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

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