Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
check res for bufferevent_socket_connect (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthomas committed Apr 2, 2016
1 parent 3a80996 commit 70b68d4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion evhtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4352,6 +4352,7 @@ evhtp_connection_t *
evhtp_connection_ssl_new(evbase_t * evbase, const char * addr, uint16_t port, evhtp_ssl_ctx_t * ctx) {
evhtp_connection_t * conn;
struct sockaddr_in sin;
int rc;

evhtp_assert(evbase != NULL);

Expand All @@ -4364,17 +4365,21 @@ evhtp_connection_ssl_new(evbase_t * evbase, const char * addr, uint16_t port, ev
sin.sin_port = htons(port);

conn->ssl = SSL_new(ctx);
evhtp_assert(conn->ssl != NULL);

conn->evbase = evbase;
conn->bev = bufferevent_openssl_socket_new(evbase, -1, conn->ssl,
BUFFEREVENT_SSL_CONNECTING, BEV_OPT_CLOSE_ON_FREE);
evhtp_assert(conn->bev != NULL);

bufferevent_enable(conn->bev, EV_READ);
bufferevent_setcb(conn->bev, NULL, NULL,
_evhtp_connection_eventcb, conn);

bufferevent_socket_connect(conn->bev,
rc = bufferevent_socket_connect(conn->bev,
(struct sockaddr *)&sin, sizeof(sin));

evhtp_assert(rc == 0);

return conn;
}
Expand Down

0 comments on commit 70b68d4

Please sign in to comment.