aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/test_upgrade.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/test_upgrade.c')
-rw-r--r--src/microhttpd/test_upgrade.c40
1 files changed, 7 insertions, 33 deletions
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 */
405static 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 */
431static int wr_close(wr_socket s) 403static int
404wr_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 */