Skip to content

Commit 24788c5

Browse files
kvapkelvich
authored andcommitted
Move connection dropping earlier than adding to poll lists in case server is disabled.
1 parent 04bbd42 commit 24788c5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

contrib/arbiter/src/server.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,15 @@ static bool server_accept(server_t server) {
418418
shout("failed to accept a connection: %s\n", strerror(errno));
419419
return false;
420420
}
421-
debug("a new connection accepted\n");
421+
debug("a new connection fd=%d accepted\n", fd);
422422

423+
if (!server->enabled) {
424+
shout("server disabled, disconnecting the accepted connection fd=%d\n", fd);
425+
// FIXME: redirect instead of disconnecting
426+
close(fd);
427+
return false;
428+
}
429+
423430
s = server->free_chain;
424431
if (s == NULL) {
425432
s = malloc(sizeof(stream_data_t));
@@ -430,13 +437,6 @@ static bool server_accept(server_t server) {
430437
s->next = server->used_chain;
431438
server->used_chain = s;
432439

433-
if (!server->enabled) {
434-
shout("server disabled, disconnecting the accepted connection\n");
435-
// FIXME: redirect instead of disconnecting
436-
close(fd);
437-
return false;
438-
}
439-
440440
stream_init(s, fd);
441441

442442
return server_add_socket(server, fd, s);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy