Blame SOURCES/server-Add-detailed-request-logging.patch

472fdf
From f413cc257c6c1e60090c72163152ae7fd2180c41 Mon Sep 17 00:00:00 2001
472fdf
From: Alexander Scheel <ascheel@redhat.com>
472fdf
Date: Fri, 4 Aug 2017 16:09:20 -0400
472fdf
Subject: [PATCH] [server] Add detailed request logging
472fdf
472fdf
Add request logging to track requests through gssproxy.  Requests are
472fdf
logged as they are read, processed, handled, and replies sent.  These
472fdf
are identified by buffer memory address and size.
472fdf
472fdf
Signed-off-by: Alexander Scheel <ascheel@redhat.com>
472fdf
Reviewed-by: Simo Sorce <simo@redhat.com>
472fdf
[rharwood@redhat.com: commit message cleanups, rebase]
472fdf
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
472fdf
Merges: #205
472fdf
(cherry picked from commit 4097dafad3f276c3cf7b1255fe0540e16d59ae03)
472fdf
---
472fdf
 proxy/src/gp_rpc_process.c |  6 ++++++
472fdf
 proxy/src/gp_socket.c      | 12 ++++++++++++
472fdf
 proxy/src/gp_workers.c     |  5 +++++
472fdf
 3 files changed, 23 insertions(+)
