Browse Source

improved ssl write error handling...this hopefully fixes occasionally crashes when using ssl

release0.1.5
Georg Hopp 12 years ago
parent
commit
2429393218
  1. 1
      src/server/close_conn.c
  2. 25
      src/stream/write.c

1
src/server/close_conn.c

@ -39,6 +39,7 @@ serverCloseConn(Server this, unsigned int i)
if (NULL != st && STREAM_SSL == st->type) { if (NULL != st && STREAM_SSL == st->type) {
SSL_shutdown((st->handle).ssl); SSL_shutdown((st->handle).ssl);
SSL_free((st->handle).ssl); SSL_free((st->handle).ssl);
(st->handle).ssl = NULL;
} }
delete(st); delete(st);

25
src/stream/write.c

@ -63,12 +63,34 @@ streamWrite(Stream this, void * buf, size_t count)
break; break;
case STREAM_SSL: case STREAM_SSL:
/*
* @TODO I got a segfault in this call under unclear
* circumstances. Most likely it has to do with a
* write on a closed connection.
*/
done = SSL_write((this->handle).ssl, buf, count); done = SSL_write((this->handle).ssl, buf, count);
if (0 >= done) { if (0 >= done) {
switch (SSL_get_error((this->handle).ssl, done)) { switch (SSL_get_error((this->handle).ssl, done)) {
case SSL_ERROR_SSL:
case SSL_ERROR_SYSCALL: case SSL_ERROR_SYSCALL:
{
switch (errno) {
case EINTR:
case ENOBUFS:
case ENOMEM:
done = 0;
break;
case (EAGAIN|EWOULDBLOCK):
done = -1;
break;
default:
done = -2;
break;
}
}
break;
case SSL_ERROR_SSL:
{ {
unsigned long err; unsigned long err;
@ -82,6 +104,7 @@ streamWrite(Stream this, void * buf, size_t count)
// DROP THROUGH // DROP THROUGH
case SSL_ERROR_ZERO_RETURN: case SSL_ERROR_ZERO_RETURN:
default:
done = -2; done = -2;
break; break;
} }

Loading…
Cancel
Save