fix: uasync epoll event ordering + test_uasync_socket_race fix
This commit is contained in:
1 parent
b7988f0ef8
commit
ce5a84da24
8 files changed
+479
-196
No files matched your search
@@ -60,16 +60,18 @@ static void on_closed_cb(struct tcp_conn* tc, void* arg) {
|
||||
|
||||
static void on_accept_cb(int fd, void* arg) {
|
||||
(void)arg;
|
||||
struct sockaddr_in addr; socklen_t alen = sizeof(addr);
|
||||
int csock = accept(fd, (struct sockaddr*)&addr, &alen);
|
||||
if (csock < 0) return;
|
||||
if (csock == 0) { int r = open("/dev/null", O_RDONLY); if (r > 0 && r != 0) { dup2(r, 0); close(r); } return; }
|
||||
socket_set_nonblocking(csock);
|
||||
struct tcp_conn* tc = tcp_conn_create(g_ua, csock, 512, 512, 4, 0, 0, on_fin_cb, on_error_cb, NULL);
|
||||
if (!tc) { socket_close_wrapper(csock); return; }
|
||||
tc->on_closed = on_closed_cb;
|
||||
queue_set_callback(tc->read_queue, on_read_cb, tc);
|
||||
g_conn_count++;
|
||||
while (1) {
|
||||
struct sockaddr_in addr; socklen_t alen = sizeof(addr);
|
||||
int csock = accept(fd, (struct sockaddr*)&addr, &alen);
|
||||
if (csock < 0) return;
|
||||
if (csock == 0) { int r = open("/dev/null", O_RDONLY); if (r > 0 && r != 0) { dup2(r, 0); close(r); } continue; }
|
||||
socket_set_nonblocking(csock);
|
||||
struct tcp_conn* tc = tcp_conn_create(g_ua, csock, 512, 512, 4, 0, 0, on_fin_cb, on_error_cb, NULL);
|
||||
if (!tc) { socket_close_wrapper(csock); continue; }
|
||||
tc->on_closed = on_closed_cb;
|
||||
queue_set_callback(tc->read_queue, on_read_cb, tc);
|
||||
g_conn_count++;
|
||||
}
|
||||
}
|
||||
|
||||
static int child_main(int port, int id, int count) {
|
||||
@@ -97,7 +99,7 @@ static void monitor(void* arg) {
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { g_done = -1; return; }
|
||||
g_children[i] = 0;
|
||||
}
|
||||
if (alive == 0) { g_ok = 1; g_done = 1; }
|
||||
if (alive == 0 && g_read_count >= CHILDREN * ITER_PER_CHILD) { g_ok = 1; g_done = 1; }
|
||||
if (!g_done) g_mon_id = uasync_set_timeout(g_ua, 500, NULL, monitor, "mon");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user