diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-02-14 16:59:10 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-02-14 16:59:10 +0100 |
commit | 73e423312cc7a32f5a260ec7992ed5a15abd4858 (patch) | |
tree | 257d8f1b8e0d8ae95bd81a0ee7cc6961de4601ba | |
parent | f1512b46b27808b0f1987a93671757e7b553eb42 (diff) | |
download | libmicrohttpd-73e423312cc7a32f5a260ec7992ed5a15abd4858.tar.gz libmicrohttpd-73e423312cc7a32f5a260ec7992ed5a15abd4858.zip |
add extra check, make it work with OpenSSL 1.1, eliminate dead code, some formatting
-rw-r--r-- | src/microhttpd/response.c | 1 | ||||
-rw-r--r-- | src/microhttpd/test_upgrade.c | 40 |
2 files changed, 8 insertions, 33 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index 86e3f325..4ea251d3 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -668,6 +668,7 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh, | |||
668 | 668 | ||
669 | /* transition to special 'closed' state for start of cleanup */ | 669 | /* transition to special 'closed' state for start of cleanup */ |
670 | urh->was_closed = true; | 670 | urh->was_closed = true; |
671 | EXTRA_CHECK (MHD_CONNECTION_UPGRADE == connection->state); | ||
671 | connection->state = MHD_CONNECTION_UPGRADE_CLOSED; | 672 | connection->state = MHD_CONNECTION_UPGRADE_CLOSED; |
672 | /* As soon as connection will be marked with BOTH | 673 | /* As soon as connection will be marked with BOTH |
673 | * 'urh->was_closed' AND 'urh->clean_ready', it will | 674 | * 'urh->was_closed' AND 'urh->clean_ready', it will |
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c index 695a5e73..01e963f1 100644 --- a/src/microhttpd/test_upgrade.c +++ b/src/microhttpd/test_upgrade.c | |||
@@ -132,7 +132,7 @@ gnutlscli_connect (int *sock, | |||
132 | "-connect", | 132 | "-connect", |
133 | destination, | 133 | destination, |
134 | "-verify", | 134 | "-verify", |
135 | "0", | 135 | "1", |
136 | (char *) NULL); | 136 | (char *) NULL); |
137 | } | 137 | } |
138 | _exit (1); | 138 | _exit (1); |
@@ -396,39 +396,12 @@ static ssize_t wr_recv(wr_socket s, void *buf, size_t len) | |||
396 | 396 | ||
397 | 397 | ||
398 | /** | 398 | /** |
399 | * Perform shutdown of TCP socket for plain sockets or | ||
400 | * shutdown of TLS layer for TLS sockets. | ||
401 | * @param s the socket to shutdown | ||
402 | * @param how SHUT_WR or SHUT_RDWR | ||
403 | * @return zero on succeed, -1 otherwise | ||
404 | */ | ||
405 | static int wr_shutdown(wr_socket s, int how) | ||
406 | { | ||
407 | if (wr_plain == s->t) | ||
408 | return shutdown (s->fd, how); | ||
409 | #ifdef HTTPS_SUPPORT | ||
410 | if (wr_tls == s->t) | ||
411 | { | ||
412 | ssize_t ret; | ||
413 | if (SHUT_WR == how) | ||
414 | ret = gnutls_bye (s->tls_s, GNUTLS_SHUT_WR); | ||
415 | else | ||
416 | ret = gnutls_bye (s->tls_s, GNUTLS_SHUT_RDWR); | ||
417 | |||
418 | if (GNUTLS_E_SUCCESS == ret) | ||
419 | return 0; | ||
420 | } | ||
421 | #endif /* HTTPS_SUPPORT */ | ||
422 | return -1; | ||
423 | } | ||
424 | |||
425 | |||
426 | /** | ||
427 | * Close socket and release allocated resourced | 399 | * Close socket and release allocated resourced |
428 | * @param s the socket to close | 400 | * @param s the socket to close |
429 | * @return zero on succeed, -1 otherwise | 401 | * @return zero on succeed, -1 otherwise |
430 | */ | 402 | */ |
431 | static int wr_close(wr_socket s) | 403 | static int |
404 | wr_close(wr_socket s) | ||
432 | { | 405 | { |
433 | int ret = (MHD_socket_close_(s->fd)) ? 0 : -1; | 406 | int ret = (MHD_socket_close_(s->fd)) ? 0 : -1; |
434 | #ifdef HTTPS_SUPPORT | 407 | #ifdef HTTPS_SUPPORT |
@@ -1130,12 +1103,13 @@ main (int argc, | |||
1130 | abort (); | 1103 | abort (); |
1131 | } | 1104 | } |
1132 | } | 1105 | } |
1133 | if (TLS_LIB_GNUTLS == use_tls_tool && GNUTLS_E_SUCCESS != gnutls_global_init()) | 1106 | if ( (TLS_LIB_GNUTLS == use_tls_tool) && |
1107 | (GNUTLS_E_SUCCESS != gnutls_global_init()) ) | ||
1134 | abort (); | 1108 | abort (); |
1135 | 1109 | ||
1136 | #else /* ! HTTPS_SUPPORT */ | 1110 | #else /* ! HTTPS_SUPPORT */ |
1137 | fprintf (stderr, "HTTPS support was disabled by configure.\n"); | 1111 | fprintf (stderr, "HTTPS support was disabled by configure.\n"); |
1138 | return 99; | 1112 | return 77; |
1139 | #endif /* ! HTTPS_SUPPORT */ | 1113 | #endif /* ! HTTPS_SUPPORT */ |
1140 | } | 1114 | } |
1141 | 1115 | ||
@@ -1260,7 +1234,7 @@ main (int argc, | |||
1260 | "Error (code: %u)\n", | 1234 | "Error (code: %u)\n", |
1261 | error_count); | 1235 | error_count); |
1262 | #ifdef HTTPS_SUPPORT | 1236 | #ifdef HTTPS_SUPPORT |
1263 | if (test_tls && TLS_LIB_GNUTLS == use_tls_tool) | 1237 | if (test_tls && (TLS_LIB_GNUTLS == use_tls_tool)) |
1264 | gnutls_global_deinit(); | 1238 | gnutls_global_deinit(); |
1265 | #endif /* HTTPS_SUPPORT */ | 1239 | #endif /* HTTPS_SUPPORT */ |
1266 | return error_count != 0; /* 0 == pass */ | 1240 | return error_count != 0; /* 0 == pass */ |