From ece26bbf602c649193e2b1c1da699cdbfe65fda5 Mon Sep 17 00:00:00 2001 From: zhangchengwei Date: Mon, 15 Oct 2018 16:38:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9GET/PUT=E5=AF=B9=E5=A4=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=9Bcache=20miss=E4=B8=8D=E7=AE=97fail?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/include/cache_evbase_client.h | 14 +-- cache/include/tango_cache_client.h | 42 ++++--- cache/src/cache_evbase_client.cpp | 30 ++--- cache/src/tango_cache_client.cpp | 56 ++++----- cache/src/tango_cache_client_in.h | 11 +- cache/src/tango_cache_transfer.cpp | 141 +++++++++++++---------- cache/test/cache_evbase_test.cpp | 69 +++++------ cache/test/cache_evbase_test_threads.cpp | 68 +++++------ cache/test/tango_cache_test.c | 66 ++++++----- 9 files changed, 264 insertions(+), 233 deletions(-) diff --git a/cache/include/cache_evbase_client.h b/cache/include/cache_evbase_client.h index 538b6d7..15bf3c3 100644 --- a/cache/include/cache_evbase_client.h +++ b/cache/include/cache_evbase_client.h @@ -33,24 +33,24 @@ struct cache_evbase_instance *cache_evbase_instance_new(const char* profile_path //GET接口,成功返回0,失败返回-1,future回调函数会在另外的线程中执行,下同 -int cache_evbase_fetch_object(struct cache_evbase_instance *instance, struct future* future, struct tango_cache_meta *meta); +int cache_evbase_fetch_object(struct cache_evbase_instance *instance, struct future* f, struct tango_cache_meta_get *meta); struct tango_cache_result *cache_evbase_read_result(void *promise_result); //DELETE接口 -int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct future* future, const char *objkey); +int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct future* f, const char *objkey); //一次性上传接口 -int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct future* future, +int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct future* f, enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, - struct tango_cache_meta *meta, + struct tango_cache_meta_put *meta, char *path/*OUT*/, size_t pathsize); -int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struct future* future, +int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struct future* f, struct evbuffer *evbuf, - struct tango_cache_meta *meta, + struct tango_cache_meta_put *meta, char *path/*OUT*/, size_t pathsize); //流式上传接口 -struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance *instance, struct future* future, struct tango_cache_meta *meta); +struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance *instance, struct future* f, struct tango_cache_meta_put *meta); int cache_evbase_update_frag_data(struct cache_evbase_ctx *ctx_asyn, enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size); int cache_evbase_update_frag_evbuf(struct cache_evbase_ctx *ctx_asyn, struct evbuffer *evbuf); void cache_evbase_update_end(struct cache_evbase_ctx *ctx_asyn); diff --git a/cache/include/tango_cache_client.h b/cache/include/tango_cache_client.h index 5e3da6a..75c4e10 100644 --- a/cache/include/tango_cache_client.h +++ b/cache/include/tango_cache_client.h @@ -43,7 +43,7 @@ struct cache_statistics long long put_error_num;//UPLOAD失败的次数 long long del_recv_num; //发起DELETE的次数 long long del_succ_num; //DELETE成功的次数 - long long del_error_num;//DELETE成功的次数 + long long del_error_num;//DELETE失败的次数 long long totaldrop_num;//内存满以及WiredLB出错时DROP的次数 long long memory_used; //当前UPLOAD BODY所占内存大小 long long session_num; //当前正在进行GET/PUT的HTTP会话数 @@ -51,16 +51,19 @@ struct cache_statistics enum CACHE_RESULT_TYPE { - RESULT_TYPE_HEADER=0, //只调用一次 - RESULT_TYPE_USERTAG, //只调用一次 + RESULT_TYPE_HEADER=0, //最多只调用一次 + RESULT_TYPE_USERTAG, //最多只调用一次 RESULT_TYPE_BODY, //可能调用多次 + RESULT_TYPE_END, //全部结束,只调用一次,不附带数据 + RESULT_TYPE_MISS, //缓存未命中,与其他类型互斥,只调用一次(有END之意),不附带数据 }; //promise_success的结果result struct tango_cache_result { - const void *data_frag; //如果type为RESULT_TYPE_HEADER,每个头部后会包含一个换行(HTTP1.1格式) + const char *data_frag; //如果type为RESULT_TYPE_HEADER,每个头部后会包含一个换行(HTTP1.1格式) size_t size; + size_t tlength; //对象的总长度,回调时都有效 enum CACHE_RESULT_TYPE type; }; @@ -74,16 +77,19 @@ enum CACHE_HTTP_HDR_TYPE HDR_CONTENT_NUM, }; -struct tango_cache_meta +struct tango_cache_meta_get { const char* url; //缓存:URL;非结构化日志:文件名;最大长度256字节 + struct request_freshness get; +}; + +struct tango_cache_meta_put +{ + const char* url; const char* std_hdr[HDR_CONTENT_NUM]; //完整头部,如"Content-Type: text/html",不要包含换行;NULL表示没有该头部; const char* usertag; //可以是任意内容,GET时会原样返回 size_t usertag_len; //最大长度USER_TAG_MAX_LEN,0表示没有该头部 - union{ - struct response_freshness put; - struct request_freshness get; - }; + struct response_freshness put; }; struct tango_cache_instance; @@ -102,16 +108,16 @@ struct tango_cache_instance *tango_cache_instance_new(struct event_base* evbase, /* GET接口的API*/ -//成功时回调promise_success, result为NULL时表示结束; +//成功时回调promise_success //失败时回调promise_failed(仅一次),使用get_last_error获取错误码; //future不可以为NULL -int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta *meta); +int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta); //从promise_success的result参数提取结果 -struct tango_cache_result *tango_cache_read_result(future_result_t *result); +struct tango_cache_result *tango_cache_read_result(void *promise_result); /* DELETE接口的API*/ -int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* future, const char *objkey); +int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* f, const char *objkey); /* UPLOAD接口的API @@ -121,17 +127,17 @@ int tango_cache_delete_object(struct tango_cache_instance *instance, struct futu /*完整一次上传API*/ //若path不为空,则输出对象的存储路径 //返回值: 0-成功;<0失败;下同 -int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* future, +int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* f, enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, - struct tango_cache_meta *meta, + struct tango_cache_meta_put *meta, char *path/*OUT*/, size_t pathsize); -int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* future, +int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* f, enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf, - struct tango_cache_meta *meta, + struct tango_cache_meta_put *meta, char *path/*OUT*/, size_t pathsize); /*流式上传API*/ //返回值: 若为NULL则表示创建失败,调用tango_cache_ctx_error查看错误码是否是CACHE_OUTOF_MEMORY(正常情况下是); -struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta); +struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_put *meta); //返回值: 0-成功;<0失败,调用tango_cache_get_last_error查看错误码; int tango_cache_update_frag_data(struct tango_cache_ctx *ctx, const char *data, size_t size); int tango_cache_update_frag_evbuf(struct tango_cache_ctx *ctx, enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf); diff --git a/cache/src/cache_evbase_client.cpp b/cache/src/cache_evbase_client.cpp index 40de5c2..0f9059b 100644 --- a/cache/src/cache_evbase_client.cpp +++ b/cache/src/cache_evbase_client.cpp @@ -325,13 +325,13 @@ int cache_evbase_update_frag_evbuf(struct cache_evbase_ctx *ctx_asyn, struct evb return 0; } -struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance *instance, struct future* future, struct tango_cache_meta *meta) +struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance *instance, struct future* f, struct tango_cache_meta_put *meta) { struct cache_evbase_ctx *ctx_asyn; struct tango_cache_ctx *ctx; struct databuffer *buffer; - ctx = tango_cache_update_prepare(instance->instance, future, meta); + ctx = tango_cache_update_prepare(instance->instance, f, meta); if(ctx == NULL) { return NULL; @@ -357,14 +357,14 @@ struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance return ctx_asyn; } -int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct future* future, - enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta *meta, char *path, size_t pathsize) +int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct future* f, + enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta_put *meta, char *path, size_t pathsize) { struct cache_evbase_ctx *ctx_asyn; struct tango_cache_ctx *ctx; struct databuffer *buffer; - ctx = tango_cache_update_prepare(instance->instance, future, meta); + ctx = tango_cache_update_prepare(instance->instance, f, meta); if(ctx == NULL) { return -1; @@ -404,14 +404,14 @@ int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct return 0; } -int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struct future* future, - struct evbuffer *evbuf, struct tango_cache_meta *meta, char *path, size_t pathsize) +int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struct future* f, + struct evbuffer *evbuf, struct tango_cache_meta_put *meta, char *path, size_t pathsize) { struct cache_evbase_ctx *ctx_asyn; struct tango_cache_ctx *ctx; struct databuffer *buffer; - ctx = tango_cache_update_prepare(instance->instance, future, meta); + ctx = tango_cache_update_prepare(instance->instance, f, meta); if(ctx == NULL) { return -1; @@ -443,14 +443,14 @@ int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struc return 0; } -int cache_evbase_fetch_object(struct cache_evbase_instance *instance, struct future* future, struct tango_cache_meta *meta) +int cache_evbase_fetch_object(struct cache_evbase_instance *instance, struct future* f, struct tango_cache_meta_get *meta) { struct cache_evbase_ctx *ctx_asyn; struct databuffer *buffer; ctx_asyn = (struct cache_evbase_ctx *)calloc(1, sizeof(struct cache_evbase_ctx)); ctx_asyn->instance_asyn = instance; - ctx_asyn->ctx = tango_cache_fetch_prepare(instance->instance, future, meta); + ctx_asyn->ctx = tango_cache_fetch_prepare(instance->instance, f, meta); if(ctx_asyn->ctx == NULL) { free(ctx_asyn); @@ -464,7 +464,7 @@ int cache_evbase_fetch_object(struct cache_evbase_instance *instance, struct fut if(iothread_notify_event(instance->notify_sendfd, &buffer, sizeof(void *), 2) != sizeof(void *)) { tango_cache_set_fail_state(ctx_asyn->ctx, CACHE_ERR_SOCKPAIR); - promise_failed(future_to_promise(future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx_asyn->ctx)); + promise_failed(future_to_promise(f), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx_asyn->ctx)); tango_cache_ctx_destroy(ctx_asyn->ctx); cache_asyn_ctx_destroy(ctx_asyn); free(buffer); @@ -473,14 +473,14 @@ int cache_evbase_fetch_object(struct cache_evbase_instance *instance, struct fut return 0; } -int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct future* future, const char *objkey) +int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct future* f, const char *objkey) { struct cache_evbase_ctx *ctx_asyn; struct databuffer *buffer; ctx_asyn = (struct cache_evbase_ctx *)calloc(1, sizeof(struct cache_evbase_ctx)); ctx_asyn->instance_asyn = instance; - ctx_asyn->ctx = tango_cache_delete_prepare(instance->instance, future, objkey); + ctx_asyn->ctx = tango_cache_delete_prepare(instance->instance, f, objkey); if(ctx_asyn->ctx == NULL) { free(ctx_asyn); @@ -495,9 +495,9 @@ int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct fu if(iothread_notify_event(instance->notify_sendfd, &buffer, sizeof(void *), 2) != sizeof(void *)) { tango_cache_set_fail_state(ctx_asyn->ctx, CACHE_ERR_SOCKPAIR); - if(future != NULL) + if(f != NULL) { - promise_failed(future_to_promise(future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx_asyn->ctx)); + promise_failed(future_to_promise(f), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx_asyn->ctx)); } tango_cache_ctx_destroy(ctx_asyn->ctx); cache_asyn_ctx_destroy(ctx_asyn); diff --git a/cache/src/tango_cache_client.cpp b/cache/src/tango_cache_client.cpp index 2038b35..140b7e0 100644 --- a/cache/src/tango_cache_client.cpp +++ b/cache/src/tango_cache_client.cpp @@ -87,7 +87,7 @@ const char *tango_cache_get_errstring(const struct tango_cache_ctx *ctx) case CACHE_OUTOF_MEMORY:return "outof memory"; case CACHE_ERR_WIREDLB: return "wiredlb error"; case CACHE_ERR_SOCKPAIR:return "socketpair error"; - case CACHE_ERR_INTERNAL:return "cache Expires or x-amz-meta-lm not found"; + case CACHE_ERR_INTERNAL:return "internal error"; default: return ctx->error; } } @@ -136,10 +136,10 @@ static void update_statistics(struct tango_cache_ctx *ctx, struct cache_statisti case CACHE_REQUEST_GET: if(ctx->fail_state) { - if(ctx->error_code == CACHE_ERR_CURL) - statistic->get_error_num += 1; - else + if(ctx->error_code == CACHE_CACHE_MISS || ctx->error_code == CACHE_TIMEOUT) statistic->get_miss_num += 1; + else + statistic->get_error_num += 1; } else { @@ -297,7 +297,7 @@ int tango_cache_update_frag_evbuf(struct tango_cache_ctx *ctx, enum EVBUFFER_COP return 0; } -struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta) +struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_put *meta) { struct tango_cache_ctx *ctx; char buffer[256]={0}; @@ -312,7 +312,7 @@ struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance * ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx)); ctx->instance = instance; - ctx->future = future; + ctx->future = f; ctx->method = CACHE_REQUEST_PUT; if(instance->hash_object_key) @@ -375,11 +375,11 @@ struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance * return ctx; } -struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta) +struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_put *meta) { struct tango_cache_ctx *ctx; - ctx = tango_cache_update_prepare(instance, future, meta); + ctx = tango_cache_update_prepare(instance, f, meta); if(ctx == NULL) { return NULL; @@ -389,12 +389,12 @@ struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *in return ctx; } -int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* future, - enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta *meta, char *path, size_t pathsize) +int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* f, + enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta_put *meta, char *path, size_t pathsize) { struct tango_cache_ctx *ctx; - ctx = tango_cache_update_prepare(instance, future, meta); + ctx = tango_cache_update_prepare(instance, f, meta); if(ctx == NULL) { return -1; @@ -407,12 +407,12 @@ int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct f return tango_cache_upload_once_start_data(ctx, way, data, size); } -int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* future, - enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf, struct tango_cache_meta *meta, char *path, size_t pathsize) +int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* f, + enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf, struct tango_cache_meta_put *meta, char *path, size_t pathsize) { struct tango_cache_ctx *ctx; - ctx = tango_cache_update_prepare(instance, future, meta); + ctx = tango_cache_update_prepare(instance, f, meta); if(ctx == NULL) { return -1; @@ -425,14 +425,14 @@ int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct return tango_cache_upload_once_start_evbuf(ctx, way, evbuf); } -struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta) +struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta) { struct tango_cache_ctx *ctx; char sha256[72]={0}; ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx)); ctx->instance = instance; - ctx->future = future; + ctx->future = f; ctx->method = CACHE_REQUEST_GET; ctx->get.state = GET_STATE_START; ctx->get.max_age = meta->get.max_age; @@ -457,11 +457,11 @@ struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *i return ctx; } -int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta) +int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta) { struct tango_cache_ctx *ctx; - ctx = tango_cache_fetch_prepare(instance, future, meta); + ctx = tango_cache_fetch_prepare(instance, f, meta); if(ctx == NULL) { return -1; @@ -469,14 +469,14 @@ int tango_cache_fetch_object(struct tango_cache_instance *instance, struct futur return tango_cache_fetch_start(ctx); } -struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* future, const char *objkey) +struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* f, const char *objkey) { struct tango_cache_ctx *ctx; char sha256[72]={0}; ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx)); ctx->instance = instance; - ctx->future = future; + ctx->future = f; ctx->method = CACHE_REQUEST_DELETE; if(instance->hash_object_key) @@ -498,11 +498,11 @@ struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance * return ctx; } -int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* future, const char *objkey) +int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* f, const char *objkey) { struct tango_cache_ctx *ctx; - ctx = tango_cache_delete_prepare(instance, future, objkey); + ctx = tango_cache_delete_prepare(instance, f, objkey); if(ctx == NULL) { return -1; @@ -510,14 +510,14 @@ int tango_cache_delete_object(struct tango_cache_instance *instance, struct futu return (cache_delete_minio_object(ctx)==1)?0:-1; } -struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_instance *instance, struct future* future, char *objlist[], u_int32_t num) +struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_instance *instance, struct future* f, char *objlist[], u_int32_t num) { struct tango_cache_ctx *ctx; char md5[48]={0}, content_md5[48]; ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx)); ctx->instance = instance; - ctx->future = future; + ctx->future = f; ctx->method = CACHE_REQUEST_DELETE_MUL; ctx->del.succ_num = num; @@ -534,15 +534,16 @@ struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_inst sprintf(content_md5, "Content-MD5: %s", md5); ctx->headers = curl_slist_append(ctx->headers, content_md5); ctx->headers = curl_slist_append(ctx->headers, "Content-Type: application/xml"); + ctx->headers = curl_slist_append(ctx->headers, "Expect:"); return ctx; } //TODO: AccessDenied -int tango_cache_multi_delete(struct tango_cache_instance *instance, struct future* future, char *objlist[], u_int32_t num) +int tango_cache_multi_delete(struct tango_cache_instance *instance, struct future* f, char *objlist[], u_int32_t num) { struct tango_cache_ctx *ctx; - ctx = tango_cache_multi_delete_prepare(instance, future, objlist, num); + ctx = tango_cache_multi_delete_prepare(instance, f, objlist, num); if(ctx == NULL) { return -1; @@ -752,9 +753,8 @@ static int load_local_configure(struct tango_cache_instance *instance, const cha MESA_load_profile_string_def(profile_path, section, "WIREDLB_GROUP", instance->wiredlb_group, 64, "KAZAKHSTAN"); MESA_load_profile_string_def(profile_path, section, "WIREDLB_DATACENTER", instance->wiredlb_datacenter, 64, "ASTANA"); MESA_load_profile_uint_def(profile_path, section, "WIREDLB_OVERRIDE", &instance->wiredlb_override, 1); - MESA_load_profile_uint_def(profile_path, section, "WIREDLB_HEALTH_PORT", &intval, 52100); - instance->wiredlb_ha_port=(unsigned short)intval; + instance->wiredlb_ha_port = (u_int16_t)intval; return 0; } diff --git a/cache/src/tango_cache_client_in.h b/cache/src/tango_cache_client_in.h index 12a2fee..879bd1e 100644 --- a/cache/src/tango_cache_client_in.h +++ b/cache/src/tango_cache_client_in.h @@ -55,6 +55,7 @@ struct tango_cache_instance u_int32_t minio_port; u_int32_t wiredlb_override; u_int16_t wiredlb_ha_port; + u_int32_t hash_object_key; struct event_base* evbase; struct event timer_event; struct cache_statistics statistic; @@ -66,7 +67,6 @@ struct tango_cache_instance long max_cnn_host; u_int32_t upload_block_size; //minio分段上传块的最小长度 enum CACHE_ERR_CODE error_code; - u_int32_t hash_object_key; }; struct multipart_etag_list @@ -78,13 +78,14 @@ struct multipart_etag_list struct cache_ctx_data_get { - time_t max_age;//Get - time_t min_fresh;//Get + time_t max_age; + time_t min_fresh; time_t expires; time_t last_modify; u_int32_t need_hdrs; enum GET_OBJECT_STATE state; struct easy_string response_tag; + struct tango_cache_result result; }; struct cache_ctx_data_put @@ -144,8 +145,8 @@ void tango_cache_ctx_destroy(struct tango_cache_ctx *ctx); void tango_cache_set_fail_state(struct tango_cache_ctx *ctx, enum CACHE_ERR_CODE error_code); const char *tango_cache_get_errstring(const struct tango_cache_ctx *ctx); -struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta); -struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta); +struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta_put *meta); +struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta_get *meta); struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* future, const char *objkey); #endif diff --git a/cache/src/tango_cache_transfer.cpp b/cache/src/tango_cache_transfer.cpp index 55b0cb6..bf7eb20 100644 --- a/cache/src/tango_cache_transfer.cpp +++ b/cache/src/tango_cache_transfer.cpp @@ -647,48 +647,10 @@ int tango_cache_multi_delete_start(struct tango_cache_ctx *ctx) return 0; } -void tango_cache_curl_get_done(struct tango_cache_ctx *ctx, CURLcode res, long res_code) -{ - switch(ctx->get.state) - { - case GET_STATE_START: - if(!ctx->fail_state) - { - if(res!=CURLE_OK || res_code!=200L) - { - tango_cache_set_fail_state(ctx, (res!=CURLE_OK)?CACHE_ERR_CURL:CACHE_CACHE_MISS); - promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); - } - else - { - promise_success(future_to_promise(ctx->future), NULL); - } - } - tango_cache_ctx_destroy(ctx); - break; - - case GET_STATE_DELETE: - if(cache_delete_minio_object(ctx)) - { - ctx->get.state = GET_STATE_END; - } - else - { - tango_cache_ctx_destroy(ctx); - } - break; - - case GET_STATE_END: - tango_cache_ctx_destroy(ctx); - break; - default: assert(0);break; - } -} static size_t curl_get_response_body_cb(void *ptr, size_t size, size_t count, void *userp) { struct tango_cache_ctx *ctx = (struct tango_cache_ctx *)userp; - struct tango_cache_result result; if(ctx->fail_state || ctx->get.state==GET_STATE_DELETE) { @@ -705,24 +667,24 @@ static size_t curl_get_response_body_cb(void *ptr, size_t size, size_t count, vo if(ctx->get.response_tag.len > 0) { - result.data_frag = ctx->get.response_tag.buff; - result.size = ctx->get.response_tag.len; - result.type = RESULT_TYPE_USERTAG; - promise_success(future_to_promise(ctx->future), &result); + ctx->get.result.data_frag = ctx->get.response_tag.buff; + ctx->get.result.size = ctx->get.response_tag.len; + ctx->get.result.type = RESULT_TYPE_USERTAG; + promise_success(future_to_promise(ctx->future), &ctx->get.result); easy_string_destroy(&ctx->get.response_tag); } if(ctx->response.len > 0) { - result.data_frag = ctx->response.buff; - result.size = ctx->response.len; - result.type = RESULT_TYPE_HEADER; - promise_success(future_to_promise(ctx->future), &result); + ctx->get.result.data_frag = ctx->response.buff; + ctx->get.result.size = ctx->response.len; + ctx->get.result.type = RESULT_TYPE_HEADER; + promise_success(future_to_promise(ctx->future), &ctx->get.result); easy_string_destroy(&ctx->response); } - result.data_frag = ptr; - result.size = size * count; - result.type = RESULT_TYPE_BODY; - promise_success(future_to_promise(ctx->future), &result); + ctx->get.result.data_frag = (const char *)ptr; + ctx->get.result.size = size * count; + ctx->get.result.type = RESULT_TYPE_BODY; + promise_success(future_to_promise(ctx->future), &ctx->get.result); return size*count; } @@ -733,12 +695,13 @@ static bool check_expires_header(struct tango_cache_ctx *ctx, const char *expire ctx->get.expires = expires_hdr2timestamp(expires_val, len); time_gmt = get_gmtime_timestamp(time(NULL)); - if(time_gmt > ctx->get.expires) //缓存失效;TODO relative_age的含义是啥 + if(time_gmt > ctx->get.expires) { tango_cache_set_fail_state(ctx, CACHE_TIMEOUT); ctx->get.state = GET_STATE_DELETE; //缓存失效时在下载完毕时触发删除动作 + ctx->get.result.type = RESULT_TYPE_MISS; + promise_success(future_to_promise(ctx->future), &ctx->get.result); easy_string_destroy(&ctx->response); - promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); return false; } return true; @@ -755,24 +718,38 @@ static bool check_fresh_header(struct tango_cache_ctx *ctx) if(ctx->get.last_modify+ctx->get.max_age > now_gmt || now_gmt+ctx->get.min_fresh>ctx->get.expires) { tango_cache_set_fail_state(ctx, CACHE_TIMEOUT); + ctx->get.result.type = RESULT_TYPE_MISS; + promise_success(future_to_promise(ctx->future), &ctx->get.result); easy_string_destroy(&ctx->response); - promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); return false; } return true; } -static bool check_get_result_code(struct tango_cache_ctx *ctx) +static bool check_get_result_code(struct tango_cache_ctx *ctx, CURLcode code, long res_code) { - CURLcode code; - - code = curl_easy_getinfo(ctx->curl, CURLINFO_RESPONSE_CODE, &ctx->res_code); - if(code != CURLE_OK || ctx->res_code!=200L) + if(code != CURLE_OK) { - tango_cache_set_fail_state(ctx, (code!=CURLE_OK)?CACHE_ERR_CURL:CACHE_CACHE_MISS); + tango_cache_set_fail_state(ctx, CACHE_ERR_CURL); promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); return false; } + + if(res_code != 200L) + { + if(res_code == 404L) + { + tango_cache_set_fail_state(ctx, CACHE_CACHE_MISS); + ctx->get.result.type = RESULT_TYPE_MISS; + promise_success(future_to_promise(ctx->future), &ctx->get.result); + } + else + { + tango_cache_set_fail_state(ctx, CACHE_ERR_INTERNAL); + promise_failed(future_to_promise(ctx->future), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx)); + } + return false; + } return true; } @@ -788,9 +765,13 @@ static size_t curl_get_response_header_cb(void *ptr, size_t size, size_t count, { return raw_len; } - if(ctx->res_code==0 && !check_get_result_code(ctx)) //首次应答时先看应答码是否是200 + if(ctx->res_code == 0) //首次应答时先看应答码是否是200 { - return raw_len; + CURLcode code = curl_easy_getinfo(ctx->curl, CURLINFO_RESPONSE_CODE, &ctx->res_code); + if(!check_get_result_code(ctx, code, ctx->res_code)) + { + return raw_len; + } } pos_colon = (char*)memchr(start, ':', raw_len); if(pos_colon == NULL) @@ -831,9 +812,14 @@ static size_t curl_get_response_header_cb(void *ptr, size_t size, size_t count, } } break; + case 14: + if(strcmp_one_word_mesa_equal_len("content-length", "CONTENT-LENGTH", start, 14)) + { + sscanf(pos_colon+1, "%lu", &ctx->get.result.tlength); + } + break; case 11: if(strcmp_one_word_mesa_equal_len("content-md5", "CONTENT-MD5", start, 11)) easy_string_savedata(&ctx->response, (const char*)ptr, raw_len); break; case 12: if(strcmp_one_word_mesa_equal_len("content-type", "CONTENT-TYPE", start, 12)) easy_string_savedata(&ctx->response, (const char*)ptr, raw_len); break; - case 14: if(strcmp_one_word_mesa_equal_len("content-length", "CONTENT-LENGTH", start, 14)) easy_string_savedata(&ctx->response, (const char*)ptr, raw_len); break; case 16: if(strcmp_one_word_mesa_equal_len("content-encoding", "CONTENT-ENCODING", start, 16)) easy_string_savedata(&ctx->response, (const char*)ptr, raw_len); break; case 19: if(strcmp_one_word_mesa_equal_len("content-disposition", "CONTENT-DISPOSITION", start, 19)) easy_string_savedata(&ctx->response, (const char*)ptr, raw_len); break; default: break; @@ -841,6 +827,37 @@ static size_t curl_get_response_header_cb(void *ptr, size_t size, size_t count, return raw_len; } +void tango_cache_curl_get_done(struct tango_cache_ctx *ctx, CURLcode res, long res_code) +{ + switch(ctx->get.state) + { + case GET_STATE_START: + if(!ctx->fail_state && check_get_result_code(ctx, res, res_code)) + { + ctx->get.result.type = RESULT_TYPE_END; + promise_success(future_to_promise(ctx->future), &ctx->get.result); + } + tango_cache_ctx_destroy(ctx); + break; + + case GET_STATE_DELETE: + if(cache_delete_minio_object(ctx)) + { + ctx->get.state = GET_STATE_END; + } + else + { + tango_cache_ctx_destroy(ctx); + } + break; + + case GET_STATE_END: + tango_cache_ctx_destroy(ctx); + break; + default: assert(0);break; + } +} + int tango_cache_fetch_start(struct tango_cache_ctx *ctx) { CURLMcode rc; diff --git a/cache/test/cache_evbase_test.cpp b/cache/test/cache_evbase_test.cpp index f4b4ddd..9670cbc 100644 --- a/cache/test/cache_evbase_test.cpp +++ b/cache/test/cache_evbase_test.cpp @@ -37,29 +37,28 @@ void get_future_success(future_result_t* result, void * user) struct future_pdata *pdata = (struct future_pdata *)user; char buffer[1024]; - if(res != NULL) + switch(res->type) { - switch(res->type) - { - case RESULT_TYPE_BODY: - fwrite(res->data_frag, res->size, 1, pdata->fp); - break; - - case RESULT_TYPE_USERTAG: - case RESULT_TYPE_HEADER: - memcpy(buffer, res->data_frag, res->size>=1024?1023:res->size); - buffer[res->size] = '\0'; - printf("%s", buffer); - break; - default:break; - } - } - else //结束 - { - future_destroy(pdata->future); - fclose(pdata->fp); - free(pdata); - runing_over = 1; + case RESULT_TYPE_USERTAG: + case RESULT_TYPE_HEADER: + memcpy(buffer, res->data_frag, res->size>=1024?1023:res->size); + buffer[res->size] = '\0'; + printf("%s", buffer); + break; + case RESULT_TYPE_BODY: + fwrite(res->data_frag, res->size, 1, pdata->fp); + break; + case RESULT_TYPE_MISS: + printf("cache not hit/fresh\n"); + case RESULT_TYPE_END: + if(res->type != RESULT_TYPE_MISS) + printf("get cache over, total length: %ld\n", res->tlength); + future_destroy(pdata->future); + fclose(pdata->fp); + free(pdata); + runing_over = 1; + break; + default:break; } } @@ -150,7 +149,8 @@ int main(int argc, char **argv) { int n, index=0; char method[16], filename_in[256], filename_out[256], *p; - struct tango_cache_meta meta; + struct tango_cache_meta_put putmeta; + struct tango_cache_meta_get getmeta; struct future_pdata *pdata; struct cache_evbase_ctx *ctx; void *runtime_log; @@ -183,12 +183,15 @@ int main(int argc, char **argv) } if(strlen(filename_in) > 0) { - memset(&meta, 0, sizeof(struct tango_cache_meta)); - meta.url = filename_in; - meta.std_hdr[HDR_CONTENT_TYPE] = "Content-Type: maintype/subtype"; - meta.std_hdr[HDR_CONTENT_ENCODING] = "Content-Encoding: gzip"; - meta.usertag = "Etag: hgdkqkwdwqekdfjwjfjwelkjfkwfejwhf\r\n"; - meta.usertag_len = strlen(meta.usertag); + memset(&putmeta, 0, sizeof(struct tango_cache_meta_put)); + memset(&getmeta, 0, sizeof(struct tango_cache_meta_get)); + putmeta.url = filename_in; + putmeta.std_hdr[HDR_CONTENT_TYPE] = "Content-Type: maintype/subtype"; + putmeta.std_hdr[HDR_CONTENT_ENCODING] = "Content-Encoding: gzip"; + putmeta.usertag = "Etag: hgdkqkwdwqekdfjwjfjwelkjfkwfejwhf\r\n"; + putmeta.usertag_len = strlen(putmeta.usertag); + + getmeta.url = filename_in; p = method; while(*p=='\r'||*p=='\n') p++; @@ -201,7 +204,7 @@ int main(int argc, char **argv) promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); pdata->fp = fopen(filename_out, "w"); - cache_evbase_fetch_object(instance_asyn, pdata->future, &meta); + cache_evbase_fetch_object(instance_asyn, pdata->future, &getmeta); } else if(!strcasecmp(p, "DEL")) { @@ -217,7 +220,7 @@ int main(int argc, char **argv) pdata->future = future_create(put_future_success, put_future_failed, pdata); promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); - cache_evbase_upload_once_data(instance_asyn, pdata->future, PUT_MEM_FREE, p, filelen, &meta, pdata->filename, 256); + cache_evbase_upload_once_data(instance_asyn, pdata->future, PUT_MEM_FREE, p, filelen, &putmeta, pdata->filename, 256); } else if(!strcasecmp(p, "PUTONCEEV")) { @@ -238,14 +241,14 @@ int main(int argc, char **argv) evbuffer_add(evbuf, buffer, readlen); } fclose(fp); - cache_evbase_upload_once_evbuf(instance_asyn, pdata->future, evbuf, &meta, pdata->filename, 256); + cache_evbase_upload_once_evbuf(instance_asyn, pdata->future, evbuf, &putmeta, pdata->filename, 256); } else { pdata->future = future_create(put_future_success, put_future_failed, pdata); promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); - ctx = cache_evbase_update_start(instance_asyn, pdata->future, &meta); + ctx = cache_evbase_update_start(instance_asyn, pdata->future, &putmeta); cache_evbase_get_object_path(ctx, pdata->filename, 256); char buffer[1024]; diff --git a/cache/test/cache_evbase_test_threads.cpp b/cache/test/cache_evbase_test_threads.cpp index 20bc861..9d3827b 100644 --- a/cache/test/cache_evbase_test_threads.cpp +++ b/cache/test/cache_evbase_test_threads.cpp @@ -38,29 +38,28 @@ void get_future_success(future_result_t* result, void * user) struct future_pdata *pdata = (struct future_pdata *)user; char buffer[1024]; - if(res != NULL) + switch(res->type) { - switch(res->type) - { - case RESULT_TYPE_BODY: - fwrite(res->data_frag, res->size, 1, pdata->fp); - break; - - case RESULT_TYPE_USERTAG: - case RESULT_TYPE_HEADER: - memcpy(buffer, res->data_frag, res->size>=1024?1023:res->size); - buffer[res->size] = '\0'; - printf("%s", buffer); - break; - default:break; - } - } - else //结束 - { - future_destroy(pdata->future); - fclose(pdata->fp); - free(pdata); - runing_over = 1; + case RESULT_TYPE_USERTAG: + case RESULT_TYPE_HEADER: + memcpy(buffer, res->data_frag, res->size>=1024?1023:res->size); + buffer[res->size] = '\0'; + printf("%s", buffer); + break; + case RESULT_TYPE_BODY: + fwrite(res->data_frag, res->size, 1, pdata->fp); + break; + case RESULT_TYPE_MISS: + printf("cache not hit/fresh\n"); + case RESULT_TYPE_END: + if(res->type != RESULT_TYPE_MISS) + printf("get cache over, total length: %ld\n", res->tlength); + future_destroy(pdata->future); + fclose(pdata->fp); + free(pdata); + runing_over = 1; + break; + default:break; } } @@ -158,7 +157,8 @@ void* thread_upload_download(void *arg) { int n; char method[16], filename_in[256], filename_out[256], *p; - struct tango_cache_meta meta; + struct tango_cache_meta_put putmeta; + struct tango_cache_meta_get getmeta; struct future_pdata *pdata; struct cache_evbase_ctx *ctx; struct pthread_data *thread_data = (struct pthread_data *)arg; @@ -172,12 +172,14 @@ void* thread_upload_download(void *arg) return NULL; } - memset(&meta, 0, sizeof(struct tango_cache_meta)); - meta.url = filename_in; - meta.std_hdr[HDR_CONTENT_TYPE] = "Content-Type: maintype/subtype"; - meta.std_hdr[HDR_CONTENT_ENCODING] = "Content-Encoding: gzip"; - meta.usertag = "Etag: hgdkqkwdwqekdfjwjfjwelkjfkwfejwhf\r\n"; - meta.usertag_len = strlen(meta.usertag); + memset(&putmeta, 0, sizeof(struct tango_cache_meta_put)); + putmeta.url = filename_in; + putmeta.std_hdr[HDR_CONTENT_TYPE] = "Content-Type: maintype/subtype"; + putmeta.std_hdr[HDR_CONTENT_ENCODING] = "Content-Encoding: gzip"; + putmeta.usertag = "Etag: hgdkqkwdwqekdfjwjfjwelkjfkwfejwhf\r\n"; + putmeta.usertag_len = strlen(putmeta.usertag); + + getmeta.url = filename_in; p = method; while(*p=='\r'||*p=='\n') p++; @@ -194,7 +196,7 @@ void* thread_upload_download(void *arg) promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); pdata->fp = fopen(filename_out, "w"); - cache_evbase_fetch_object(instance_asyn, pdata->future, &meta); + cache_evbase_fetch_object(instance_asyn, pdata->future, &getmeta); } else if(!strcasecmp(p, "DEL")) { @@ -210,7 +212,7 @@ void* thread_upload_download(void *arg) pdata->future = future_create(put_future_success, put_future_failed, pdata); promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); - if(cache_evbase_upload_once_data(instance_asyn, pdata->future, PUT_MEM_FREE, p, filelen, &meta, pdata->filename, 256)) + if(cache_evbase_upload_once_data(instance_asyn, pdata->future, PUT_MEM_FREE, p, filelen, &putmeta, pdata->filename, 256)) { printf("cache_evbase_upload_once_data fail: %d\n", cache_evbase_ctx_error(instance_asyn)); future_destroy(pdata->future); @@ -236,7 +238,7 @@ void* thread_upload_download(void *arg) evbuffer_add(evbuf, buffer, readlen); } fclose(fp); - if(cache_evbase_upload_once_evbuf(instance_asyn, pdata->future, evbuf, &meta, pdata->filename, 256)) + if(cache_evbase_upload_once_evbuf(instance_asyn, pdata->future, evbuf, &putmeta, pdata->filename, 256)) { printf("cache_evbase_upload_once_evbuf fail: %d\n", cache_evbase_ctx_error(instance_asyn)); future_destroy(pdata->future); @@ -249,7 +251,7 @@ void* thread_upload_download(void *arg) pdata->future = future_create(put_future_success, put_future_failed, pdata); promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); - ctx = cache_evbase_update_start(instance_asyn, pdata->future, &meta); + ctx = cache_evbase_update_start(instance_asyn, pdata->future, &putmeta); if(ctx==NULL) { printf("cache_evbase_update_start fail: %d\n", cache_evbase_ctx_error(instance_asyn)); diff --git a/cache/test/tango_cache_test.c b/cache/test/tango_cache_test.c index b8102c0..36a2bc3 100644 --- a/cache/test/tango_cache_test.c +++ b/cache/test/tango_cache_test.c @@ -50,28 +50,27 @@ void get_future_success(future_result_t* result, void * user) struct future_pdata *pdata = (struct future_pdata *)user; char buffer[1024]; - if(res != NULL) + switch(res->type) { - switch(res->type) - { - case RESULT_TYPE_BODY: - fwrite(res->data_frag, res->size, 1, pdata->fp); - break; - - case RESULT_TYPE_USERTAG: - case RESULT_TYPE_HEADER: - memcpy(buffer, res->data_frag, res->size>=1024?1023:res->size); - buffer[res->size] = '\0'; - printf("%s", buffer); - break; - default:break; - } - } - else - { - future_destroy(pdata->future); - fclose(pdata->fp); - free(pdata); + case RESULT_TYPE_USERTAG: + case RESULT_TYPE_HEADER: + memcpy(buffer, res->data_frag, res->size>=1024?1023:res->size); + buffer[res->size] = '\0'; + printf("%s", buffer); + break; + case RESULT_TYPE_BODY: + fwrite(res->data_frag, res->size, 1, pdata->fp); + break; + case RESULT_TYPE_MISS: + printf("cache not hit/fresh\n"); + case RESULT_TYPE_END: + if(res->type != RESULT_TYPE_MISS) + printf("get cache over, total length: %ld\n", res->tlength); + future_destroy(pdata->future); + fclose(pdata->fp); + free(pdata); + break; + default:break; } } @@ -166,7 +165,8 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg) char *dellist[16]; char *pstart, *save_ptr=NULL; int delnum=0; - struct tango_cache_meta meta; + struct tango_cache_meta_put putmeta; + struct tango_cache_meta_get getmeta; struct future_pdata *pdata; struct tango_cache_ctx *ctx; @@ -181,12 +181,14 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg) { p = method; - memset(&meta, 0, sizeof(struct tango_cache_meta)); - meta.url = s; - meta.std_hdr[HDR_CONTENT_TYPE] = "Content-Type: maintype/subtype"; - meta.std_hdr[HDR_CONTENT_ENCODING] = "Content-Encoding: gzip"; - meta.usertag = "Etag: hgdkqkwdwqekdfjwjfjwelkjfkwfejwhf\r\n"; - meta.usertag_len = strlen(meta.usertag); + memset(&putmeta, 0, sizeof(struct tango_cache_meta_put)); + putmeta.url = s; + putmeta.std_hdr[HDR_CONTENT_TYPE] = "Content-Type: maintype/subtype"; + putmeta.std_hdr[HDR_CONTENT_ENCODING] = "Content-Encoding: gzip"; + putmeta.usertag = "Etag: hgdkqkwdwqekdfjwjfjwelkjfkwfejwhf\r\n"; + putmeta.usertag_len = strlen(putmeta.usertag); + + getmeta.url = s; while(*p=='\r'||*p=='\n')p++; if(*p=='\0') continue; @@ -197,7 +199,7 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg) pdata->future = future_create(get_future_success, get_future_failed, pdata); promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); - tango_cache_fetch_object(tango_instance, pdata->future, &meta); + tango_cache_fetch_object(tango_instance, pdata->future, &getmeta); } else if(!strcasecmp(p, "PUTONCE")) { @@ -206,7 +208,7 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg) pdata->future = future_create(put_future_success, put_future_failed, pdata); promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); - tango_cache_upload_once_data(tango_instance, pdata->future, PUT_MEM_FREE, p, filelen, &meta, pdata->filename, 256); + tango_cache_upload_once_data(tango_instance, pdata->future, PUT_MEM_FREE, p, filelen, &putmeta, pdata->filename, 256); } else if(!strcasecmp(p, "PUTONCEEV")) { @@ -227,7 +229,7 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg) evbuffer_add(evbuf, buffer, readlen); } fclose(fp); - tango_cache_upload_once_evbuf(tango_instance, pdata->future, EVBUFFER_MOVE, evbuf, &meta, pdata->filename, 256); + tango_cache_upload_once_evbuf(tango_instance, pdata->future, EVBUFFER_MOVE, evbuf, &putmeta, pdata->filename, 256); } else if(!strcasecmp(p, "DEL")) { @@ -253,7 +255,7 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg) pdata->future = future_create(put_future_success, put_future_failed, pdata); promise_set_ctx(future_to_promise(pdata->future), NULL, NULL); - ctx = tango_cache_update_start(tango_instance, pdata->future, &meta); + ctx = tango_cache_update_start(tango_instance, pdata->future, &putmeta); tango_cache_get_object_path(ctx, pdata->filename, 256); FILE *fp = fopen(s, "r");