Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Ralf Habacker" To: "cygwin" Subject: RE: Long duration of close(socket) and signal problem Date: Tue, 5 Mar 2002 16:30:01 +0100 Message-ID: <000901c1c45a$9d8563b0$651c440a@BRAMSCHE> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal In-Reply-To: <000e01c1c40f$a18c13f0$0610a8c0@wyw> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 > To my great surprise, the close(socket) operation > took EXTREMELY long. It > took 0.11 second (CPU usage was low), while this > operation under MinGW 1.1 > on the same machine took only 0.00019 second. On > another Linux machine, > close took 0.000043 second. > An strace of fakeweb with a patchec cygwin.dll which prints an additional timestamp on entering fhandler_socket::close() shows that the time is consumed in the fhandler_socket::close(). 240 10050859 [main] fakeweb 2272 _close: close (4) 110 10050969 [main] fakeweb 2272 fhandler_socket::close: fhandler_socket::close() 329915 10380884 [main] fakeweb 2272 fhandler_socket::close: 0 = fhandler_socket::close() I assume this happens in the loop with the closesocket() call. Has anyone additional comments ? fhandler_socket::close () { debug_printf ("fhandler_socket::close()"); int res = 0; sigframe thisframe (mainthread); /* HACK to allow a graceful shutdown even if shutdown() hasn't been called by the application. Note that this isn't the ultimate solution but it helps in many cases. */ struct linger linger; linger.l_onoff = 1; linger.l_linger = 240; /* seconds. default 2MSL value according to MSDN. */ setsockopt (get_socket (), SOL_SOCKET, SO_LINGER, (const char *)&linger, sizeof linger); while ((res = closesocket (get_socket ())) && WSAGetLastError () == WSAEWOULDBLOCK) continue; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if (res) { set_winsock_errno (); res = -1; } close_secret_event (); debug_printf ("%d = fhandler_socket::close()", res); return res; } -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/