diff options
author | Sander Vrijders <[email protected]> | 2016-10-21 12:44:00 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-10-21 12:44:00 +0000 |
commit | 482c44232d4deda3f89a7d85fbad99c1c64e80ec (patch) | |
tree | f3fb790d93da3cbe198b0f0c58d9c7513b0eff23 /src/tools/oping/oping_server.c | |
parent | 680017a72c7a15b90f223bafcea80fd3e264e984 (diff) | |
parent | 02976060919566d1a217b818ca8f33297700d56d (diff) | |
download | ouroboros-482c44232d4deda3f89a7d85fbad99c1c64e80ec.tar.gz ouroboros-482c44232d4deda3f89a7d85fbad99c1c64e80ec.zip |
Merged in dstaesse/ouroboros/be-demux (pull request #267)
lib: Demultiplex the fast path
Diffstat (limited to 'src/tools/oping/oping_server.c')
-rw-r--r-- | src/tools/oping/oping_server.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c index 845f0cbd..8a5a3512 100644 --- a/src/tools/oping/oping_server.c +++ b/src/tools/oping/oping_server.c @@ -69,16 +69,23 @@ void * server_thread(void *o) struct oping_msg * msg = (struct oping_msg *) buf; struct timespec now = {0, 0}; struct timespec timeout = {0, 100 * MILLION}; + int fd; + fqueue_t * fq = fqueue_create(); + if (fq == NULL) + return (void *) 1; while (true) { - int fd = flow_select(server.flows, &timeout); - if (fd == -ETIMEDOUT) - continue; - if (fd < 0) { - printf("Failed to get active fd.\n"); + int ret = flow_event_wait(server.flows, fq, &timeout); + if (ret == -ETIMEDOUT) continue; + + if (ret < 0) { + printf("Event error.\n"); + break; } - while (!((msg_len = flow_read(fd, buf, OPING_BUF_SIZE)) < 0)) { + + while ((fd = fqueue_next(fq)) >= 0) { + msg_len = flow_read(fd, buf, OPING_BUF_SIZE); if (msg_len < 0) continue; @@ -160,8 +167,6 @@ int server_main() if (server.flows == NULL) return 0; - flow_set_zero(server.flows); - pthread_create(&server.cleaner_pt, NULL, cleaner_thread, NULL); pthread_create(&server.accept_pt, NULL, accept_thread, NULL); pthread_create(&server.server_pt, NULL, server_thread, NULL); |