On 04/07/2010 12:04 PM, Robert Collins wrote:
I'd start by posting a patch to the Debian BTS; if the maintainer
doesn't respond, then an NMU can be done (and I can do that).

Thanks.  Here is the patch, maintainer is CCed.

Paolo
Fix FTBFS on architectures missing accept4/SOCK_CLOEXEC (and likely others).

2010-03-25  Paolo Bonzini  <[email protected]>

        * libgst/sockets.c: Fix logic for no SOCK_CLOEXEC or no accept4.
        * packages/sockets/AbstractSocketImpl.st: Do not check errno unless
        a system call fails.

diff --git a/libgst/sockets.c b/libgst/sockets.c
index 3e155d6..f8e8a63 100644
--- a/libgst/sockets.c
+++ b/libgst/sockets.c
@@ -236,12 +236,14 @@ constantFunction (aiV4mapped, AI_V4MAPPED)
 /* 0 = unknown, 1 = yes, -1 = no.  */
 static mst_Boolean have_sock_cloexec;
 
+/* Return 0 if the operation failed and an error can be returned
+   by the caller.  */
 static inline int
 check_have_sock_cloexec (int fh, int expected_errno)
 {
   if (have_sock_cloexec == 0 && (fh >= 0 || errno == expected_errno))
     have_sock_cloexec = (fh >= 0 ? 1 : -1);
-  return (have_sock_cloexec == 1);
+  return (have_sock_cloexec != 0);
 }
 #endif
 
diff --git a/packages/sockets/AbstractSocketImpl.st 
b/packages/sockets/AbstractSocketImpl.st
index 961b5a7..a71410e 100644
--- a/packages/sockets/AbstractSocketImpl.st
+++ b/packages/sockets/AbstractSocketImpl.st
@@ -75,7 +75,7 @@ this can be changed by class methods on SocketAddress 
sublcasses.'>
                    create: addressClass protocolFamily
                    type: self socketType
                    protocol: self protocol.
-       File checkError.
+       descriptor < 0 ifTrue: [ File checkError ].
        ^self on: descriptor
     ]
 
@@ -93,6 +93,7 @@ this can be changed by class methods on SocketAddress 
sublcasses.'>
                    accept: fd
                    peer: peer
                    addrLen: addrLen.
+        newFD < 0 ifTrue: [ File checkError: self soError ].
        ^(implementationClass on: newFD)
            hasBeenBound;
            hasBeenConnectedTo: peer;
@@ -108,11 +109,10 @@ this can be changed by class methods on SocketAddress 
sublcasses.'>
        addr := ipAddress port: port.
        
        (fd := self fd) isNil ifTrue: [ ^self ].
-       [self 
+       [(self 
            bind: fd
            to: addr
-           addrLen: addr size.
-       File checkError] 
+           addrLen: addr size) < 0 ifTrue: [File checkError: self soError] ]
                ifCurtailed: [self close].
        self isOpen ifTrue: [self hasBeenBound]
     ]
@@ -527,11 +527,10 @@ implementations.'>
        addr := ipAddress port: port.
        
        [(fd := self fd) isNil ifTrue: [ ^self ].
-       self 
+       (self 
            connect: fd
            to: addr
-           addrLen: addr size.
-       File checkError] 
+           addrLen: addr size) < 0 ifTrue: [File checkError: self soError] ]
                ifCurtailed: [self close].
 
        "connect does not block, so wait for"
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to