about summary refs log tree commit homepage
path: root/http_get.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-07 20:03:34 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-26 20:41:08 +0000
commit37a5071021601480384c2abe20f2d33ad974579d (patch)
treeb0cc006c9cac9da7002e44adcfba2737bc0ce83f /http_get.c
parentfe1e1200c1541676e6b8402b7972a16105a76a63 (diff)
downloadcmogstored-37a5071021601480384c2abe20f2d33ad974579d.tar.gz
Our "all.stp" tapset now generates awk-friendly output for feeding
some sample awk scripts.

Using awk (and gawk) was necessary to avoid reimplementing strftime
in guru mode for generating CLF (Common Log Format) HTTP access logs.

Using awk also gives us several advantages:

* floating point number support (for time differences)

* a more familiar language to systems administrators
  (given this is for MogileFS, perhaps Perl would be even
   more familiar...).

* fast edit/run cycle, so the slowness of using stap to
  rebuild/reload the kernel module for all.stp changes can
  be avoided when output must be customized.
Diffstat (limited to 'http_get.c')
-rw-r--r--http_get.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/http_get.c b/http_get.c
index 98735f0..acca0df 100644
--- a/http_get.c
+++ b/http_get.c
@@ -48,7 +48,7 @@ static off_t http_get_resp_hdr(struct mog_fd *mfd, struct stat *sb)
 {
         struct mog_http *http = &mfd->as.http;
         char *modified;
-        void *buf;
+        char *buf;
         size_t len;
         struct mog_now *now = mog_now();
         long long count;
@@ -56,7 +56,7 @@ static off_t http_get_resp_hdr(struct mog_fd *mfd, struct stat *sb)
 
         /* single buffer so we can use MSG_MORE */
         buf = mog_fsbuf_get(&len);
-        modified = (char *)buf + len / 2;
+        modified = buf + len / 2;
         assert((len / 2) > MOG_HTTPDATE_CAPA && "fsbuf too small");
         mog_http_date(modified, MOG_HTTPDATE_CAPA, &sb->st_mtime);
 
@@ -174,6 +174,8 @@ bad_range:
         if (http->_p.http_method == MOG_HTTP_METHOD_HEAD)
                 count = 0;
 
+
+        TRACE(CMOGSTORED_HTTP_RES_START(mfd->fd, buf + sizeof("HTTP/1.1")));
         http->wbuf = mog_trysend(mfd->fd, buf, len, (off_t)count);
 
         return (off_t)count;
@@ -191,6 +193,9 @@ void mog_http_get_open(struct mog_fd *mfd, char *buf)
         assert(http->forward == NULL && "already have http->forward");
         assert(path[0] == '/' && "bad path");
 
+        TRACE(CMOGSTORED_HTTP_REQ_START(mfd->fd,
+                http->_p.http_method == MOG_HTTP_METHOD_HEAD ?
+                "HEAD" : "GET", path));
         if (path[1] == '\0') { /* keep "mogadm check" happy */
                 sb.st_mtime = 0;
                 sb.st_size = 0;
@@ -284,6 +289,7 @@ retry:
                        (long long)file->foff);
         }
 done:
+        TRACE(CMOGSTORED_HTTP_BYTES_XFER(mfd->fd, file->foff));
         mog_file_close(http->forward);
         if (http->_p.persistent) {
                 mog_http_reset(mfd);