[Chilli] [3/6] Fix bug: Headers providing a flag don't imply this is

Jan-Benedict Glaw jbglaw at getslash.de
Tue Mar 18 14:59:05 UTC 2014


One of the socket flags is checked for existence, but that doesn't
neccessarily mean that it's supported on the target system. Accept
failure here, SO_REUSEPORT isn't really important.

2014-03-06  Jan-Benedict Glaw  <jbglaw at lug-owl.de>

	* src/redir.c (redir_listen): Handle failure upon SO_REUSEPORT.
---
 src/redir.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/redir.c b/src/redir.c
index 7c194fd..9d6d63e 100644
--- a/src/redir.c
+++ b/src/redir.c
@@ -1705,10 +1705,17 @@ int redir_listen(struct redir_t *redir) {
 #ifdef SO_REUSEPORT
     optval = 1;
     if (setsockopt(redir->fd[n], SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval))) {
-      log_err(errno, "setsockopt(SO_REUSEPORT)");
-      safe_close(redir->fd[n]);
-      redir->fd[n]=0;
-      return -1;
+      error_t last_errno = errno;
+      log_err(last_errno, "setsockopt(SO_REUSEPORT)");
+      if (last_errno != ENOPROTOOPT) {
+	log_dbg ("setsockopt(SO_REUSEPORT) failed hard, aborting.");
+	safe_close(redir->fd[n]);
+	redir->fd[n]=0;
+	return -1;
+      } else {
+	log_dbg ("setsockopt(SO_REUSEPORT) failed due to proto not available "
+		 "(probably compiled with newer header files), continueing anyways...");
+      }
     }
 #endif
     
-- 
1.8.3.2

-- 
Getslash GmbH, Bahnhofstraße 16, 59302 Oelde
Tel: +49-2522-834349-5    Fax:   +49-2522-834349-1
http://www.getslash.de    Mobil: +49-152-33822499
Sitz der Gesellschaft: Oelde
Handelsregister: Amtsgericht Münster, HRB 11911
Ust-Id-Nr.: DE 815060326
Geschäftsführung: Andre Peitz, Tobias Hanisch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.coova.org/pipermail/chilli/attachments/20140318/ed06500e/attachment.pgp>


More information about the Chilli mailing list