diff --git a/cache/src/cache_evbase_client.cpp b/cache/src/cache_evbase_client.cpp index bf849e2..e7835ef 100644 --- a/cache/src/cache_evbase_client.cpp +++ b/cache/src/cache_evbase_client.cpp @@ -473,7 +473,7 @@ int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struc buffer->ctx_asyn = ctx_asyn; buffer->cmd_type = CACHE_ASYN_UPLOAD_ONCE_EVBUF; buffer->evbuf = evbuffer_new(); - evbuffer_add_buffer_reference(buffer->evbuf, evbuf); + evbuffer_add_buffer(buffer->evbuf, evbuf); if(iothread_notify_event(instance->notify_sendfd, &buffer, sizeof(void *), 2) != sizeof(void *)) { diff --git a/plugin/business/pangu-http/src/pangu_logger.cpp b/plugin/business/pangu-http/src/pangu_logger.cpp index e02493a..56d0b17 100644 --- a/plugin/business/pangu-http/src/pangu_logger.cpp +++ b/plugin/business/pangu-http/src/pangu_logger.cpp @@ -245,6 +245,12 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) } } + char log_file_upload_req_path[TFE_STRING_MAX]={0}, cont_type_whole[TFE_STRING_MAX]={0}; + char log_file_upload_resp_path[TFE_STRING_MAX]={0}; + memset(log_file_upload_req_path, 0, sizeof(log_file_upload_req_path)); + memset(log_file_upload_resp_path, 0, sizeof(log_file_upload_resp_path)); + memset(cont_type_whole, 0, sizeof(cont_type_whole)); + for(size_t i=0; iresult_num; i++) { if(log_msg->result[i].do_log!=1) @@ -252,65 +258,75 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) continue; } - char log_file_upload_path[TFE_STRING_MAX]={0}, cont_type_whole[TFE_STRING_MAX]={0}; struct tango_cache_meta_put meta; char* log_file_key=NULL;; const char* cont_type_val; if(log_msg->req_body!=NULL) { - memset(&meta, 0, sizeof(meta)); - asprintf(&log_file_key, "%s.reqbody", http->req->req_spec.url); - meta.url=log_file_key; - cont_type_val=tfe_http_std_field_read(http->req, TFE_HTTP_CONT_TYPE); - if(cont_type_val!=NULL) + if(log_file_upload_req_path[0] != '\0') { - snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val); - meta.std_hdr[0]=cont_type_whole; - } - meta.user_log_name=1; - tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL, - log_msg->req_body, - &meta, - log_file_upload_path, sizeof(log_file_upload_path)); - if(tmp==0) - { - cJSON_AddStringToObject(common_obj, "http_request_body", log_file_upload_path); + cJSON_AddStringToObject(common_obj, "http_request_body", log_file_upload_req_path); } else { - TFE_LOG_ERROR(handle->local_logger, "Upload req_body failed."); + memset(&meta, 0, sizeof(meta)); + asprintf(&log_file_key, "%s.reqbody", http->req->req_spec.url); + meta.url=log_file_key; + cont_type_val=tfe_http_std_field_read(http->req, TFE_HTTP_CONT_TYPE); + if(cont_type_val!=NULL) + { + snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val); + meta.std_hdr[0]=cont_type_whole; + } + meta.user_log_name=1; + tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL, + log_msg->req_body, + &meta, + log_file_upload_req_path, sizeof(log_file_upload_req_path)); + if(tmp==0) + { + cJSON_AddStringToObject(common_obj, "http_request_body", log_file_upload_req_path); + } + else + { + TFE_LOG_ERROR(handle->local_logger, "Upload req_body failed."); + } + free(log_file_key); } - free(log_file_key); } if(log_msg->resp_body!=NULL) { - memset(log_file_upload_path, 0, sizeof(log_file_upload_path)); - memset(cont_type_whole, 0, sizeof(cont_type_whole)); - - memset(&meta, 0, sizeof(meta)); - asprintf(&log_file_key, "%s.respbody", http->req->req_spec.url); - meta.url=log_file_key; - cont_type_val=tfe_http_std_field_read(http->resp, TFE_HTTP_CONT_TYPE); - if(cont_type_val!=NULL) + if(log_file_upload_resp_path[0] != '\0') { - snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val); - meta.std_hdr[0]=cont_type_whole; - } - meta.user_log_name=1; - tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL, - log_msg->resp_body, - &meta, - log_file_upload_path, sizeof(log_file_upload_path)); - - if(tmp==0) - { - cJSON_AddStringToObject(common_obj, "http_response_body", log_file_upload_path); + cJSON_AddStringToObject(common_obj, "http_response_body", log_file_upload_resp_path); } else { - TFE_LOG_ERROR(handle->local_logger, "Upload resp_body failed."); + memset(&meta, 0, sizeof(meta)); + asprintf(&log_file_key, "%s.respbody", http->req->req_spec.url); + meta.url=log_file_key; + cont_type_val=tfe_http_std_field_read(http->resp, TFE_HTTP_CONT_TYPE); + if(cont_type_val!=NULL) + { + snprintf(cont_type_whole, sizeof(cont_type_whole), "Content-Type:%s", cont_type_val); + meta.std_hdr[0]=cont_type_whole; + } + meta.user_log_name=1; + tmp=cache_evbase_upload_once_evbuf(handle->log_file_upload_instance, NULL, + log_msg->resp_body, + &meta, + log_file_upload_resp_path, sizeof(log_file_upload_resp_path)); + + if(tmp==0) + { + cJSON_AddStringToObject(common_obj, "http_response_body", log_file_upload_resp_path); + } + else + { + TFE_LOG_ERROR(handle->local_logger, "Upload resp_body failed."); + } + free(log_file_key); } - free(log_file_key); } }