Author: rfm
Date: Mon Jun 13 17:14:21 2016
New Revision: 39861

URL: http://svn.gna.org/viewcvs/gnustep?rev=39861&view=rev
Log:
when a connect fails, we still want the stream scheduled to generate events

Modified:
    libs/base/trunk/Source/GSSocketStream.m

Modified: libs/base/trunk/Source/GSSocketStream.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/GSSocketStream.m?rev=39861&r1=39860&r2=39861&view=diff
==============================================================================
--- libs/base/trunk/Source/GSSocketStream.m     (original)
+++ libs/base/trunk/Source/GSSocketStream.m     Mon Jun 13 17:14:21 2016
@@ -1752,27 +1752,33 @@
             }
         }
 
-      if (_handler == nil)
+      if (nil == _handler)
         {
           [GSTLSHandler tryInput: self output: _sibling];
         }
+
       result = connect([self _sock], &_address.s,
         GSPrivateSockaddrLength(&_address.s));
       if (socketError(result))
         {
-          if (!socketWouldBlock())
+          if (socketWouldBlock())
             {
-              [self _recordError];
+              /* Need to set the status first, so that the run loop can tell
+               * it needs to add the stream as waiting on writable, as an
+               * indication of opened
+               */
+              [self _setStatus: NSStreamStatusOpening];
+            }
+          else
+            {
+              /* Had an immediate connect error, so record it and remove
+               * any handlers because we want higher level code to be
+               * told about it.
+               */
               [self _setHandler: nil];
               [_sibling _setHandler: nil];
-              return;
+              [self _recordError];
             }
-          /*
-           * Need to set the status first, so that the run loop can tell
-           * it needs to add the stream as waiting on writable, as an
-           * indication of opened
-           */
-          [self _setStatus: NSStreamStatusOpening];
 #if    defined(_WIN32)
           WSAEventSelect(_sock, _loopID, FD_ALL_EVENTS);
 #endif
@@ -2228,7 +2234,7 @@
             }
         }
 
-      if (_handler == nil)
+      if (nil == _handler)
         {
           [GSTLSHandler tryInput: _sibling output: self];
         }
@@ -2237,19 +2243,25 @@
         GSPrivateSockaddrLength(&_address.s));
       if (socketError(result))
         {
-          if (!socketWouldBlock())
+          if (socketWouldBlock())
             {
-              [self _recordError];
+              /*
+               * Need to set the status first, so that the run loop can tell
+               * it needs to add the stream as waiting on writable, as an
+               * indication of opened
+               */
+              [self _setStatus: NSStreamStatusOpening];
+            }
+          else
+            {
+              /* Had an immediate connect error, so record it and remove
+               * any handlers because we want higher level code to be
+               * told about it.
+               */
               [self _setHandler: nil];
               [_sibling _setHandler: nil];
-              return;
+              [self _recordError];
             }
-          /*
-           * Need to set the status first, so that the run loop can tell
-           * it needs to add the stream as waiting on writable, as an
-           * indication of opened
-           */
-          [self _setStatus: NSStreamStatusOpening];
 #if    defined(_WIN32)
           WSAEventSelect(_sock, _loopID, FD_ALL_EVENTS);
 #endif


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to