mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 15:28:30 +00:00
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:
parent
5469202ea8
commit
e142124730
25 changed files with 556 additions and 277 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/calls/struct/sigset.internal.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timespec.internal.h"
|
||||
#include "libc/calls/syscall_support-nt.internal.h"
|
||||
#include "libc/cosmo.h"
|
||||
#include "libc/ctype.h"
|
||||
|
@ -837,7 +838,8 @@ textwindows static int CountConsoleInputBytesBlockingImpl(uint32_t ms,
|
|||
uint32_t wi;
|
||||
struct timespec now, deadline;
|
||||
InitConsole();
|
||||
deadline = timespec_add(timespec_mono(), timespec_frommillis(ms));
|
||||
deadline =
|
||||
timespec_add(sys_clock_gettime_monotonic_nt(), timespec_frommillis(ms));
|
||||
RestartOperation:
|
||||
if (_check_cancel() == -1)
|
||||
return -1;
|
||||
|
@ -870,7 +872,7 @@ RestartOperation:
|
|||
// this can happen for multiple reasons. first our driver controls
|
||||
// user interactions in canonical mode. secondly we could lose the
|
||||
// race with another thread that's reading input.
|
||||
now = timespec_mono();
|
||||
now = sys_clock_gettime_monotonic_nt();
|
||||
if (timespec_cmp(now, deadline) >= 0)
|
||||
return etimedout();
|
||||
ms = timespec_tomillis(timespec_sub(deadline, now));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue