mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
I attach the first attempt on SO_REUSEPORT. The patch is available either at https://github.com/foxik/libmicrohttpd/commit/9ce9422742e10458f87275ea202a982e00c2b88c or attached. (It is against the version with MHD_DAEMON_OPTION_CURRENT_CONNECTIONS, but I can rebase it to current SVN HEAD if you want.) It seems that a reasonably multiplatform way of detecting SO_REUSEPORT is #ifdef SO_REPOSEPORT which is used for example by Perl. For SO_EXCLUSIVEADDRUSE, the same strategy seems to work too, according to Windows SDK headers and MinGW WinAPI headers. The current patch adds an option to allowing/disallowing address:port reuse. One remark: - currently both nonexisting SO_xxx and setsockopt failure are fatal and MHD_start_daemon fails. That may be too harsh -- maybe the MHD_OPTION_LISTENING_ADDRESS_REUSE should be only a hint. Nevertheless, as one can freely not use MHD_OPTION_LISTENING_ADDRESS_REUSE option, I chose the "fail on error" behaviour. Thanks, cheers, Milan Straka Original patch modified to get rid of some redundant USE_DEBUG checks, fix indentation, and #ifndef SO_REUSEPORT on Linux, we try be #defining it to 15 ourselves.