Re-ordered some logic.
authorcrh <crh@ubiqx.org>
Wed, 12 Sep 2012 23:07:45 +0000 (18:07 -0500)
committercrh <crh@ubiqx.org>
Wed, 12 Sep 2012 23:07:45 +0000 (18:07 -0500)
src/daemon/PrequelD.c

index 412f917eef3daa87a386adf622a58ba2d8a4b479..b00c106d23f6892ac469f76e9a1ad0cc4a5d627e 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Email: crh@ubiqx.mn.org
  *
- * $Id: PrequelD.c 2012-09-12 17:37:39 -0500 crh$
+ * $Id: PrequelD.c 2012-09-12 18:07:45 -0500 crh$
  *
  * -------------------------------------------------------------------------- **
  *
@@ -257,7 +257,7 @@ static const char *License =
 static const char *Revision =
                     "$Revision$";
 static const char *Id =
-                    "$Id: PrequelD.c 2012-09-12 17:37:39 -0500 crh$";
+                    "$Id: PrequelD.c 2012-09-12 18:07:45 -0500 crh$";
 
 static const char *HelpMsg[] =
   {
@@ -877,33 +877,30 @@ static void WorkHash( const char *srcPathName )
     (void)pthread_mutex_unlock( &GlobalMutex );
     return;
     }
-
-  /* We have mutex and a configuration entry.
-   *  Copy all of the config values so that we can release the mutex.
+  /* This should be impossible.
+   *  Check PD_read_config if this ever happens.
    */
-  if( entry->cacheDir )
-    {
-    cacheDir  = strdup( entry->cacheDir );
-    minBlocks = entry->minBlocks;
-    hashType  = entry->v1HashType;
-    syserr    = 0;
-    (void)memcpy( key, entry->userParam, PD_V1_KEY_SIZE );
-    }
-  else
+  if( NULL == (entry->cacheDir) )
     {
-    /* This should be impossible.
-     *  Check PD_read_config if this ever happens.
-     */
     Log( "Bad configuration entry; cacheDir is NULL.\n" );
     (void)pthread_mutex_unlock( &GlobalMutex );
     return;
     }
 
+  /* We have mutex and a configuration entry.
+   *  Copy all of the config values so that we can release the mutex.
+   */
+  cacheDir  = strdup( entry->cacheDir );
+  minBlocks = entry->minBlocks;
+  hashType  = entry->v1HashType;
+  syserr    = 0;
+  (void)memcpy( key, entry->userParam, PD_V1_KEY_SIZE );
   /* Check the <cacheDir> copy. */
   if( NULL == cacheDir )
     {
     if( Verbosity )
       Log( "Warning: Memory allocation failure in WorkHash().\n" );
+    (void)pthread_mutex_unlock( &GlobalMutex );
     return;
     }
 
@@ -912,6 +909,7 @@ static void WorkHash( const char *srcPathName )
    *  the mutex just now.
    */
   (void)pthread_mutex_unlock( &GlobalMutex );
+  /* FIX: If verbosity > 2 save start time & report calc time at end. */
   result = pd_v1CreateHashCache( srcPathName,
                                  cacheDir,
                                  minBlocks,