Merge pull request #582 from ctiller/chex2

Make valgrind a bit more useful
diff --git a/INSTALL b/INSTALL
index d2f08ec..f1e7aa7 100644
--- a/INSTALL
+++ b/INSTALL
@@ -95,6 +95,44 @@
 
   # apt-get install clang libc++-dev
 
+Mac-specific notes:
+-------------------
+
+For a Mac system, git is not available by default. You will first need to
+install Xcode from the Mac AppStore and then run the following command from a
+terminal:
+
+  $ sudo xcode-select --install
+
+You should also install "port" following the instructions at
+https://www.macports.org . This will reside in /opt/local/bin/port for
+most Mac installations. Do the "git submodule" command listed above.
+
+Then execute the following for all the needed build dependencies
+
+  $ sudo /opt/local/bin/port install autoconf automake libtool gflags cmake
+  $ mkdir ~/gtest
+  $ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
+  $ mkdir mybuild
+  $ cd mybuild
+  $ cmake ../gtest-svn
+  $ make
+  $ make gtest.a gtest_main.a
+  $ sudo cp libgtest.a libgtest_main.a /opt/local/lib
+  $ sudo mkdir /opt/local/include/gtest
+  $ sudo cp -pr ../gtest-svn/include/gtest /opt/local/include/gtest 
+
+We will also need to make openssl and install it appropriately
+
+  $ cd <git directory>
+  $ cd third_party/openssl
+  $ sudo make install
+  $ cd ../../
+
+If you are going to make changes and need to regenerate the projects file,
+you will need to install certain modules for python.
+
+  $ sudo easy_install simplejson mako
 
 A word on OpenSSL
 -----------------
diff --git a/Makefile b/Makefile
index e45b128..92def36 100644
--- a/Makefile
+++ b/Makefile
@@ -177,7 +177,9 @@
 
 INCLUDES = . include $(GENDIR)
 ifeq ($(SYSTEM),Darwin)
+INCLUDES += /usr/local/ssl/include /opt/local/include
 LIBS = m z
+LDFLAGS += -L/usr/local/ssl/lib -L/opt/local/lib
 else
 LIBS = rt m z pthread
 LDFLAGS += -pthread
diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h
index b33cc3d..4a720d1 100644
--- a/include/grpc/grpc.h
+++ b/include/grpc/grpc.h
@@ -354,10 +354,18 @@
   } data;
 } grpc_op;
 
-/* Initialize the grpc library */
+/* Initialize the grpc library.
+   It is not safe to call any other grpc functions before calling this.
+   (To avoid overhead, little checking is done, and some things may work. We
+   do not warrant that they will continue to do so in future revisions of this
+   library). */
 void grpc_init(void);
 
-/* Shut down the grpc library */
+/* Shut down the grpc library. 
+   No memory is used by grpc after this call returns, nor are any instructions
+   executing within the grpc library.
+   Prior to calling, all application owned grpc objects must have been
+   destroyed. */
 void grpc_shutdown(void);
 
 grpc_completion_queue *grpc_completion_queue_create(void);
@@ -386,7 +394,12 @@
 void grpc_event_finish(grpc_event *event);
 
 /* Begin destruction of a completion queue. Once all possible events are
-   drained it's safe to call grpc_completion_queue_destroy. */
+   drained then grpc_completion_queue_next will start to produce
+   GRPC_QUEUE_SHUTDOWN events only. At that point it's safe to call 
+   grpc_completion_queue_destroy. 
+   
+   After calling this function applications should ensure that no
+   NEW work is added to be published on this completion queue. */
 void grpc_completion_queue_shutdown(grpc_completion_queue *cq);
 
 /* Destroy a completion queue. The caller must ensure that the queue is
diff --git a/templates/Makefile.template b/templates/Makefile.template
index 3e0f77c..d107801 100644
--- a/templates/Makefile.template
+++ b/templates/Makefile.template
@@ -194,7 +194,9 @@
 
 INCLUDES = . include $(GENDIR)
 ifeq ($(SYSTEM),Darwin)
+INCLUDES += /usr/local/ssl/include /opt/local/include
 LIBS = m z
+LDFLAGS += -L/usr/local/ssl/lib -L/opt/local/lib
 else
 LIBS = rt m z pthread
 LDFLAGS += -pthread