diff options
| author | Franklin Wei <git@fwei.tk> | 2016-01-24 16:58:59 -0500 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2016-01-24 16:58:59 -0500 |
| commit | b346e948cb167c18efc33f32f0e7cfb21050fc96 (patch) | |
| tree | 2a6989023690021c15999ce8fc3fefdca3ab7d83 /src/server.c | |
| parent | e2c2a9878a0fb55923fbd77db1f73085013aa36c (diff) | |
| download | netcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.zip netcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.tar.gz netcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.tar.bz2 netcosm-b346e948cb167c18efc33f32f0e7cfb21050fc96.tar.xz | |
objects partially implemented, fixes some bugs
Diffstat (limited to 'src/server.c')
| -rw-r--r-- | src/server.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/server.c b/src/server.c index 6ce4de4..b8d5bb4 100644 --- a/src/server.c +++ b/src/server.c @@ -76,8 +76,11 @@ static void handle_disconnects(void) pid_t pid; while((pid = waitpid(-1, NULL, WNOHANG)) > 0) { + struct child_data *child = hash_lookup(child_map, &pid); + debugf("Client disconnect.\n"); - //struct child_data *child = hash_lookup(child_map, &pid); + + room_user_del(child->room, child); --num_clients; @@ -130,7 +133,7 @@ static void __attribute__((noreturn)) serv_cleanup(void) ev_default_destroy(); - _exit(0); + exit(0); } static void __attribute__((noreturn)) sigint_handler(int s) @@ -228,7 +231,7 @@ static void new_connection_cb(EV_P_ ev_io *w, int revents) if(pipe2(readpipe, O_DIRECT) < 0) error("error creating pipe, need linux kernel >= 3.4"); - if(pipe2(outpipe, O_NONBLOCK | O_DIRECT) < 0) + if(pipe2(outpipe, O_DIRECT) < 0) error("error creating pipe, need linux kernel >= 3.4"); pid_t pid = fork(); @@ -281,6 +284,7 @@ static void new_connection_cb(EV_P_ ev_io *w, int revents) ev_io *new_io_watcher = calloc(1, sizeof(ev_io)); ev_io_init(new_io_watcher, childreq_cb, new->readpipe[0], EV_READ); + ev_set_priority(new_io_watcher, EV_MINPRI); ev_io_start(EV_A_ new_io_watcher); new->io_watcher = new_io_watcher; |