This is the mail archive of the
cygwin-xfree@cygwin.com
mailing list for the Cygwin XFree86 project.
Re: More Test 15 [CGF please comment]
At 10:45 PM 4/11/2001 -0400, Christopher Faylor wrote:
>On Wed, Apr 11, 2001 at 08:47:09PM -0400, Pierre A. Humblet wrote:
>Thank you for the analysis. This is exactly what I was looking for.
>Would you care to submit a patch incorporating your setsockopt idea?
Sure, see attachment. I have tested it on Win98 and WinME.
No more connections in TIME_WAIT...
>I wonder if this should also be employed for UNIX domain sockets.
What do you mean? The pipe close problem on Win9X or something else?
>Hopefully the connections that you are seeing will go away within
>a few seconds. I don't see any reason for them to linger for a
>long time.
With the Test 15 server calling select() 100x/sec, more than 2000
connections accumulated on WinME. Thus the timeout is at least 20 sec...
That's long. Anyway it's fixed now.
>>Why do you use PeekMessage( PM_NOREMOVE) in peek_windows, and not
>>GetQueueStatus()?
>
>I assume that it was used because the person who wrote the original
>select code didn't know about the side effect and I just implemented his
>idea when I rewrote select().
>
>In any event, it looks like GetMessageStatus is a simpler interface.
>Would you like to submit a patch?
I tried but it doesn't work. Apparently GetQueueStatus() doesn't
consider pending NonQueuedMessages.
Pierre
--- select.cc.in Tue Mar 20 14:50:28 2001
+++ select.cc Fri Apr 13 19:41:14 2001
@@ -1329,6 +1329,11 @@
{
select_printf ("connection to si->exitsock %p", si->exitsock);
SOCKET s = socket (AF_INET, SOCK_STREAM, 0);
+
+ /* Set LINGER with 0 timeout for hard close */
+ struct linger tmp = {1, 0}; /* On, 0 delay */
+ (void) setsockopt (s, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof(tmp));
+
/* Connecting to si->exitsock will cause any executing select to wake
up. When this happens then the exitsock condition will cause the
thread to terminate. */
@@ -1338,12 +1343,12 @@
select_printf ("connect failed");
/* FIXME: now what? */
}
- shutdown (s, 2);
+ shutdown (s, SD_BOTH);
closesocket (s);
/* Wait for thread to go away */
WaitForSingleObject (si->thread, INFINITE);
- shutdown (si->exitsock, 2);
+ shutdown (si->exitsock, SD_BOTH);
closesocket (si->exitsock);
CloseHandle (si->thread);
stuff->device_specific[FHDEVN(FH_SOCKET)] = NULL;