This commit is contained in:
2025-11-10 12:26:25 +01:00
parent 62d7439ddd
commit 36925309da
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ int main(int argc, char **argv)
// TODO: set simulation_should_stop=true on ctrl+C
startup_simulation(2);
startup_simulation(3);
// Spawn metadata server (leader)
spawn_simulated_process("--addr 127.0.0.1 --port 8080 --leader");
+5 -3
View File
@@ -223,7 +223,6 @@ int tcp_register_events(TCP *tcp, void **contexts, struct pollfd *polled)
int tcp_translate_events(TCP *tcp, Event *events, void **contexts, struct pollfd *polled, int num_polled)
{
bool removed[MAX_CONNS+1];
memset(removed, 0, sizeof(removed));
int num_events = 0;
for (int i = 0; i < num_polled; i++) {
@@ -244,6 +243,7 @@ int tcp_translate_events(TCP *tcp, Event *events, void **contexts, struct pollfd
}
}
}
removed[i] = false;
} else {
@@ -322,13 +322,15 @@ int tcp_translate_events(TCP *tcp, Event *events, void **contexts, struct pollfd
}
}
for (int i = 0; i < num_polled; i++)
for (int i = 0; i < num_polled; i++) {
if (removed[i]) {
Connection *conn = &tcp->conns[i];
Connection *conn = contexts[i];
assert(conn);
conn_free(conn);
*conn = tcp->conns[--tcp->num_conns];
}
}
return num_events;
}