472fdf
472fdf
diff --git a/proxy/src/gp_rpc_process.c b/proxy/src/gp_rpc_process.c
472fdf
index 0ea17f0..eaffc55 100644
472fdf
--- a/proxy/src/gp_rpc_process.c
472fdf
+++ b/proxy/src/gp_rpc_process.c
472fdf
@@ -372,9 +372,12 @@ int gp_rpc_process_call(struct gp_call_ctx *gpcall,
472fdf
     xdrmem_create(&xdr_reply_ctx, reply_buffer, MAX_RPC_SIZE, XDR_ENCODE);
472fdf
 
472fdf
     /* decode request */
472fdf
+    GPDEBUGN(3, "[status] Processing request [%p (%zu)]\n", inbuf, inlen);
472fdf
     ret = gp_rpc_decode_call(&xdr_call_ctx, &xid, &proc, &arg, &acc, &rej;;
472fdf
     if (!ret) {
472fdf
         /* execute request */
472fdf
+        GPDEBUGN(3, "[status] Executing request %d (%s) from [%p (%zu)]\n",
472fdf
+                 proc, gp_rpc_procname(proc), inbuf, inlen);
472fdf
         ret = gp_rpc_execute(gpcall, proc, &arg, &res;;
472fdf
         if (ret) {
472fdf
             acc = GP_RPC_SYSTEM_ERR;
472fdf
@@ -388,6 +391,9 @@ int gp_rpc_process_call(struct gp_call_ctx *gpcall,
472fdf
         /* return encoded buffer */
472fdf
         ret = gp_rpc_return_buffer(&xdr_reply_ctx,
472fdf
                                    reply_buffer, outbuf, outlen);
472fdf
+        GPDEBUGN(3, "[status] Returned buffer %d (%s) from [%p (%zu)]: "
472fdf
+                 "[%p (%zu)]\n", proc, gp_rpc_procname(proc), inbuf, inlen,
472fdf
+                 *outbuf, *outlen);
472fdf
     }
472fdf
     /* free resources */
472fdf
     gp_rpc_free_xdrs(proc, &arg, &res;;
472fdf
diff --git a/proxy/src/gp_socket.c b/proxy/src/gp_socket.c
472fdf
index 5064e51..8675a0e 100644
472fdf
--- a/proxy/src/gp_socket.c
472fdf
+++ b/proxy/src/gp_socket.c
472fdf
@@ -441,6 +441,8 @@ void gp_socket_send_data(verto_ctx *vctx, struct gp_conn *conn,
472fdf
 
472fdf
     wbuf = calloc(1, sizeof(struct gp_buffer));
472fdf
     if (!wbuf) {
472fdf
+        GPDEBUGN(3, "[status] OOM in gp_socket_send_data: %p (%zu)\n",
472fdf
+                 buffer, buflen);
472fdf
         /* too bad, must kill the client connection now */
472fdf
         gp_conn_free(conn);
472fdf
         return;
472fdf
@@ -467,6 +469,8 @@ static void gp_socket_write(verto_ctx *vctx, verto_ev *ev)
472fdf
 
472fdf
     vecs = 0;
472fdf
 
472fdf
+    GPDEBUGN(3, "[status] Sending data: %p (%zu)\n", wbuf->data, wbuf->size);
472fdf
+
472fdf
     if (wbuf->pos == 0) {
472fdf
         /* first write, send the buffer size as packet header */
472fdf
         size = wbuf->size | FRAGMENT_BIT;
472fdf
@@ -489,6 +493,9 @@ static void gp_socket_write(verto_ctx *vctx, verto_ev *ev)
472fdf
             gp_socket_schedule_write(vctx, wbuf);
472fdf
         } else {
472fdf
             /* error on socket, close and release it */
472fdf
+            GPDEBUGN(3, "[status] Error %d in gp_socket_write on writing for "
472fdf
+                     "[%p (%zu:%zu)]\n", errno, wbuf->data, wbuf->pos,
472fdf
+                     wbuf->size);
472fdf
             gp_conn_free(wbuf->conn);
472fdf
             gp_buffer_free(wbuf);
472fdf
         }
472fdf
@@ -498,6 +505,8 @@ static void gp_socket_write(verto_ctx *vctx, verto_ev *ev)
472fdf
         if (wn < (ssize_t) sizeof(size)) {
472fdf
             /* don't bother trying to handle sockets that can't
472fdf
              * buffer even 4 bytes */
472fdf
+            GPDEBUGN(3, "[status] Sending data [%p (%zu)]: failed with short "
472fdf
+                     "write of %d\n", wbuf->data, wbuf->size, wn);
472fdf
             gp_conn_free(wbuf->conn);
472fdf
             gp_buffer_free(wbuf);
472fdf
             return;
472fdf
@@ -505,6 +514,9 @@ static void gp_socket_write(verto_ctx *vctx, verto_ev *ev)
472fdf
         wn -= sizeof(size);
472fdf
     }
472fdf
 
472fdf
+    GPDEBUGN(3, "[status] Sending data [%p (%zu)]: successful write of %d\n",
472fdf
+             wbuf->data, wbuf->size, wn);
472fdf
+
472fdf
     wbuf->pos += wn;
472fdf
     if (wbuf->size > wbuf->pos) {
472fdf
         /* short write, reschedule */
472fdf
diff --git a/proxy/src/gp_workers.c b/proxy/src/gp_workers.c
472fdf
index d37e57c..2a33c21 100644
472fdf
--- a/proxy/src/gp_workers.c
472fdf
+++ b/proxy/src/gp_workers.c
472fdf
@@ -319,6 +319,7 @@ static void gp_handle_reply(verto_ctx *vctx, verto_ev *ev)
472fdf
             break;
472fdf
 
472fdf
         case GP_QUERY_OUT:
472fdf
+            GPDEBUGN(3, "[status] Handling query reply: %p (%zu)\n", q->buffer, q->buflen);
472fdf
             gp_socket_send_data(vctx, q->conn, q->buffer, q->buflen);
472fdf
             gp_query_free(q, false);
472fdf
             break;
472fdf
@@ -381,7 +382,11 @@ static void *gp_worker_main(void *pvt)
472fdf
         gp_debug_set_conn_id(gp_conn_get_cid(q->conn));
472fdf
 
472fdf
         /* handle the client request */
472fdf
+        GPDEBUGN(3, "[status] Handling query input: %p (%zu)\n", q->buffer,
472fdf
+                 q->buflen);
472fdf
         gp_handle_query(t->pool, q);
472fdf
+        GPDEBUGN(3 ,"[status] Handling query output: %p (%zu)\n", q->buffer,
472fdf
+                 q->buflen);
472fdf
 
472fdf
         /* now get lock on main queue, to play with the reply list */
472fdf
         /* ======> POOL LOCK */