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. I thought i could use Socket>>isPeerAlive to test whether i can expect further data from the prev. listening socket. But then i shutdown the end point of the connection (the prev. listening socket) isPeerAlive still signals true. Is this wrong usage of isPeerAlive? Should i rather use Socket>>atEnd to test whether the connection is still alive? Or something else? Steps to reproduce: - open a listening socket on localhost port 1234 (i use netcat: 'nc -l -p 1234') - start the Communicator.st like this: gst Communicator.st - ctrl-c/abort the netcat/listening process after Communicator connected - watch 'read hunk []' scrolling on the screen where you started gst. Robin -- and why is my signature missing? _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
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. And as usual i forgot the attachment... _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk Communicator.st (1K) Download Attachment |
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 [hidden email]--2004b/smalltalk--devo--2.2--patch-168 to compare with * comparing to [hidden email]--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 [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Tue, Oct 31, 2006 at 01:31:04PM +0100, Paolo Bonzini wrote:
> 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. > But this doesn't fix my test case, should it? I tried applying the patch to the latest cvs, and installing it and tried it, but i got the same results: endless loop. Robin _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
> But this doesn't fix my test case, should it? > I tried applying the patch to the latest cvs, and installing it and > tried it, but i got the same results: endless loop. > Yes, but this time I can see that 'End!' is reached. Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |