Skip to content

Commit

Permalink
Cleanup connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen van der Heijden committed Sep 11, 2017
1 parent 45e1d76 commit 31cb283
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
libsuv (0.1.1)

* Cleanup connection when connect has failed.

-- Jeroen van der Heijden <jeroen@transceptor.technology> 11 Sep 2017

libsuv (0.1.0)

* Initial version.
Expand Down
6 changes: 4 additions & 2 deletions suv.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void suv_close(suv_buf_t * buf, const char * msg)
{
buf->onclose(buf->data, (msg == NULL) ? "connection closed" : msg);
}
uv_close((uv_handle_t *) tcp_, suv__close_tcp);
suv__close_tcp((uv_handle_t *) tcp_);
}
}

Expand Down Expand Up @@ -248,7 +248,7 @@ static void suv__close_tcp(uv_handle_t * tcp)
suv_buf_t * buf = (suv_buf_t *) tcp->data;
buf->siridb->data = NULL;
}
free(tcp);
uv_close(tcp, (uv_close_cb) free);
}

/*
Expand Down Expand Up @@ -318,13 +318,15 @@ static void suv__connect_cb(uv_connect_t * uvreq, int status)
{
/* error handling */
suv_write_error((suv_write_t *) connect, -status);
suv__close_tcp((uv_handle_t *) connect->_req->siridb->data);
}
else
{
uv_write_t * uvw = (uv_write_t *) malloc(sizeof(uv_write_t));
if (uvw == NULL)
{
suv_write_error((suv_write_t *) connect, ERR_MEM_ALLOC);
suv__close_tcp((uv_handle_t *) connect->_req->siridb->data);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion suv.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#define SUV_VERSION_MAJOR 0
#define SUV_VERSION_MINOR 1
#define SUV_VERSION_PATCH 0
#define SUV_VERSION_PATCH 1

#define SUV_STRINGIFY(num) #num
#define SUV_VERSION_STR(major,minor,patch) \
Expand Down

0 comments on commit 31cb283

Please sign in to comment.