summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-05-02 10:44:31 -0400
committerRich Salz <rsalz@openssl.org>2015-06-02 12:22:38 -0400
commit366e2a60b2fcc727b061f1459343245476ad6c3b (patch)
tree2798782de5f2dbcc0dd0177a57adfee873d33333 /apps
parentf20bb4eb18b01979cb23b2ae4a60675c83c4ba91 (diff)
RT832: Use REUSEADDR in ocsp responder
I also re-ordered some of #ifdef's. Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'apps')
-rw-r--r--apps/ocsp.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/apps/ocsp.c b/apps/ocsp.c
index 4c3aa39410..5d3e646f81 100644
--- a/apps/ocsp.c
+++ b/apps/ocsp.c
@@ -1010,22 +1010,27 @@ static BIO *init_responder(const char *port)
{
BIO *acbio = NULL, *bufbio = NULL;
- bufbio = BIO_new(BIO_f_buffer());
- if (!bufbio)
- goto err;
-# ifndef OPENSSL_NO_SOCK
- acbio = BIO_new_accept(port);
-# else
+# ifdef OPENSSL_NO_SOCK
BIO_printf(bio_err,
"Error setting up accept BIO - sockets not supported.\n");
+ return NULL;
# endif
- if (!acbio)
+ bufbio = BIO_new(BIO_f_buffer());
+ if (!bufbio)
goto err;
+ acbio = BIO_new(BIO_s_accept());
+ if (acbio == NULL
+ || BIO_set_bind_mode(acbio, BIO_BIND_REUSEADDR) < 0
+ || BIO_set_accept_port(acbio, port) < 0) {
+ BIO_printf(bio_err, "Error setting up accept BIO\n");
+ ERR_print_errors(bio_err);
+ goto err;
+ }
+
BIO_set_accept_bios(acbio, bufbio);
bufbio = NULL;
-
if (BIO_do_accept(acbio) <= 0) {
- BIO_printf(bio_err, "Error setting up accept BIO\n");
+ BIO_printf(bio_err, "Error starting accept\n");
ERR_print_errors(bio_err);
goto err;
}