lua-handlers icon indicating copy to clipboard operation
lua-handlers copied to clipboard

lua-handlers + udp with nixio+ev on freebsd problem - SO_REUSEPORT

Open terminar opened this issue 9 years ago • 1 comments

I'm testing a bit with the poller branch and udp (i need COAP support). While testing it on FreeBSD i got into trouble with the server mentioning "Adress already in use". This is caused by acceptor/nixio_backend.lua at ~ line 115 where the :bind() is happening.

It took some time until i realized that there isn't only SO_REUSEADDR but also SO_REUSEPORT on FreeBSD - this seems to be needed.

I tried this modifing nixio 0.3/src/sockopt.c adding

            } else if (!strcmp(option, "reuseport")) {
                    return nixio__gso_int(L, sock->fd, SOL_SOCKET, SO_REUSEPORT, set);

and then, also added it to acceptor/nxio_backend.lua next to the 'reuseaddr' calls.

It's working now in my test environment but how should we handle this? This means a patch to lua-handlers and nixio. Should i create a PR for both?

terminar avatar Aug 21 '16 17:08 terminar

Yes. a PR to both. Make sure to use #ifdef/#else/#endif like what is done for SO_PRIORITY

Neopallium avatar Aug 21 '16 17:08 Neopallium