List Info

Thread: Problems with Socket>>isPeerAlive




Problems with Socket>>isPeerAlive
user name
2006-10-31 12:31:04
Robin Redeker wrote:
> On Tue, Oct 31, 2006 at 12:43:47PM +0100, Robin Redeker
wrote:
>   
>> Hi,
>>
>> in the attachment there is a piece of code, which
establishes a tcp
>> connection to a listening socket and reads all
arriving data from there.
>>     
Yes, the SIGIO arrives but events.c misses it because a
POLLHUP 
condition (peer dead) does not increment the return value of
poll.

Fixing this in turn triggers a latent bug in sockets.  See
the attached 
patch, I need to test it a bit more before committing.

Thanks,

Paolo
* looking for bonzinignu.org--2004b/smalltalk--devo--2.2--patch-168 to
compare with
* comparing to bonzinignu.org--2004b/smalltalk--devo--2.2--patch-168
M  kernel/PosStream.st
M  kernel/Stream.st
M  libgst/events.c
M  tcp/Sockets.st

* modified files

--- orig/kernel/PosStream.st
+++ mod/kernel/PosStream.st
 -245,13
+245,6  collection
     ^collection
 !
 
-pastEnd
-    "The end of the stream has been reached.  Signal a
Notification"
-
-    SystemExceptions.EndOfStream signalOn: self.
-    ^nil
-!
-
 status: aString
     "When working with a stream on strings, this
method can be useful!
      Format of the output:


--- orig/kernel/Stream.st
+++ mod/kernel/Stream.st
 -300,12
+300,19  tab
 ! !
 
 
-!Stream methodsFor: 'providing consistent protocols'!
+!Stream methodsFor: 'polymorphism'!
 
 close
     "Do nothing. This is provided for consistency with
file streams"
 !
 
+pastEnd
+    "The end of the stream has been reached.  Signal a
Notification."
+
+    SystemExceptions.EndOfStream signalOn: self.
+    ^nil
+!
+
 flush
     "Do nothing. This is provided for consistency with
file streams"
 ! !


--- orig/libgst/events.c
+++ mod/libgst/events.c
 -190,9
+190,6  file_polling_handler (int sig)
 	}
       while (n == -1 && errno == EINTR);
 
-      if (n == 0)
-	return;
-
       num_used_pollfds = 0;
       for (node = head, pprev = &head; node; node =
*pprev)
 	{


--- orig/tcp/Sockets.st
+++ mod/tcp/Sockets.st
 -818,6
+818,7  available
 bufferContents
     "Answer the current contents of the read
buffer"
     | result |
+    readBuffer isNil ifTrue: [ ^self pastEnd ].
     result := self readBuffer bufferContents.
     lookahead isNil ifFalse: [
 	result := lookahead asString, result.



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )