WIP: Don't exit on SSL error

This commit is contained in:
Henry Case 2019-07-28 20:46:04 +01:00
parent a6601c1e97
commit 694bebfc54

View File

@ -1048,7 +1048,7 @@ core_init(void)
#ifdef HAVE_SSL #ifdef HAVE_SSL
void int
core_ssl_connect(Conn * s) core_ssl_connect(Conn * s)
{ {
Any_Type arg; Any_Type arg;
@ -1083,13 +1083,13 @@ core_ssl_connect(Conn * s)
clear_active(s, READ); clear_active(s, READ);
set_active(s, WRITE); set_active(s, WRITE);
} }
return; return 0;
} }
fprintf(stderr, fprintf(stderr,
"%s: failed to connect to SSL server (err=%d, reason=%d)\n", "%s: failed to connect to SSL server (err=%d, reason=%d)\n",
prog_name, ssl_err, reason); prog_name, ssl_err, reason);
ERR_print_errors_fp(stderr); ERR_print_errors_fp(stderr);
exit(-1); return -1;
} }
s->state = S_CONNECTED; s->state = S_CONNECTED;
@ -1114,6 +1114,7 @@ core_ssl_connect(Conn * s)
arg.l = 0; arg.l = 0;
event_signal(EV_CONN_CONNECTED, (Object *) s, arg); event_signal(EV_CONN_CONNECTED, (Object *) s, arg);
return 0;
} }
#endif /* HAVE_SSL */ #endif /* HAVE_SSL */
@ -1267,7 +1268,12 @@ core_connect(Conn * s)
if (result == 0) { if (result == 0) {
#ifdef HAVE_SSL #ifdef HAVE_SSL
if (param.use_ssl) if (param.use_ssl)
core_ssl_connect(s); printf("OZAPTF UNKNOWN case\n");
if (core_ssl_connect(s) == -1) {
// OZAPTF:
conn_failure(s, errno);
return -1;
}
else else
#endif #endif
{ {
@ -1472,6 +1478,7 @@ core_close(Conn * conn)
} }
#ifdef HAVE_KEVENT #ifdef HAVE_KEVENT
#error "MUST NOT BE USED"
void void
core_loop(void) core_loop(void)
{ {
@ -1559,7 +1566,11 @@ core_loop(void)
if (conn->state == S_CONNECTING) { if (conn->state == S_CONNECTING) {
#ifdef HAVE_SSL #ifdef HAVE_SSL
if (param.use_ssl) if (param.use_ssl)
core_ssl_connect(conn); if (core_ssl_connect(conn) == -1) {
event_signal(EV_CONN_TIMEOUT, (Object*)conn, arg);
conn_dec_ref(conn);
continue;
}
else else
#endif #endif
if (ep->events & EPOLLOUT) { if (ep->events & EPOLLOUT) {
@ -1580,6 +1591,9 @@ core_loop(void)
close(epoll_fd); close(epoll_fd);
} }
#else #else
#error "MUST NOT BE USED"
void void
core_loop(void) core_loop(void)
{ {
@ -1646,8 +1660,11 @@ core_loop(void)
} }
if (conn->state == S_CONNECTING) { if (conn->state == S_CONNECTING) {
#ifdef HAVE_SSL #ifdef HAVE_SSL
if (param.use_ssl) if (param.use_ssl) {
core_ssl_connect(conn); core_ssl_connect(conn);
assert(false); /// OZAPTF: ensure this is not used
}
else else
#endif #endif
if (is_writable) { if (is_writable) {