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

Commit

Permalink
connection_ssl_new log errors to stderr
Browse files Browse the repository at this point in the history
- added error logs for evhtp_connection_ssl_new when any
  context allocation errors occur. (M<3D)
  • Loading branch information
NathanFrench committed Nov 2, 2017
1 parent 369fe77 commit a1f6926
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions evhtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5318,7 +5318,7 @@ evhtp_connection_ssl_new(struct event_base * evbase,
{
evhtp_connection_t * conn;
struct sockaddr_in sin;
int8_t err;
const char * errstr;

if (evbase == NULL)
{
Expand All @@ -5330,20 +5330,24 @@ evhtp_connection_ssl_new(struct event_base * evbase,
}

conn->evbase = evbase;
err = -1;
errstr = NULL;

do {
if ((conn->ssl = SSL_new(ctx)) == NULL) {
errstr = "unable to allocate SSL context";

break;
}

if ((conn->bev = ssl_sk_new_(evbase, -1, conn->ssl,
BUFFEREVENT_SSL_CONNECTING,
BEV_OPT_CLOSE_ON_FREE)) == NULL) {
errstr = "unable to allocate bev context";
break;
}

if (bufferevent_enable(conn->bev, EV_READ) == -1) {
errstr = "unable to enable reading";
break;
}

Expand All @@ -5359,14 +5363,15 @@ evhtp_connection_ssl_new(struct event_base * evbase,
if (ssl_sk_connect_(conn->bev,
(struct sockaddr *)&sin,
sizeof(sin)) == -1) {
errstr = "sk_connect_ failure";
break;
}

err = 0;
} while (0);


if (err == -1) {
if (errstr != NULL) {
log_error("%s", errstr);

evhtp_safe_free(conn, evhtp_connection_free);

return NULL;
Expand Down

0 comments on commit a1f6926

Please sign in to comment.