Browse Source

Fixed SSL_shutdown error handling problems which became visible after [2136].

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2139 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.20
Stefan Bühler 14 years ago
parent
commit
6363a0908f
  1. 39
      src/connections.c

39
src/connections.c

@ -1669,7 +1669,8 @@ int connection_state_machine(server *srv, connection *con) {
}
#ifdef USE_OPENSSL
if (srv_sock->is_ssl) {
int ret;
int ret, ssl_r;
unsigned long err;
ERR_clear_error();
switch ((ret = SSL_shutdown(con->ssl))) {
case 1:
@ -1677,16 +1678,42 @@ int connection_state_machine(server *srv, connection *con) {
break;
case 0:
ERR_clear_error();
if ((ret = SSL_shutdown(con->ssl)) == 1) break;
if (-1 != (ret = SSL_shutdown(con->ssl))) break;
// fall through
default:
log_error_write(srv, __FILE__, __LINE__, "sds", "SSL:",
SSL_get_error(con->ssl, ret),
ERR_error_string(ERR_get_error(), NULL));
return -1;
switch ((ssl_r = SSL_get_error(con->ssl, ret))) {
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_READ:
break;
case SSL_ERROR_SYSCALL:
/* perhaps we have error waiting in our error-queue */
if (0 != (err = ERR_get_error())) {
do {
log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:",
ssl_r, ret,
ERR_error_string(err, NULL));
} while((err = ERR_get_error()));
} else {
log_error_write(srv, __FILE__, __LINE__, "sddds", "SSL (error):",
ssl_r, r, errno,
strerror(errno));
}
break;
default:
while((err = ERR_get_error())) {
log_error_write(srv, __FILE__, __LINE__, "sdds", "SSL:",
ssl_r, ret,
ERR_error_string(err, NULL));
}
break;
}
}
}
ERR_clear_error();
#endif
switch(con->mode) {

Loading…
Cancel
Save