ecore_con: bug workaround SO_REUSEADDR and EADDRINUSE from bind (fix)
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Wed, 20 Dec 2017 12:10:53 +0000 (21:10 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Wed, 10 Jan 2018 11:08:13 +0000 (20:08 +0900)
commiteab194a34fb3ba38228c9fc65a98b58bb39cf32a
tree0ec4bcd2356be2e440207a6dbf85ced3fd3a235f
parenta6ff0a85abd5deb7a40cb748ab259a8d9c087b53
ecore_con: bug workaround SO_REUSEADDR and EADDRINUSE from bind (fix)

what i'm seeing is this with local unix sockets:

1. server process not cleanly shut down (kill -9 for example).
2. run server process again and bind fails due to EADDRINUSE
3. we ARE doing setsockopt() with SO_REUSEADDR set to 1 ...

this just makes no sense because setsockopt() SHOULD allow use to
re-use... the previous efreetd process for example is gone. no such
process, yet socket is not re-usable. this should just not happen due
to SO_REUSEADDR, but it does. this has nasty consequences like efreetd
maybe never running because of stale sockets. this should never have
happened, but it does. odd. so a hacky workaround:

1. try bind.
2. if bind fails with EADDRINUSE and its a socket path AND
pd->unlink_before_bind is NOT set... then try a connect to the socket.
3. if connect succeeds then fail as normal (close socket and error on
bind'ing)
   if connect fails then we have a stale socket, so unlink it
forcibly. create the socket again and try bind again.

hacky but... fixes the core issue.

@fix
src/lib/ecore_con/efl_net_server_unix.c