Rewrite Windows connect()

Our old code wasn't working with projects like Qt that call connect() in
O_NONBLOCK mode multiple times. This change overhauls connect() to use a
simpler WSAConnect() API and follows the same pattern as cosmo accept().
This change also reduces the binary footprint of read(), which no longer
needs to depend on our enormous clock_gettime() function.
This commit is contained in:
Justine Tunney 2024-09-12 23:01:20 -07:00
parent 5469202ea8
commit e142124730
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
25 changed files with 556 additions and 277 deletions

View file

@ -16,8 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/weaken.h"
#include "libc/mem/mem.h"
#include "libc/nt/thunk/msabi.h"
#include "libc/nt/winsock.h"
#include "libc/sock/internal.h"
@ -32,9 +30,6 @@ __msabi extern typeof(__sys_closesocket_nt) *const __imp_closesocket;
* This function should only be called by close().
*/
textwindows int sys_closesocket_nt(struct Fd *f) {
if (_weaken(sys_connect_nt_cleanup)) {
_weaken(sys_connect_nt_cleanup)(f, true);
}
if (!__imp_closesocket(f->handle)) {
return 0;
} else {