Attempt to solve blocking problem with getLocalPrefix
diff --git a/ccnx/sync-ccnx-wrapper.cc b/ccnx/sync-ccnx-wrapper.cc
index c27aeb3..9a4071b 100644
--- a/ccnx/sync-ccnx-wrapper.cc
+++ b/ccnx/sync-ccnx-wrapper.cc
@@ -463,8 +463,6 @@
 string
 CcnxWrapper::getLocalPrefix ()
 {
-  recursive_mutex::scoped_lock lock(m_mutex);
-
   string retval = "";
   
   struct ccn_charbuf *templ = ccn_charbuf_create();
@@ -485,10 +483,14 @@
   }
   else
     {
+      m_mutex.lock ();
+  
       struct ccn_fetch *fetch = ccn_fetch_new (m_handle);
 
       struct ccn_fetch_stream *stream = ccn_fetch_open (fetch, name, "/local/ndn/prefix",
                                                         templ, 4, CCN_V_HIGHEST, 0);
+      m_mutex.unlock ();
+      
       if (stream == NULL) {
         _LOG_ERROR ("Cannot create ccn_fetch_stream");
       }
@@ -497,15 +499,19 @@
           ostringstream os;
           
           char buf[256];
-          while ((res = ccn_fetch_read (stream, buf, sizeof(buf))) != 0) {
+          while (true) {
+            m_mutex.lock ();
+            res = ccn_fetch_read (stream, buf, sizeof(buf));
+            m_mutex.unlock ();
+            
+            if (res == 0) {
+              break;
+            }
+            
             if (res > 0) {
               os << string(buf, res);
             } else if (res == CCN_FETCH_READ_NONE) {
-              fflush(stdout);
-              if (ccn_run (m_handle, 1000) < 0) {
-                _LOG_ERROR ("error during ccn_run");
-                break;
-              }
+              sleep (1);
             } else if (res == CCN_FETCH_READ_END) {
               break;
             } else if (res == CCN_FETCH_READ_TIMEOUT) {
@@ -516,9 +522,14 @@
             }
           }
           retval = os.str ();
+          m_mutex.lock ();
           stream = ccn_fetch_close(stream);
+          m_mutex.unlock ();
+          
         }
+      m_mutex.lock ();
       fetch = ccn_fetch_destroy(fetch);
+      m_mutex.unlock ();
     }
 
   ccn_charbuf_destroy (&name);