diff options
author | Max Kellermann <max@duempel.org> | 2008-12-30 19:20:36 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-12-30 19:20:36 +0100 |
commit | 03e650aa9e9a95575fccd51ec9f669abae52fe7e (patch) | |
tree | 6d1447445c41dc1322d017bb78f1e603d06d0237 /src | |
parent | 10b5966bf656bc25261171f6fbf4ea35eff246af (diff) | |
download | mpd-03e650aa9e9a95575fccd51ec9f669abae52fe7e.tar.gz mpd-03e650aa9e9a95575fccd51ec9f669abae52fe7e.tar.xz mpd-03e650aa9e9a95575fccd51ec9f669abae52fe7e.zip |
main_notify: make the read side of the pipe blocking
Currently, both sides of the pipe are blocking, although we do not
need blocking read(). Convert it back to blocking. Eliminate the
select() from wait_main_task().
Diffstat (limited to '')
-rw-r--r-- | src/main_notify.c | 21 | ||||
-rw-r--r-- | src/utils.c | 10 | ||||
-rw-r--r-- | src/utils.h | 2 |
3 files changed, 6 insertions, 27 deletions
diff --git a/src/main_notify.c b/src/main_notify.c index 68df0b44b..f821f76aa 100644 --- a/src/main_notify.c +++ b/src/main_notify.c @@ -63,7 +63,12 @@ static int ioops_consume(int fd_count, fd_set * rfds, void init_main_notify(void) { main_task = g_thread_self(); - init_async_pipe(main_pipe); + + if (pipe(main_pipe) < 0) + g_error("Couldn't open pipe: %s", strerror(errno)); + if (set_nonblocking(main_pipe[1]) < 0) + g_error("Couldn't set non-blocking I/O: %s", strerror(errno)); + main_notify_IO.fdset = ioops_fdset; main_notify_IO.consume = ioops_consume; registerIO(&main_notify_IO); @@ -96,19 +101,5 @@ void main_notify_unlock(void) void wait_main_task(void) { - fd_set rfds; - int ret; - - assert(main_task == g_thread_self()); - - do { - FD_ZERO(&rfds); - FD_SET(main_pipe[0], &rfds); - ret = select(main_pipe[0] + 1, &rfds, NULL, NULL, NULL); - } while (ret == 0 || (ret < 0 && (errno == EAGAIN || errno == EINTR))); - - if (ret < 0) - g_error("select() failed: %s", strerror(errno)); - consume_pipe(); } diff --git a/src/utils.c b/src/utils.c index f624cf6df..16a4cf018 100644 --- a/src/utils.c +++ b/src/utils.c @@ -211,16 +211,6 @@ int set_nonblocking(int fd) #endif } -void init_async_pipe(int file_des[2]) -{ - if (pipe(file_des) < 0) - g_error("Couldn't open pipe: %s", strerror(errno)); - if (set_nonblocking(file_des[0]) < 0) - g_error("Couldn't set non-blocking I/O: %s", strerror(errno)); - if (set_nonblocking(file_des[1]) < 0) - g_error("Couldn't set non-blocking I/O: %s", strerror(errno)); -} - int stringFoundInStringArray(const char *const*array, const char *suffix) { while (array && *array) { diff --git a/src/utils.h b/src/utils.h index 2142df7f4..4130eb74e 100644 --- a/src/utils.h +++ b/src/utils.h @@ -95,8 +95,6 @@ char *parsePath(char *path); int set_nonblocking(int fd); -void init_async_pipe(int file_des[2]); - int stringFoundInStringArray(const char *const*array, const char *suffix); #endif |