[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Remove set_windows_fd_as_blocking_socket()?

From: Ray Satiro
Subject: Re: [Bug-wget] Remove set_windows_fd_as_blocking_socket()?
Date: Wed, 06 Aug 2014 13:19:03 -0400
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0

On 8/5/2014 4:48 PM, Gisle Vanem wrote:
A little study of why calling the function 'set_windows_fd_as_blocking_socket()' is needed, reveals that on downloading a big file (400MByte using ftp), the Winsock functions 'WSASetLastError()' and 'WSAGetLastError()' are called approx. 277.000 times!! IMHO this is a terrible waste of CPU-time.

How many times is select called?

I failed to find a Gnulib reference/changelog where this bug was fixed (after 2011), but reading some sources failed to find any place where a network-socket is set to blocking in Gnulib's select() or poll().
Hence I request that the call to 'set_windows_fd_as_blocking_socket()'
should be removed.

The function should only be called on a non-blocking socket to set it blocking. It was needed because gnulib's select called WSAEventSelect() which turns blocking sockets into non-blocking. After every select call in wget the socket had to be turned back into blocking because wget used blocking sockets. Assuming both those things are still true and the wget team is not going back to MS select() then the code is needed. A cursory check of select.c and I see WSAEventSelect() is still used for sockets:

The WSASetLastError()/WSAGetLastError() in set_windows_fd_as_blocking_socket() are unfortunately necessary to wait until the socket is converted back to blocking. I could not ascertain that the winsock last error code would be set during the ioctl in all cases so I zeroed it beforehand using WSASetLastError(), then wait until the socket went back to blocking using WSAGetLastError(). Excessive CPU time for just those calls my gut says no but you may best me on that. I know that GetLastError()/SetLastError() just read/write a variable that isn't exposed and I'm pretty sure WSAGetLastError()/WSASetLastError() do the same.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]