修复内存泄露
This commit is contained in:
2
cache/src/tango_cache_client.cpp
vendored
2
cache/src/tango_cache_client.cpp
vendored
@@ -214,7 +214,7 @@ void tango_cache_ctx_destroy(struct tango_cache_ctx *ctx, bool callback)
|
|||||||
case CACHE_REQUEST_PUT:
|
case CACHE_REQUEST_PUT:
|
||||||
if(ctx->put.uploadID != NULL) free(ctx->put.uploadID);
|
if(ctx->put.uploadID != NULL) free(ctx->put.uploadID);
|
||||||
if(ctx->put.combine_xml != NULL) free(ctx->put.combine_xml);
|
if(ctx->put.combine_xml != NULL) free(ctx->put.combine_xml);
|
||||||
if(ctx->put.object_meta == NULL) cJSON_Delete(ctx->put.object_meta);
|
if(ctx->put.object_meta != NULL) cJSON_Delete(ctx->put.object_meta);
|
||||||
if(ctx->put.evbuf!=NULL)
|
if(ctx->put.evbuf!=NULL)
|
||||||
{
|
{
|
||||||
ctx->instance->statistic.memory_used -= evbuffer_get_length(ctx->put.evbuf);
|
ctx->instance->statistic.memory_used -= evbuffer_get_length(ctx->put.evbuf);
|
||||||
|
|||||||
20
cache/test/cache_evbase_benchmark.cpp
vendored
20
cache/test/cache_evbase_benchmark.cpp
vendored
@@ -320,7 +320,11 @@ static void* thread_transfer_cmd(void *arg)
|
|||||||
{
|
{
|
||||||
object_store_update_frag_data(ctx, PUT_MEM_COPY, filecont.buf+(filecont.len-remain_len), remain_len);
|
object_store_update_frag_data(ctx, PUT_MEM_COPY, filecont.buf+(filecont.len-remain_len), remain_len);
|
||||||
}
|
}
|
||||||
object_store_update_end(ctx, pdata->filename, 256);
|
if(object_store_update_end(ctx, pdata->filename, 256))
|
||||||
|
{
|
||||||
|
future_destroy(pdata->future);
|
||||||
|
free(pdata);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case METHOD_HEAD:
|
case METHOD_HEAD:
|
||||||
@@ -343,7 +347,11 @@ static void* thread_transfer_cmd(void *arg)
|
|||||||
|
|
||||||
pdata = (struct future_pdata *)malloc(sizeof(struct future_pdata));
|
pdata = (struct future_pdata *)malloc(sizeof(struct future_pdata));
|
||||||
pdata->future = future_create(put_future_success, put_future_failed, pdata);
|
pdata->future = future_create(put_future_success, put_future_failed, pdata);
|
||||||
object_store_upload_once_data(instance_asyn, pdata->future, PUT_MEM_FREE, filecont.buf, filecont.len, &putmeta, pdata->filename, 256);
|
if(object_store_upload_once_data(instance_asyn, pdata->future, PUT_MEM_COPY, filecont.buf, filecont.len, &putmeta, pdata->filename, 256))
|
||||||
|
{
|
||||||
|
future_destroy(pdata->future);
|
||||||
|
free(pdata);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case METHOD_PUTONCEEV:
|
case METHOD_PUTONCEEV:
|
||||||
remain_len = filecont.len;
|
remain_len = filecont.len;
|
||||||
@@ -365,7 +373,11 @@ static void* thread_transfer_cmd(void *arg)
|
|||||||
{
|
{
|
||||||
evbuffer_add(evbuf, filecont.buf+(filecont.len-remain_len), remain_len);
|
evbuffer_add(evbuf, filecont.buf+(filecont.len-remain_len), remain_len);
|
||||||
}
|
}
|
||||||
object_store_upload_once_evbuf(instance_asyn, pdata->future, evbuf, &putmeta, pdata->filename, 256);
|
if(object_store_upload_once_evbuf(instance_asyn, pdata->future, evbuf, &putmeta, pdata->filename, 256))
|
||||||
|
{
|
||||||
|
future_destroy(pdata->future);
|
||||||
|
free(pdata);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:break;
|
default:break;
|
||||||
}
|
}
|
||||||
@@ -389,7 +401,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if(argc != 6)
|
if(argc != 6)
|
||||||
{
|
{
|
||||||
printf("USAGE: %s <method,1-GET,2-PUT> <file> <threads> <total_num> <limit_session_num>\n", argv[0]);
|
printf("USAGE: %s <method,1-GET,2-PUT,5-PUTONCE> <file> <threads> <total_num> <limit_session_num>\n", argv[0]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
cache/test/tango_cache_test.cpp
vendored
15
cache/test/tango_cache_test.cpp
vendored
@@ -262,7 +262,10 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg)
|
|||||||
pdata = (struct future_pdata *)malloc(sizeof(struct future_pdata));
|
pdata = (struct future_pdata *)malloc(sizeof(struct future_pdata));
|
||||||
pdata->future = future_create(put_future_success, put_future_failed, pdata);
|
pdata->future = future_create(put_future_success, put_future_failed, pdata);
|
||||||
|
|
||||||
tango_cache_upload_once_data(tango_instance, pdata->future, PUT_MEM_FREE, p, filelen, &putmeta, pdata->filename, 256);
|
if(tango_cache_upload_once_data(tango_instance, pdata->future, PUT_MEM_FREE, p, filelen, &putmeta, pdata->filename, 256))
|
||||||
|
{
|
||||||
|
put_future_failed(FUTURE_ERROR_CANCEL, "", pdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(!strcasecmp(p, "PUTONCEEV"))
|
else if(!strcasecmp(p, "PUTONCEEV"))
|
||||||
{
|
{
|
||||||
@@ -283,7 +286,10 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg)
|
|||||||
evbuffer_add(evbuf, buffer, readlen);
|
evbuffer_add(evbuf, buffer, readlen);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
tango_cache_upload_once_evbuf(tango_instance, pdata->future, EVBUFFER_MOVE, evbuf, &putmeta, pdata->filename, 256);
|
if(tango_cache_upload_once_evbuf(tango_instance, pdata->future, EVBUFFER_MOVE, evbuf, &putmeta, pdata->filename, 256))
|
||||||
|
{
|
||||||
|
put_future_failed(FUTURE_ERROR_CANCEL, "", pdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(!strcasecmp(p, "DEL"))
|
else if(!strcasecmp(p, "DEL"))
|
||||||
{
|
{
|
||||||
@@ -323,7 +329,10 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg)
|
|||||||
tango_cache_update_frag_data(ctx, buffer, n);
|
tango_cache_update_frag_data(ctx, buffer, n);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
tango_cache_update_end(ctx, pdata->filename, 256);
|
if(tango_cache_update_end(ctx, pdata->filename, 256))
|
||||||
|
{
|
||||||
|
put_future_failed(FUTURE_ERROR_CANCEL, "", pdata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user