Author: rfm Date: Sat Jun 25 17:57:06 2016 New Revision: 39919 URL: http://svn.gna.org/viewcvs/gnustep?rev=39919&view=rev Log: socket fixes
Modified: libs/base/trunk/ChangeLog libs/base/trunk/Source/NSMessagePort.m libs/base/trunk/config/config.reuseaddr.c Modified: libs/base/trunk/ChangeLog URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39919&r1=39918&r2=39919&view=diff ============================================================================== --- libs/base/trunk/ChangeLog (original) +++ libs/base/trunk/ChangeLog Sat Jun 25 17:57:06 2016 @@ -1,3 +1,9 @@ +2016-06-25 Richard Frith-Macdonald <r...@gnu.org> + + * Source/NSMessagePort.m: + * config/config.reuseaddr.c: + SO_REUSEADDR fixes. + 2016-06-25 Richard Frith-Macdonald <r...@gnu.org> * Documentation/Base.gsdoc: Modified: libs/base/trunk/Source/NSMessagePort.m URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSMessagePort.m?rev=39919&r1=39918&r2=39919&view=diff ============================================================================== --- libs/base/trunk/Source/NSMessagePort.m (original) +++ libs/base/trunk/Source/NSMessagePort.m Sat Jun 25 17:57:06 2016 @@ -1503,9 +1503,6 @@ NSMapEnumerator me; int sock; void *dummy; -#ifndef BROKEN_SO_REUSEADDR - int opt = 1; -#endif GSMessageHandle *handle = nil; M_LOCK(myLock); @@ -1533,20 +1530,6 @@ { NSLog(@"unable to create socket - %@", [NSError _last]); } -#ifndef BROKEN_SO_REUSEADDR - /* - * Under decent systems, SO_REUSEADDR means that the port can be reused - * immediately that this process exits. Under some it means - * that multiple processes can serve the same port simultaneously. - * We don't want that broken behavior! - */ - else if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&opt, - sizeof(opt)) < 0) - { - (void)close(sock); - NSLog(@"unable to set reuse on socket - %@", [NSError _last]); - } -#endif else if ((handle = [GSMessageHandle handleWithDescriptor: sock]) == nil) { (void)close(sock); Modified: libs/base/trunk/config/config.reuseaddr.c URL: http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/config/config.reuseaddr.c?rev=39919&r1=39918&r2=39919&view=diff ============================================================================== --- libs/base/trunk/config/config.reuseaddr.c (original) +++ libs/base/trunk/config/config.reuseaddr.c Sat Jun 25 17:57:06 2016 @@ -44,13 +44,19 @@ sin.sin_addr.s_addr = htonl(INADDR_ANY); sin.sin_port = 0; - if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) + if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { fprintf(stderr, "unable to create socket 1\n"); return 2; } - setsockopt(net, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status)); + if (setsockopt(net, SOL_SOCKET, SO_REUSEADDR, + (char *)&status, sizeof(status)) < 0) + { + fprintf(stderr, "unable to set socket 1 option\n"); + (void) close(net); + return 1; + } if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0) { @@ -80,7 +86,13 @@ return 2; } - setsockopt(net, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status)); + if (setsockopt(net, SOL_SOCKET, SO_REUSEADDR, + (char *)&status, sizeof(status)) < 0) + { + fprintf(stderr, "unable to set socket 2 option\n"); + (void) close(net); + return 1; + } /* * Now ... this bind should fail unless SO_REUSEADDR is broken. _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs