diff --git a/server/select.c b/server/select.c index 645f02abfd7..60a6fd42810 100644 --- a/server/select.c +++ b/server/select.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -37,12 +36,8 @@ static struct timeout_user *timeout_tail; /* sorted timeouts list tail */ /* register a user */ void register_select_user( struct select_user *user ) { - int flags; assert( !users[user->fd] ); - flags = fcntl( user->fd, F_GETFL, 0 ); - fcntl( user->fd, F_SETFL, flags | O_NONBLOCK ); - users[user->fd] = user; if (user->fd > max_fd) max_fd = user->fd; nb_users++; diff --git a/server/socket.c b/server/socket.c index 98c1f6db209..915de42a18c 100644 --- a/server/socket.c +++ b/server/socket.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -287,9 +288,13 @@ static void client_event( int event, void *private ) /* add a client */ struct client *add_client( int fd, struct thread *self ) { + int flags; struct client *client = mem_alloc( sizeof(*client) ); if (!client) return NULL; + flags = fcntl( fd, F_GETFL, 0 ); + fcntl( fd, F_SETFL, flags | O_NONBLOCK ); + client->state = RUNNING; client->select.fd = fd; client->select.func = client_event;