Bug fix
This commit is contained in:
+1
-1
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user