From: Andre Date: Thu, 15 Jun 2006 11:25:37 +0000 (+0200) Subject: gui: mark all fds used for select() as non-blocking. X-Git-Tag: v0.2.14~60^2~20 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=75529c7cb29903302931db92f04cb3b510eb6317;p=paraslash.git gui: mark all fds used for select() as non-blocking. --- diff --git a/client_common.c b/client_common.c index c2ae2d31..9b241efe 100644 --- a/client_common.c +++ b/client_common.c @@ -320,6 +320,9 @@ int client_open(struct private_client_data *pcd) if (ret < 0) goto out; pcd->status = CL_CONNECTED; + ret = mark_fd_nonblock(pcd->fd); + if (ret < 0) + goto out; pcd->task.pre_select = client_pre_select; pcd->task.post_select = client_post_select; pcd->task.private_data = pcd; diff --git a/gui.c b/gui.c index 8b1b39a8..ab66bbb2 100644 --- a/gui.c +++ b/gui.c @@ -896,7 +896,6 @@ repeat: if (curses_active) para_fd_set(STDIN_FILENO, &rfds, &max_fileno); ret = para_select(max_fileno + 1, &rfds, NULL, &tv); -// PARA_DEBUG_LOG("select returned %d\n", ret); if (ret <= 0) goto check_return; /* skip fd checks */ /* signals */ @@ -1342,6 +1341,11 @@ int main(int argc, char *argv[]) initscr(); /* needed only once, always successful */ init_curses(); print_welcome(); + ret = mark_fd_nonblock(STDIN_FILENO); + if (ret < 0) { + PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret)); + exit(EXIT_FAILURE); + } for (;;) { print_status_bar(); ret = do_select(GETCH_MODE); diff --git a/gui_common.c b/gui_common.c index 07cab16f..87676986 100644 --- a/gui_common.c +++ b/gui_common.c @@ -1,4 +1,5 @@ #include "para.h" +#include "fd.h" extern const char *status_item_list[NUM_STAT_ITEMS]; @@ -7,8 +8,14 @@ int para_open_audiod_pipe(char *cmd) { int fds[3] = {0, 1, 0}; pid_t pid; - return para_exec_cmdline_pid(&pid, cmd, fds) > 0? - fds[1] : -1; + int ret = para_exec_cmdline_pid(&pid, cmd, fds); + if (ret < 0) + return ret; + ret = mark_fd_nonblock(fds[1]); + if (ret > 0) + return fds[1]; + close(fds[1]); + return ret; } int read_audiod_pipe(int fd, void (*line_handler)(char *) )