非结构化接口线程安全

This commit is contained in:
zhangchengwei
2018-09-29 11:28:09 +08:00
committed by zhengchao
parent 27d7b503c7
commit 09a3d6598d
5 changed files with 41 additions and 15 deletions

View File

@@ -204,6 +204,7 @@ int cache_delete_minio_object(struct tango_cache_ctx *ctx)
CURLMcode rc;
char minio_url[256];
ctx->instance->statistic.del_recv_num += 1;
if(NULL == (ctx->curl=curl_easy_init()))
{
return 0;
@@ -505,6 +506,8 @@ int tango_cache_upload_once_start_data(struct tango_cache_ctx *ctx, enum PUT_MEM
CURLMcode rc;
char minio_url[256];
ctx->instance->statistic.put_recv_num += 1;
ctx->instance->error_code = CACHE_OK;
if(NULL == (ctx->curl=curl_easy_init()))
{
tango_cache_ctx_destroy(ctx);
@@ -556,7 +559,9 @@ int tango_cache_upload_once_start_evbuf(struct tango_cache_ctx *ctx, enum EVBUFF
{
size_t size;
ctx->put.evbuf = evbuffer_new();
ctx->instance->statistic.put_recv_num += 1;
ctx->instance->error_code = CACHE_OK;
size = evbuffer_get_length(evbuf);
if(way == EVBUFFER_MOVE)
{
@@ -639,7 +644,6 @@ static size_t curl_get_response_body_cb(void *ptr, size_t size, size_t count, vo
ctx->fail_state = true;
ctx->error_code = CACHE_ERR_CURL;
ctx->get.state = GET_STATE_DELETE;
ctx->instance->statistic.del_recv_num += 1;
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, "cache Expires or x-amz-meta-lm not found");
return size*count;
}
@@ -679,7 +683,6 @@ static bool check_expires_header(struct tango_cache_ctx *ctx, const char *expire
ctx->fail_state = true;
ctx->error_code = CACHE_TIMEOUT;
ctx->get.state = GET_STATE_DELETE; //<2F><><EFBFBD><EFBFBD>ʧЧʱ<D0A7><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ctx->instance->statistic.del_recv_num += 1;
easy_string_destroy(&ctx->response);
promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, "cache not fresh");
return false;
@@ -791,6 +794,7 @@ int tango_cache_fetch_start(struct tango_cache_ctx *ctx)
CURLMcode rc;
char minio_url[256];
ctx->instance->statistic.get_recv_num += 1;
if(NULL == (ctx->curl=curl_easy_init()))
{
tango_cache_ctx_destroy(ctx);