mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-23 19:10:30 +00:00
Eliminate some flakes
- Get ASAN working on Windows. - Deleting directories and then recreating them with the same name in a short period of time appears to be a no-no on Windows. - There's no reason to call FlushFileBuffers on close() for pipes, and it's harmful since it might block indefinitely for no good reason.
This commit is contained in:
parent
27c899af56
commit
4e56d89dcd
60 changed files with 588 additions and 751 deletions
|
@ -34,12 +34,13 @@ textwindows int accept$nt(struct Fd *fd, void *addr, uint32_t *addrsize,
|
|||
uint32_t yes;
|
||||
for (;;) {
|
||||
if (!WSAPoll(&(struct pollfd$nt){fd->handle, POLLIN}, 1, 1000)) continue;
|
||||
if ((client = __getemptyfd()) == -1) return -1;
|
||||
if ((client = __reservefd()) == -1) return -1;
|
||||
if ((h = WSAAccept(fd->handle, addr, (int32_t *)addrsize, 0, 0)) != -1) {
|
||||
if (flags & SOCK_NONBLOCK) {
|
||||
yes = 1;
|
||||
if (__ioctlsocket$nt(g_fds.p[client].handle, FIONBIO, &yes) == -1) {
|
||||
__closesocket$nt(g_fds.p[client].handle);
|
||||
__releasefd(client);
|
||||
return __winsockerr();
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +49,7 @@ textwindows int accept$nt(struct Fd *fd, void *addr, uint32_t *addrsize,
|
|||
g_fds.p[client].handle = h;
|
||||
return client;
|
||||
} else {
|
||||
__releasefd(client);
|
||||
return __winsockerr();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1323,15 +1323,20 @@ static textwindows noinline int epoll_create1$nt(uint32_t flags) {
|
|||
int64_t ephnd;
|
||||
struct PortState *port_state;
|
||||
struct TsTreeNode *tree_node;
|
||||
if ((fd = __getemptyfd()) == -1) return -1;
|
||||
if (wepoll_init() < 0) return -1;
|
||||
if ((fd = __reservefd()) == -1) return -1;
|
||||
port_state = port_new(&ephnd);
|
||||
if (!port_state) return -1;
|
||||
if (!port_state) {
|
||||
__releasefd(fd);
|
||||
return -1;
|
||||
}
|
||||
tree_node = port_state_to_handle_tree_node(port_state);
|
||||
if (ts_tree_add(&epoll__handle_tree, tree_node, (uintptr_t)ephnd) < 0) {
|
||||
/* This should never happen. */
|
||||
port_delete(port_state);
|
||||
RETURN_SET_ERROR(-1, kNtErrorAlreadyExists);
|
||||
err_set_win_error(kNtErrorAlreadyExists);
|
||||
__releasefd(fd);
|
||||
return -1;
|
||||
}
|
||||
g_fds.p[fd].kind = kFdEpoll;
|
||||
g_fds.p[fd].handle = ephnd;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/internal.h"
|
||||
|
@ -32,15 +33,15 @@
|
|||
*/
|
||||
hidden struct NtWsaData kNtWsaData;
|
||||
|
||||
textwindows static void winsockfini(void) {
|
||||
static textwindows void winsockfini(void) {
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
textwindows void winsockinit(void) {
|
||||
textwindows noasan void winsockinit(void) {
|
||||
int rc;
|
||||
atexit(winsockfini);
|
||||
if ((rc = WSAStartup(VERSION, &kNtWsaData)) != 0 ||
|
||||
kNtWsaData.wVersion != VERSION) {
|
||||
abort();
|
||||
ExitProcess(123);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
textwindows int socket$nt(int family, int type, int protocol) {
|
||||
int fd;
|
||||
uint32_t yes;
|
||||
if ((fd = __getemptyfd()) == -1) return -1;
|
||||
if ((fd = __reservefd()) == -1) return -1;
|
||||
if ((g_fds.p[fd].handle = WSASocket(family, type & ~(CLOEXEC | NONBLOCK),
|
||||
protocol, NULL, 0, 0)) != -1) {
|
||||
if (type & NONBLOCK) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue