From: Yao Zongyou Date: Mon, 25 Dec 2017 12:35:43 +0000 (+0800) Subject: rgw: log the right http status code in civetweb frontend's access log X-Git-Tag: v13.0.2~622^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=53ab5fccf95abe8dba783eb9509c2d2c98002a44;p=ceph.git rgw: log the right http status code in civetweb frontend's access log Fixes: http://tracker.ceph.com/issues/22538 Signed-off-by: Yao Zongyou --- diff --git a/src/rgw/rgw_civetweb_frontend.cc b/src/rgw/rgw_civetweb_frontend.cc index 8cf7a20b0dc..9b405760feb 100644 --- a/src/rgw/rgw_civetweb_frontend.cc +++ b/src/rgw/rgw_civetweb_frontend.cc @@ -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() diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index 6fbf2fdb594..ecea70c055c 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -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; diff --git a/src/rgw/rgw_process.h b/src/rgw/rgw_process.h index 3aaeaff61af..699ee1c5544 100644 --- a/src/rgw/rgw_process.h +++ b/src/rgw/rgw_process.h @@ -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,