[1]统一GET/PUT结束后结果通知机制,API直接调用失败时不回调,其他情况回调(promise);
[2]hiredis版本确定为0.14.0版; [3]修复tango_cache_ctx_destroy中TAILQ内存释放的BUG;
This commit is contained in:
55
cache/src/cache_evbase_client.cpp
vendored
55
cache/src/cache_evbase_client.cpp
vendored
@@ -153,36 +153,47 @@ static void cache_asyn_ctx_destroy(struct cache_evbase_ctx *ctx_asyn)
|
||||
static void cache_asyn_ioevent_dispatch(struct databuffer *buffer)
|
||||
{
|
||||
struct cache_evbase_ctx *ctx_asyn=buffer->ctx_asyn;
|
||||
struct future *f;
|
||||
int ret=0;
|
||||
|
||||
switch(buffer->cmd_type)
|
||||
{
|
||||
case CACHE_ASYN_FETCH:
|
||||
tango_cache_fetch_start(ctx_asyn->ctx);
|
||||
f = ctx_asyn->ctx->future;
|
||||
if(tango_cache_fetch_start(ctx_asyn->ctx) < 0)
|
||||
{
|
||||
promise_failed(future_to_promise(f), FUTURE_ERROR_CANCEL, "CACHE_ASYN_FETCH failed");
|
||||
}
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
break;
|
||||
case CACHE_ASYN_HEAD:
|
||||
f = ctx_asyn->ctx->future;
|
||||
if(ctx_asyn->instance_asyn->instance->head_meta_source == HEAD_META_FROM_REDIS)
|
||||
{
|
||||
tango_cache_head_redis(ctx_asyn->ctx);
|
||||
ret = tango_cache_head_redis(ctx_asyn->ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
tango_cache_fetch_start(ctx_asyn->ctx);
|
||||
}
|
||||
ret = tango_cache_fetch_start(ctx_asyn->ctx);
|
||||
}
|
||||
if(ret<0)
|
||||
{
|
||||
promise_failed(future_to_promise(f), FUTURE_ERROR_CANCEL, "CACHE_ASYN_HEAD failed");
|
||||
}
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
break;
|
||||
|
||||
case CACHE_ASYN_DELETE:
|
||||
cache_delete_minio_object(ctx_asyn->ctx);
|
||||
cache_delete_minio_object(ctx_asyn->ctx, true);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
break;
|
||||
|
||||
case CACHE_ASYN_UPLOAD_ONCE_DATA:
|
||||
tango_cache_upload_once_start_data(ctx_asyn->ctx, PUT_MEM_FREE, buffer->data, buffer->size);
|
||||
tango_cache_upload_once_start_data(ctx_asyn->ctx, PUT_MEM_FREE, buffer->data, buffer->size, true);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
break;
|
||||
case CACHE_ASYN_UPLOAD_ONCE_EVBUF:
|
||||
tango_cache_upload_once_start_evbuf(ctx_asyn->ctx, EVBUFFER_MOVE, buffer->evbuf);
|
||||
tango_cache_upload_once_start_evbuf(ctx_asyn->ctx, EVBUFFER_MOVE, buffer->evbuf, true);
|
||||
evbuffer_free(buffer->evbuf);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
break;
|
||||
@@ -361,8 +372,8 @@ struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance
|
||||
//<2F>¼<EFBFBD>֪ͨ<CDA8><D6AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ϣ
|
||||
if(iothread_notify_event(instance->notify_sendfd, &buffer, sizeof(void *), 2) != sizeof(void *))
|
||||
{
|
||||
tango_cache_set_fail_state(ctx_asyn->ctx, CACHE_ERR_SOCKPAIR);
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx);
|
||||
instance->instance->error_code = CACHE_ERR_SOCKPAIR;
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx, false);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
free(buffer);
|
||||
return NULL;
|
||||
@@ -409,8 +420,8 @@ int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct
|
||||
{
|
||||
free(buffer->data);
|
||||
free(buffer);
|
||||
tango_cache_set_fail_state(ctx_asyn->ctx, CACHE_ERR_SOCKPAIR);
|
||||
tango_cache_ctx_destroy(ctx);
|
||||
instance->instance->error_code = CACHE_ERR_SOCKPAIR;
|
||||
tango_cache_ctx_destroy(ctx, false);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
return -2;
|
||||
}
|
||||
@@ -448,8 +459,8 @@ int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struc
|
||||
{
|
||||
evbuffer_free(buffer->evbuf);
|
||||
free(buffer);
|
||||
tango_cache_set_fail_state(ctx_asyn->ctx, CACHE_ERR_SOCKPAIR);
|
||||
tango_cache_ctx_destroy(ctx);
|
||||
instance->instance->error_code = CACHE_ERR_SOCKPAIR;
|
||||
tango_cache_ctx_destroy(ctx, false);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
return -2;
|
||||
}
|
||||
@@ -476,9 +487,8 @@ 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(f), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx_asyn->ctx));
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx);
|
||||
instance->instance->error_code = CACHE_ERR_SOCKPAIR;
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx, false);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
free(buffer);
|
||||
return -2;
|
||||
@@ -506,9 +516,8 @@ int cache_evbase_head_object(struct cache_evbase_instance *instance, struct futu
|
||||
|
||||
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(f), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx_asyn->ctx));
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx);
|
||||
instance->instance->error_code = CACHE_ERR_SOCKPAIR;
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx, false);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
free(buffer);
|
||||
return -2;
|
||||
@@ -537,12 +546,8 @@ int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct fu
|
||||
//<2F>ο<EFBFBD>Unix<69><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>432ҳ<32><D2B3><EFBFBD>ڶ<EFBFBD><DAB6>߳<EFBFBD>д<EFBFBD>İ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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(f != NULL)
|
||||
{
|
||||
promise_failed(future_to_promise(f), FUTURE_ERROR_CANCEL, tango_cache_get_errstring(ctx_asyn->ctx));
|
||||
}
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx);
|
||||
instance->instance->error_code = CACHE_ERR_SOCKPAIR;
|
||||
tango_cache_ctx_destroy(ctx_asyn->ctx, false);
|
||||
cache_asyn_ctx_destroy(ctx_asyn);
|
||||
free(buffer);
|
||||
return -2;
|
||||
|
||||
Reference in New Issue
Block a user