monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[monit-dev] [monit] r213 committed - log more specific error in case of


From: monit
Subject: [monit-dev] [monit] r213 committed - log more specific error in case of stream failure
Date: Thu, 29 Jul 2010 11:36:33 +0000

Revision: 213
Author: martin2812
Date: Thu Jul 29 04:35:44 2010
Log: log more specific error in case of stream failure
http://code.google.com/p/monit/source/detail?r=213

Modified:
 /trunk/md5.c
 /trunk/util.c

=======================================
--- /trunk/md5.c        Thu Jun  4 12:28:53 2009
+++ /trunk/md5.c        Thu Jul 29 04:35:44 2010
@@ -162,15 +162,16 @@
          sum += n;
        }
       while (sum < BLOCKSIZE && n != 0);
-      if (n == 0 && ferror (stream))
-        return 1;
-
-      /* If end of file is reached, end the loop.  */
-      if (n == 0)
-       break;
-
-      /* Process buffer with BLOCKSIZE bytes.  Note that
-                       BLOCKSIZE % 64 == 0
+      if (n == 0) {
+        int error = ferror(stream);
+        if (error) {
+ LogError("md5_stream: stream error -- sum=%d, error=0x%x\n", sum, error);
+          return error;
+        } else
+          break; /* If end of file is reached, end the loop.  */
+      }
+
+      /* Process buffer with BLOCKSIZE bytes. Note that BLOCKSIZE % 64 == 0
        */
       md5_process_block (buffer, BLOCKSIZE, &ctx);
     }
=======================================
--- /trunk/util.c       Mon Jul 26 07:54:50 2010
+++ /trunk/util.c       Thu Jul 29 04:35:44 2010
@@ -1440,6 +1440,7 @@
       hashlength = 20;
       break;
     default:
+      LogError("checksum: invalid hash type: 0x%x\n", hashtype);
       return FALSE;
   }

@@ -1462,14 +1463,18 @@
       }

       fclose(f);
-      if (fresult)
+      if (fresult) {
+        LogError("checksum: file %s stream error (0x%x)\n", file, fresult);
         return FALSE;
+      }

       Util_digest2Bytes(sum, hashlength, buf);
       return TRUE;

-    }
-  }
+    } else
+      LogError("checksum: failed to open file %s -- %s\n", file, STRERROR);
+  } else
+    LogError("checksum: file %s is not regular file\n", file);
   return FALSE;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]