|
1 |
| -$NetBSD: patch-stud.c,v 1.1 2013/03/16 19:41:36 jym Exp $ |
| 1 | +$NetBSD: patch-stud.c,v 1.2 2015/02/20 09:32:07 fhajny Exp $ |
2 | 2 |
|
3 | 3 | SunOS fixes as per https://github.com/bumptech/stud/pull/71.
|
4 |
| ---- stud.c.orig 2012-08-15 10:33:39.000000000 +0000 |
| 4 | +SSL fixes as per https://github.com/bumptech/stud/pull/130. |
| 5 | + |
| 6 | +--- stud.c.orig 2012-08-10 23:40:19.000000000 +0000 |
5 | 7 | +++ stud.c
|
6 | 8 | @@ -189,9 +189,17 @@ typedef struct proxystate {
|
7 | 9 |
|
@@ -35,7 +37,38 @@ SunOS fixes as per https://github.com/bumptech/stud/pull/71.
|
35 | 37 | if(setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &optval, optlen) < 0) {
|
36 | 38 | ERR("Error setting TCP_KEEPIDLE on client socket: %s", strerror(errno));
|
37 | 39 | }
|
38 |
| -@@ -1751,24 +1759,16 @@ void daemonize () { |
| 40 | +@@ -889,6 +897,13 @@ static void shutdown_proxy(proxystate *p |
| 41 | + close(ps->fd_up); |
| 42 | + close(ps->fd_down); |
| 43 | + |
| 44 | ++ // Clear the SSL error queue - it might contain details |
| 45 | ++ // of errors that we haven't consumed for whatever reason. |
| 46 | ++ // If we don't, future calls to SSL_get_error will lead to |
| 47 | ++ // weird/confusing results that can throw off the handling |
| 48 | ++ // of normal conditions like SSL_ERROR_WANT_READ. |
| 49 | ++ ERR_clear_error(); |
| 50 | ++ |
| 51 | + SSL_set_shutdown(ps->ssl, SSL_SENT_SHUTDOWN); |
| 52 | + SSL_free(ps->ssl); |
| 53 | + |
| 54 | +@@ -1197,7 +1212,15 @@ static void client_handshake(struct ev_l |
| 55 | + shutdown_proxy(ps, SHUTDOWN_SSL); |
| 56 | + } |
| 57 | + else { |
| 58 | +- LOG("{%s} Unexpected SSL error (in handshake): %d\n", w->fd == ps->fd_up ? "client" : "backend", err); |
| 59 | ++ |
| 60 | ++ // Try and get more detail on the error from the SSL |
| 61 | ++ // error queue. ERR_error_string requires a char buffer |
| 62 | ++ // of 120 bytes. |
| 63 | ++ unsigned long err_detail = ERR_get_error(); |
| 64 | ++ char err_msg[120]; |
| 65 | ++ ERR_error_string(err_detail, err_msg); |
| 66 | ++ |
| 67 | ++ LOG("{client} Unexpected SSL error (in handshake): %d, %s\n", err, err_msg); |
| 68 | + shutdown_proxy(ps, SHUTDOWN_SSL); |
| 69 | + } |
| 70 | + } |
| 71 | +@@ -1751,24 +1774,16 @@ void daemonize () { |
39 | 72 | exit(0);
|
40 | 73 | }
|
41 | 74 |
|
|
0 commit comments