Skip to content

Commit

Permalink
Add option to use REUSEADDR on miniserver socket
Browse files Browse the repository at this point in the history
This adds a compile time option "--enable-reuseaddr" which enables the
previously unavailable SO_REUSEADDR codepath in miniserver.c

This allows us the normal advantages of REUSEADDR when implementing
servers that would like graceful restarts.

See gerbera/gerbera#34
  • Loading branch information
whyman authored and ffontaine committed Mar 8, 2017
1 parent 120c533 commit 629dec7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ if test "x$enable_postwrite" = xyes ; then
AC_DEFINE(UPNP_ENABLE_POST_WRITE, 1, [see upnpconfig.h])
fi

RT_BOOL_ARG_ENABLE([reuseaddr], [no], [bind the miniserver socket with reuseaddr to allow clean restarts])
if test "x$enable_reuseaddr" = xyes ; then
AC_DEFINE(UPNP_MINISERVER_REUSEADDR, 1, [see upnpconfig.h])
fi

RT_BOOL_ARG_ENABLE([samples], [yes], [compilation of upnp/sample/ code])


Expand Down
5 changes: 5 additions & 0 deletions upnp/src/genlib/miniserver/miniserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,12 @@ static int get_miniserver_sockets(
uint16_t actual_port6 = 0u;
#endif
int ret_code;
#ifdef UPNP_MINISERVER_REUSEADDR
int reuseaddr_on = 1;
#else
int reuseaddr_on = 0;
#endif

int sockError = UPNP_E_SUCCESS;
int errCode = 0;

Expand Down

0 comments on commit 629dec7

Please sign in to comment.