Skip to content

Commit

Permalink
[debug](http) logs for debugging http
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Jun 16, 2023
1 parent 5573858 commit 0d06b42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions be/src/http/action/stream_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ void StreamLoadAction::handle(HttpRequest* req) {
// add new line at end
str = str + '\n';
HttpChannel::send_reply(req, str);
LOG(INFO) << "http reply req " << req->debug_string() << " res " << str;
#ifndef BE_TEST
if (config::enable_stream_load_record) {
str = ctx->prepare_stream_load_record(str);
Expand Down
9 changes: 9 additions & 0 deletions be/src/http/ev_http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static void on_chunked(struct evhttp_request* ev_req, void* param) {
static void on_close(evhttp_connection* con, void* arg) {
HttpRequest* request = (HttpRequest*)arg;
{
LOG(INFO) << "close connection "<< (void*)con;
std::lock_guard<std::mutex> l(g_conn_req_map_lock);
auto itr = g_conn_req_map.find(con);
if (itr != g_conn_req_map.end()) {
Expand All @@ -71,6 +72,7 @@ static void on_close(evhttp_connection* con, void* arg) {
<< " current HttpRequest=" << request
<< " but orginal HttpRequest=" << itr->second;
}
LOG(INFO) << "close connection "<< (void*)con << " req " << itr->second->debug_string();
delete itr->second;
}
g_conn_req_map.erase(con);
Expand All @@ -81,6 +83,8 @@ static void on_close(evhttp_connection* con, void* arg) {
static void on_free(struct evhttp_request* ev_req, void* arg) {
HttpRequest* request = (HttpRequest*)arg;
{
LOG(INFO) << "free request "<< (void*)arg << " conn " << ev_req->evcon
<< " req " << request->debug_string();
std::lock_guard<std::mutex> l(g_conn_req_map_lock);
auto itr = g_conn_req_map.find(ev_req->evcon);
if (itr != g_conn_req_map.end()) {
Expand All @@ -97,6 +101,10 @@ static void on_free(struct evhttp_request* ev_req, void* arg) {
}
}

static void on_error(evhttp_request_error error, void*) {
LOG(INFO) << "http fail, error " << error;
}

static void on_request(struct evhttp_request* ev_req, void* arg) {
auto request = (HttpRequest*)ev_req->on_free_cb_arg;
if (request == nullptr) {
Expand Down Expand Up @@ -308,6 +316,7 @@ int EvHttpServer::on_header(struct evhttp_request* ev_req) {

struct evhttp_connection* httpcon = evhttp_request_get_connection(ev_req);
evhttp_connection_set_closecb(httpcon, on_close, request.get());
evhttp_request_set_error_cb(ev_req, on_error);
evhttp_request_set_on_free_cb(ev_req, on_free, request.release());
struct bufferevent* bufev = evhttp_connection_get_bufferevent(httpcon);
if (bufev) bufferevent_enable(bufev, EV_READ);
Expand Down

0 comments on commit 0d06b42

Please sign in to comment.