ISSUE 43: Add BIO_sock_shutdown
This replaces SHUTDOWN/SHUTDOWN2 with BIO_closesocket. Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
@@ -1735,7 +1735,7 @@ int s_client_main(int argc, char **argv)
|
|||||||
if (init_client(&s, host, port, socket_family, socket_type) == 0)
|
if (init_client(&s, host, port, socket_family, socket_type) == 0)
|
||||||
{
|
{
|
||||||
BIO_printf(bio_err, "connect:errno=%d\n", get_last_socket_error());
|
BIO_printf(bio_err, "connect:errno=%d\n", get_last_socket_error());
|
||||||
SHUTDOWN(s);
|
BIO_closesocket(s);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
BIO_printf(bio_c_out, "CONNECTED(%08X)\n", s);
|
BIO_printf(bio_c_out, "CONNECTED(%08X)\n", s);
|
||||||
@@ -1753,7 +1753,7 @@ int s_client_main(int argc, char **argv)
|
|||||||
if (getsockname(s, &peer, (void *)&peerlen) < 0) {
|
if (getsockname(s, &peer, (void *)&peerlen) < 0) {
|
||||||
BIO_printf(bio_err, "getsockname:errno=%d\n",
|
BIO_printf(bio_err, "getsockname:errno=%d\n",
|
||||||
get_last_socket_error());
|
get_last_socket_error());
|
||||||
SHUTDOWN(s);
|
BIO_closesocket(s);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2135,7 +2135,7 @@ int s_client_main(int argc, char **argv)
|
|||||||
"drop connection and then reconnect\n");
|
"drop connection and then reconnect\n");
|
||||||
do_ssl_shutdown(con);
|
do_ssl_shutdown(con);
|
||||||
SSL_set_connect_state(con);
|
SSL_set_connect_state(con);
|
||||||
SHUTDOWN(SSL_get_fd(con));
|
BIO_closesocket(SSL_get_fd(con));
|
||||||
goto re_start;
|
goto re_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2452,7 +2452,7 @@ int s_client_main(int argc, char **argv)
|
|||||||
if (in_init)
|
if (in_init)
|
||||||
print_stuff(bio_c_out, con, full_log);
|
print_stuff(bio_c_out, con, full_log);
|
||||||
do_ssl_shutdown(con);
|
do_ssl_shutdown(con);
|
||||||
SHUTDOWN(SSL_get_fd(con));
|
BIO_closesocket(SSL_get_fd(con));
|
||||||
end:
|
end:
|
||||||
if (con != NULL) {
|
if (con != NULL) {
|
||||||
if (prexit != 0)
|
if (prexit != 0)
|
||||||
|
|||||||
@@ -2245,7 +2245,7 @@ static int sv_body(int s, int stype, unsigned char *context)
|
|||||||
if ((i <= 0) || (buf[0] == 'Q')) {
|
if ((i <= 0) || (buf[0] == 'Q')) {
|
||||||
BIO_printf(bio_s_out, "DONE\n");
|
BIO_printf(bio_s_out, "DONE\n");
|
||||||
(void)BIO_flush(bio_s_out);
|
(void)BIO_flush(bio_s_out);
|
||||||
SHUTDOWN(s);
|
BIO_closesocket(s);
|
||||||
close_accept_socket();
|
close_accept_socket();
|
||||||
ret = -11;
|
ret = -11;
|
||||||
goto err;
|
goto err;
|
||||||
@@ -2254,7 +2254,7 @@ static int sv_body(int s, int stype, unsigned char *context)
|
|||||||
BIO_printf(bio_s_out, "DONE\n");
|
BIO_printf(bio_s_out, "DONE\n");
|
||||||
(void)BIO_flush(bio_s_out);
|
(void)BIO_flush(bio_s_out);
|
||||||
if (SSL_version(con) != DTLS1_VERSION)
|
if (SSL_version(con) != DTLS1_VERSION)
|
||||||
SHUTDOWN(s);
|
BIO_closesocket(s);
|
||||||
/*
|
/*
|
||||||
* close_accept_socket(); ret= -11;
|
* close_accept_socket(); ret= -11;
|
||||||
*/
|
*/
|
||||||
@@ -2451,7 +2451,7 @@ static void close_accept_socket(void)
|
|||||||
{
|
{
|
||||||
BIO_printf(bio_err, "shutdown accept socket\n");
|
BIO_printf(bio_err, "shutdown accept socket\n");
|
||||||
if (accept_socket >= 0) {
|
if (accept_socket >= 0) {
|
||||||
SHUTDOWN2(accept_socket);
|
BIO_closesocket(accept_socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -266,11 +266,11 @@ int do_server(int *accept_sock, const char *host, const char *port,
|
|||||||
} while (sock < 0 && BIO_sock_should_retry(ret));
|
} while (sock < 0 && BIO_sock_should_retry(ret));
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
ERR_print_errors(bio_err);
|
ERR_print_errors(bio_err);
|
||||||
SHUTDOWN(asock);
|
BIO_closesocket(asock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i = (*cb)(sock, type, context);
|
i = (*cb)(sock, type, context);
|
||||||
SHUTDOWN2(sock);
|
BIO_closesocket(sock);
|
||||||
} else {
|
} else {
|
||||||
i = (*cb)(asock, type, context);
|
i = (*cb)(asock, type, context);
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ int do_server(int *accept_sock, const char *host, const char *port,
|
|||||||
if (naccept != -1)
|
if (naccept != -1)
|
||||||
naccept--;
|
naccept--;
|
||||||
if (i < 0 || naccept == 0) {
|
if (i < 0 || naccept == 0) {
|
||||||
SHUTDOWN2(asock);
|
BIO_closesocket(asock);
|
||||||
ret = i;
|
ret = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ int s_time_main(int argc, char **argv)
|
|||||||
#else
|
#else
|
||||||
SSL_shutdown(scon);
|
SSL_shutdown(scon);
|
||||||
#endif
|
#endif
|
||||||
SHUTDOWN2(SSL_get_fd(scon));
|
BIO_closesocket(SSL_get_fd(scon));
|
||||||
|
|
||||||
nConn += 1;
|
nConn += 1;
|
||||||
if (SSL_session_reused(scon))
|
if (SSL_session_reused(scon))
|
||||||
@@ -349,7 +349,7 @@ int s_time_main(int argc, char **argv)
|
|||||||
#else
|
#else
|
||||||
SSL_shutdown(scon);
|
SSL_shutdown(scon);
|
||||||
#endif
|
#endif
|
||||||
SHUTDOWN2(SSL_get_fd(scon));
|
BIO_closesocket(SSL_get_fd(scon));
|
||||||
|
|
||||||
nConn = 0;
|
nConn = 0;
|
||||||
totalTime = 0.0;
|
totalTime = 0.0;
|
||||||
@@ -380,7 +380,7 @@ int s_time_main(int argc, char **argv)
|
|||||||
#else
|
#else
|
||||||
SSL_shutdown(scon);
|
SSL_shutdown(scon);
|
||||||
#endif
|
#endif
|
||||||
SHUTDOWN2(SSL_get_fd(scon));
|
BIO_closesocket(SSL_get_fd(scon));
|
||||||
|
|
||||||
nConn += 1;
|
nConn += 1;
|
||||||
if (SSL_session_reused(scon))
|
if (SSL_session_reused(scon))
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ static int dgram_clear(BIO *a)
|
|||||||
return (0);
|
return (0);
|
||||||
if (a->shutdown) {
|
if (a->shutdown) {
|
||||||
if (a->init) {
|
if (a->init) {
|
||||||
SHUTDOWN2(a->num);
|
BIO_closesocket(a->num);
|
||||||
}
|
}
|
||||||
a->init = 0;
|
a->init = 0;
|
||||||
a->flags = 0;
|
a->flags = 0;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ static int sock_free(BIO *a)
|
|||||||
return (0);
|
return (0);
|
||||||
if (a->shutdown) {
|
if (a->shutdown) {
|
||||||
if (a->init) {
|
if (a->init) {
|
||||||
SHUTDOWN2(a->num);
|
BIO_closesocket(a->num);
|
||||||
}
|
}
|
||||||
a->init = 0;
|
a->init = 0;
|
||||||
a->flags = 0;
|
a->flags = 0;
|
||||||
|
|||||||
10
e_os.h
10
e_os.h
@@ -466,8 +466,6 @@ extern int kbhit(void);
|
|||||||
# ifdef OPENSSL_NO_SOCK
|
# ifdef OPENSSL_NO_SOCK
|
||||||
# define OpenSSL_Write(a,b,c) (-1)
|
# define OpenSSL_Write(a,b,c) (-1)
|
||||||
# define OpenSSL_Read(a,b,c) (-1)
|
# define OpenSSL_Read(a,b,c) (-1)
|
||||||
# define SHUTDOWN(fd) close(fd)
|
|
||||||
# define SHUTDOWN2(fd) close(fd)
|
|
||||||
# elif !defined(__DJGPP__)
|
# elif !defined(__DJGPP__)
|
||||||
# if defined(_WIN32_WCE) && _WIN32_WCE<410
|
# if defined(_WIN32_WCE) && _WIN32_WCE<410
|
||||||
# define getservbyname _masked_declaration_getservbyname
|
# define getservbyname _masked_declaration_getservbyname
|
||||||
@@ -495,13 +493,9 @@ struct servent *PASCAL getservbyname(const char *, const char *);
|
|||||||
# endif
|
# endif
|
||||||
# define OpenSSL_Write(a,b,c) send((a),(b),(c),0)
|
# define OpenSSL_Write(a,b,c) send((a),(b),(c),0)
|
||||||
# define OpenSSL_Read(a,b,c) recv((a),(b),(c),0)
|
# define OpenSSL_Read(a,b,c) recv((a),(b),(c),0)
|
||||||
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
|
|
||||||
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
|
|
||||||
# else
|
# else
|
||||||
# define OpenSSL_Write(a,b,c) write_s(a,b,c,0)
|
# define OpenSSL_Write(a,b,c) write_s(a,b,c,0)
|
||||||
# define OpenSSL_Read(a,b,c) read_s(a,b,c)
|
# define OpenSSL_Read(a,b,c) read_s(a,b,c)
|
||||||
# define SHUTDOWN(fd) close_s(fd)
|
|
||||||
# define SHUTDOWN2(fd) close_s(fd)
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# elif defined(OPENSSL_SYS_NETWARE)
|
# elif defined(OPENSSL_SYS_NETWARE)
|
||||||
@@ -525,8 +519,6 @@ struct servent *PASCAL getservbyname(const char *, const char *);
|
|||||||
# endif
|
# endif
|
||||||
# define OpenSSL_Write(a,b,c) send((a),(b),(c),0)
|
# define OpenSSL_Write(a,b,c) send((a),(b),(c),0)
|
||||||
# define OpenSSL_Read(a,b,c) recv((a),(b),(c),0)
|
# define OpenSSL_Read(a,b,c) recv((a),(b),(c),0)
|
||||||
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
|
|
||||||
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
|
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
@@ -588,8 +580,6 @@ struct servent *PASCAL getservbyname(const char *, const char *);
|
|||||||
|
|
||||||
# define OpenSSL_Read(a,b,c) read((a),(b),(c))
|
# define OpenSSL_Read(a,b,c) read((a),(b),(c))
|
||||||
# define OpenSSL_Write(a,b,c) write((a),(b),(c))
|
# define OpenSSL_Write(a,b,c) write((a),(b),(c))
|
||||||
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
|
|
||||||
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
|
|
||||||
# ifndef INVALID_SOCKET
|
# ifndef INVALID_SOCKET
|
||||||
# define INVALID_SOCKET (-1)
|
# define INVALID_SOCKET (-1)
|
||||||
# endif /* INVALID_SOCKET */
|
# endif /* INVALID_SOCKET */
|
||||||
|
|||||||
Reference in New Issue
Block a user