Hi all,
it seems that pth_send() does not behave like send() if the socket descriptor
is closed only in the send direction. I patched the test_httpd.c (pth 1.4.1)
for a test case:
--- test_httpd.c.orig Thu Jun 27 14:41:15 2002
+++ test_httpd.c Thu Jun 27 14:50:53 2002
@@ -82,11 +82,14 @@ static void *handler(void *_arg)
"\r\n"
"Just a trivial test for GNU Pth\n"
"to show that it's serving data.\r\n", PTH_VERSION);
- pth_write(fd, str, strlen(str));
+ pth_send(fd, str, strlen(str),0);
/* close connection and let thread die */
fprintf(stderr, "connection shutdown (fd: %d)\n", fd);
+ shutdown(fd,1);
+ pth_send(fd, "Surprise.\r\n", strlen("Surprise.\r\n"),0);
close(fd);
+ fprintf(stderr, "connection really closed\n", fd);
return NULL;
}
shutdown(fd,1) closes the socket stream in the send direction. After that it is
tried to send data over this socket (this is a test in Sun's JCK).
send() would return -1 but pth_send() creates an event and puts the threads in
the waiting queue where the thread waits forever. A solution in pth_send() could be
to check if the socket can send data before putting the thread in the waiting queue.
I'm using -1 != send(fd,NULL,0,0) as a check on Linux as a workaround (but I do not
know if that is portable over all supported platforms).
Best reagards,
Martin Strassburger
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager (Majordomo) [EMAIL PROTECTED]