]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
gui: mark all fds used for select() as non-blocking.
authorAndre <maan@p133.(none)>
Thu, 15 Jun 2006 11:25:37 +0000 (13:25 +0200)
committerAndre <maan@p133.(none)>
Thu, 15 Jun 2006 11:25:37 +0000 (13:25 +0200)
client_common.c
gui.c
gui_common.c

index c2ae2d315fc650f0e4fc6bd1dc267d34800a2983..9b241efe722bc8d4f6e926a9077e0e32797b73e2 100644 (file)
@@ -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 8b1b39a876e3ea84cc6cde1800edb4df3bdf026a..ab66bbb262d38efe8b4501034d3a8e651a07b5bd 100644 (file)
--- 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);
index 07cab16fe211c740c7a25a484e1fee5271490498..87676986719c326340d1612ec85763349d2225be 100644 (file)
@@ -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 *) )