Commit f2616a24 authored by Alexandre Julliard's avatar Alexandre Julliard

Set only the client socket in non-blocking mode instead of all fds;

should avoid problems with stdio handles.
parent e39b676a
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -37,12 +36,8 @@ static struct timeout_user *timeout_tail; /* sorted timeouts list tail */ ...@@ -37,12 +36,8 @@ static struct timeout_user *timeout_tail; /* sorted timeouts list tail */
/* register a user */ /* register a user */
void register_select_user( struct select_user *user ) void register_select_user( struct select_user *user )
{ {
int flags;
assert( !users[user->fd] ); assert( !users[user->fd] );
flags = fcntl( user->fd, F_GETFL, 0 );
fcntl( user->fd, F_SETFL, flags | O_NONBLOCK );
users[user->fd] = user; users[user->fd] = user;
if (user->fd > max_fd) max_fd = user->fd; if (user->fd > max_fd) max_fd = user->fd;
nb_users++; nb_users++;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -287,9 +288,13 @@ static void client_event( int event, void *private ) ...@@ -287,9 +288,13 @@ static void client_event( int event, void *private )
/* add a client */ /* add a client */
struct client *add_client( int fd, struct thread *self ) struct client *add_client( int fd, struct thread *self )
{ {
int flags;
struct client *client = mem_alloc( sizeof(*client) ); struct client *client = mem_alloc( sizeof(*client) );
if (!client) return NULL; if (!client) return NULL;
flags = fcntl( fd, F_GETFL, 0 );
fcntl( fd, F_SETFL, flags | O_NONBLOCK );
client->state = RUNNING; client->state = RUNNING;
client->select.fd = fd; client->select.fd = fd;
client->select.func = client_event; client->select.func = client_event;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment