diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-03-05 04:13:07 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2017-03-05 04:13:07 +0100 |
commit | 1b5d45cec7233fd82f26ac4bc7f5f44886aabe59 (patch) | |
tree | 3761fe4e849653655eccbafd11159dff5fb37428 | |
parent | 0b8e1a614fae4bdbf529992f04fdaf2cff498d50 (diff) | |
download | blogc-1b5d45cec7233fd82f26ac4bc7f5f44886aabe59.tar.gz blogc-1b5d45cec7233fd82f26ac4bc7f5f44886aabe59.tar.bz2 blogc-1b5d45cec7233fd82f26ac4bc7f5f44886aabe59.zip |
runserver: reuse address
-rw-r--r-- | src/blogc-runserver/httpd.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/blogc-runserver/httpd.c b/src/blogc-runserver/httpd.c index 847f8f9..4afb2b8 100644 --- a/src/blogc-runserver/httpd.c +++ b/src/blogc-runserver/httpd.c @@ -270,6 +270,10 @@ br_httpd_run(const char *host, const char *port, const char *docroot, if (server_socket == -1) { continue; } + int value = 1; + if (0 > setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(int))) { + continue; + } if (0 == bind(server_socket, rp->ai_addr, rp->ai_addrlen)) { f = rp; break; @@ -288,13 +292,6 @@ br_httpd_run(const char *host, const char *port, const char *docroot, int rv = 0; - int value = 1; - if (0 > setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &value, sizeof(int))) { - fprintf(stderr, "Failed to set socket option: %s\n", strerror(errno)); - rv = 3; - goto cleanup; - } - if (-1 == listen(server_socket, LISTEN_BACKLOG)) { fprintf(stderr, "Failed to listen to server socket: %s\n", strerror(errno)); rv = 3; |