Check with select before accept (bug #325)
authorMark Spencer <markster@digium.com>
Mon, 29 Sep 2003 20:20:04 +0000 (20:20 +0000)
committerMark Spencer <markster@digium.com>
Mon, 29 Sep 2003 20:20:04 +0000 (20:20 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1580 65c4cc65-6c06-0410-ace0-fbb531ad65f3

asterisk.c

index 58fb6f3..ac7173f 100755 (executable)
@@ -216,6 +216,7 @@ static void *netconsole(void *vconsole)
 static void *listener(void *unused)
 {
        struct sockaddr_un sun;
+       fd_set fds;
        int s;
        int len;
        int x;
@@ -226,6 +227,13 @@ static void *listener(void *unused)
        for(;;) {
                if (ast_socket < 0)
                        return NULL;
+               FD_ZERO(&fds);
+               FD_SET(ast_socket, &fds);
+               s = ast_select(ast_socket + 1, &fds, NULL, NULL, NULL);
+               if (s < 0) {
+                       ast_log(LOG_WARNING, "Select retured error: %s\n", strerror(errno));
+                       continue;
+               }
                len = sizeof(sun);
                s = accept(ast_socket, (struct sockaddr *)&sun, &len);
                if (s < 0) {