Fix certain freeing of objects and allow UV_EOF to be passed to plugins

This commit is contained in:
Nikki 2015-05-21 16:14:29 -04:00
parent 525b1c02d0
commit 1b93b4736c
2 changed files with 10 additions and 15 deletions

View File

@ -5,6 +5,14 @@ AsyncSocketContext::AsyncSocketContext(IPluginContext* pContext) {
} }
AsyncSocketContext::~AsyncSocketContext() { AsyncSocketContext::~AsyncSocketContext() {
if (connect_req != NULL) {
free(connect_req);
}
if (socket != NULL) {
uv_close((uv_handle_t *) socket, NULL);
}
if (connectCallback) { if (connectCallback) {
forwards->ReleaseForward(connectCallback); forwards->ReleaseForward(connectCallback);
} }

View File

@ -73,16 +73,6 @@ void AsyncSocket::OnHandleDestroy(HandleType_t type, void *object) {
if(object != NULL) { if(object != NULL) {
AsyncSocketContext *ctx = (AsyncSocketContext *) object; AsyncSocketContext *ctx = (AsyncSocketContext *) object;
if (ctx->connect_req != NULL) {
uv_close((uv_handle_t *) ctx->connect_req->handle, NULL);
free(ctx->connect_req);
}
if (ctx->socket != NULL) {
uv_close((uv_handle_t *) ctx->socket, NULL);
free(ctx->socket);
}
delete ctx; delete ctx;
} }
} }
@ -134,11 +124,8 @@ void alloc_buffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
void on_read(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { void on_read(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) {
if (nread < 0) { if (nread < 0) {
if (nread != UV_EOF) {
push_error((AsyncSocketContext*) client->data, nread); push_error((AsyncSocketContext*) client->data, nread);
} // Should we decide to close the socket? For now let's let the plugin handle errors, including EOF.
//uv_close((uv_handle_t*) client, NULL);
//free(client);
return; return;
} }