mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 06:12:27 +00:00
Fix bugs with recent change
This change makes further effort towards improving our poll() implementation on the New Technology. The stdin worker didn't work out so well for Python so it's not being used for now. System call tracing with the --strace flag should now be less noisy now on Windows unless you modify the strace.internal.h defines to turn on some optional ones that are most useful for debugging the system call wrappers.
This commit is contained in:
parent
933411ba99
commit
dc0ea6640e
127 changed files with 1354 additions and 866 deletions
|
@ -16,17 +16,11 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sig.internal.h"
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/nt/enum/wait.h"
|
||||
#include "libc/nt/errors.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/nt/struct/overlapped.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/yoink.inc"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
/**
|
||||
|
@ -38,52 +32,16 @@
|
|||
textwindows ssize_t sys_send_nt(int fd, const struct iovec *iov, size_t iovlen,
|
||||
uint32_t flags) {
|
||||
ssize_t rc;
|
||||
uint32_t i, sent = 0;
|
||||
uint32_t sent = 0;
|
||||
struct NtIovec iovnt[16];
|
||||
struct NtOverlapped overlapped = {.hEvent = WSACreateEvent()};
|
||||
|
||||
if (_check_interrupts(true, g_fds.p)) return eintr();
|
||||
|
||||
if (!WSASend(g_fds.p[fd].handle, iovnt, __iovec2nt(iovnt, iov, iovlen), &sent,
|
||||
flags, &overlapped, NULL)) {
|
||||
rc = sent;
|
||||
goto Finished;
|
||||
} else {
|
||||
rc = __wsablock(g_fds.p[fd].handle, &overlapped, &flags, true);
|
||||
}
|
||||
|
||||
if (WSAGetLastError() != kNtErrorIoPending) {
|
||||
STRACE("WSASend failed %lm");
|
||||
rc = __winsockerr();
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
i = WSAWaitForMultipleEvents(1, &overlapped.hEvent, true,
|
||||
__SIG_POLLING_INTERVAL_MS, true);
|
||||
if (i == kNtWaitFailed) {
|
||||
STRACE("WSAWaitForMultipleEvents failed %lm");
|
||||
rc = __winsockerr();
|
||||
goto Finished;
|
||||
} else if (i == kNtWaitTimeout) {
|
||||
if (_check_interrupts(true, g_fds.p)) {
|
||||
rc = eintr();
|
||||
goto Finished;
|
||||
}
|
||||
} else if (i == kNtWaitIoCompletion) {
|
||||
STRACE("IOCP TRIGGERED EINTR");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!WSAGetOverlappedResult(g_fds.p[fd].handle, &overlapped, &sent, false,
|
||||
&flags)) {
|
||||
STRACE("WSAGetOverlappedResult failed %lm");
|
||||
rc = __winsockerr();
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
rc = sent;
|
||||
Finished:
|
||||
WSACloseEvent(overlapped.hEvent);
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue