about summary refs log tree commit homepage
path: root/mgmt_fn.c
diff options
context:
space:
mode:
Diffstat (limited to 'mgmt_fn.c')
-rw-r--r--mgmt_fn.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/mgmt_fn.c b/mgmt_fn.c
index 8bdec2d..b1cc50a 100644
--- a/mgmt_fn.c
+++ b/mgmt_fn.c
@@ -35,13 +35,16 @@ get_path(struct iovec *dst, struct mog_mgmt *mgmt, char *buf, bool sdup)
 }
 
 /* starts the MD5 request */
-void mog_mgmt_fn_digest(struct mog_mgmt *mgmt, char *buf)
+void mog_mgmt_fn_digest(struct mog_fd *mfd, char *buf)
 {
+        struct mog_mgmt *mgmt = &mfd->as.mgmt;
         struct iovec iov[2];
         char *path = get_path(iov, mgmt, buf, true);
 
         if (!path) return;
 
+        TRACE(CMOGSTORED_MGMT_DIG_START(mfd->fd, mgmt->alg, path));
+
         mgmt->forward = mog_file_open_read(mgmt->svc, path);
         if (mgmt->forward) {
                 struct mog_file *file = &mgmt->forward->as.file;
@@ -62,6 +65,7 @@ void mog_mgmt_fn_digest(struct mog_mgmt *mgmt, char *buf)
                 default: /* Ragel parser prevents this: */
                         die("BUG: unhandled algorithm: %d", mgmt->alg);
                 }
+                TRACE(CMOGSTORED_MGMT_DIG_DONE(mfd->fd, -1));
                 mog_mgmt_writev(mgmt, iov, 2);
                 free(path);
         }
@@ -70,12 +74,13 @@ void mog_mgmt_fn_digest(struct mog_mgmt *mgmt, char *buf)
 /* finishes the MD5 request */
 #define CLEN(s) (sizeof(s)-1)
 
-void mog_mgmt_fn_digest_err(struct mog_mgmt *mgmt)
+void mog_mgmt_fn_digest_err(struct mog_fd *mfd)
 {
+        struct mog_mgmt *mgmt = &mfd->as.mgmt;
         struct iovec iov[3];
-        struct mog_fd *mfd = mgmt->forward;
-        struct mog_file *file = &mfd->as.file;
-        long long offset = (long long)lseek(mfd->fd, 0, SEEK_CUR);
+        struct mog_fd *file_mfd = mgmt->forward;
+        struct mog_file *file = &file_mfd->as.file;
+        long long offset = (long long)lseek(file_mfd->fd, 0, SEEK_CUR);
         char buf[sizeof(" at 18446744073709551615 failed\r\n") - 1];
 
         /* offset could be -1 here, but there ain't much we can do */
@@ -86,17 +91,19 @@ void mog_mgmt_fn_digest_err(struct mog_mgmt *mgmt)
         iov[2].iov_base = buf;
         iov[2].iov_len = snprintf(buf, sizeof(buf),
                                   " at %lld failed\r\n", offset);
+        TRACE(CMOGSTORED_MGMT_DIG_DONE(mfd->fd, offset));
         mog_mgmt_writev(mgmt, iov, 3);
 }
 
 /* output: "/$PATH MD5=hex\r\n" */
-void mog_mgmt_fn_digest_emit(struct mog_mgmt *mgmt)
+void mog_mgmt_fn_digest_emit(struct mog_fd *mfd)
 {
+        struct mog_mgmt *mgmt = &mfd->as.mgmt;
         struct iovec iov[2];
         char buf[CLEN(" SHA-1=") + 40 + CLEN("\r\n")];
         char *b = buf;
-        struct mog_fd *mfd = mgmt->forward;
-        struct mog_file *file = &mfd->as.file;
+        struct mog_fd *file_mfd = mgmt->forward;
+        struct mog_file *file = &file_mfd->as.file;
         size_t len;
 
         iov[0].iov_base = file->path;
@@ -122,6 +129,7 @@ void mog_mgmt_fn_digest_emit(struct mog_mgmt *mgmt)
         b[len] = '\r';
         b[len + 1] = '\n';
         iov[1].iov_base = buf;
+        TRACE(CMOGSTORED_MGMT_DIG_DONE(mfd->fd, 0));
         mog_mgmt_writev(mgmt, iov, 2);
 }