]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: log the right http status code in civetweb frontend's access log 19678/head
authorYao Zongyou <yaozongyou@vip.qq.com>
Mon, 25 Dec 2017 12:35:43 +0000 (20:35 +0800)
committerYao Zongyou <yaozongyou@vip.qq.com>
Mon, 25 Dec 2017 12:35:43 +0000 (20:35 +0800)
Fixes: http://tracker.ceph.com/issues/22538
Signed-off-by: Yao Zongyou <yaozongyou@vip.qq.com>
src/rgw/rgw_civetweb_frontend.cc
src/rgw/rgw_process.cc
src/rgw/rgw_process.h

index 8cf7a20b0dc0110f355f95ecb633a0c651de3919..9b405760feb4d99db07b05ff65fbefd36c256ce7 100644 (file)
@@ -31,15 +31,20 @@ int RGWCivetWebFrontend::process(struct mg_connection*  const conn)
   RGWRestfulIO client_io(dout_context, &real_client_io);
 
   RGWRequest req(env.store->get_new_req_id());
+  int http_ret = 0;
   int ret = process_request(env.store, env.rest, &req, env.uri_prefix,
-                            *env.auth_registry, &client_io, env.olog);
+                            *env.auth_registry, &client_io, env.olog, &http_ret);
   if (ret < 0) {
     /* We don't really care about return code. */
     dout(20) << "process_request() returned " << ret << dendl;
   }
 
-  /* Mark as processed. */
-  return 1;
+  if (http_ret <= 0) {
+    /* Mark as processed. */
+    return 1;
+  }
+
+  return http_ret;
 }
 
 int RGWCivetWebFrontend::run()
index 6fbf2fdb594f005b5fdcb63a1457a96db1dc7327..ecea70c055cb8b6bfd621f941474bdf648159e74 100644 (file)
@@ -115,7 +115,8 @@ int process_request(RGWRados* const store,
                     const std::string& frontend_prefix,
                     const rgw_auth_registry_t& auth_registry,
                     RGWRestfulIO* const client_io,
-                    OpsLogSocket* const olog)
+                    OpsLogSocket* const olog,
+                    int* http_ret)
 {
   int ret = 0;
 
@@ -216,14 +217,16 @@ done:
     rgw_log_op(store, rest, s, (op ? op->name() : "unknown"), olog);
   }
 
-  int http_ret = s->err.http_ret;
+  if (http_ret != nullptr) {
+    *http_ret = s->err.http_ret;
+  }
   int op_ret = 0;
   if (op) {
     op_ret = op->get_ret();
   }
 
   req->log_format(s, "op status=%d", op_ret);
-  req->log_format(s, "http status=%d", http_ret);
+  req->log_format(s, "http status=%d", s->err.http_ret);
 
   if (handler)
     handler->put_op(op);
@@ -231,7 +234,7 @@ done:
 
   dout(1) << "====== req done req=" << hex << req << dec
          << " op status=" << op_ret
-         << " http_status=" << http_ret
+         << " http_status=" << s->err.http_ret
          << " ======"
          << dendl;
 
index 3aaeaff61afb818664a5f8f2878485d3927d61a6..699ee1c5544a3b8d09b32043d647cbc46b20312e 100644 (file)
@@ -196,7 +196,8 @@ extern int process_request(RGWRados* store,
                            const std::string& frontend_prefix,
                            const rgw_auth_registry_t& auth_registry,
                            RGWRestfulIO* client_io,
-                           OpsLogSocket* olog);
+                           OpsLogSocket* olog,
+                           int* http_ret = nullptr);
 
 extern int rgw_process_authenticated(RGWHandler_REST* handler,
                                      RGWOp*& op,