Skip to content
Snippets Groups Projects
Commit a2126b63 authored by Mark Spencer's avatar Mark Spencer
Browse files

Check with select before accept (bug #325)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 229f4abf
No related branches found
No related tags found
No related merge requests found
...@@ -216,6 +216,7 @@ static void *netconsole(void *vconsole) ...@@ -216,6 +216,7 @@ static void *netconsole(void *vconsole)
static void *listener(void *unused) static void *listener(void *unused)
{ {
struct sockaddr_un sun; struct sockaddr_un sun;
fd_set fds;
int s; int s;
int len; int len;
int x; int x;
...@@ -226,6 +227,13 @@ static void *listener(void *unused) ...@@ -226,6 +227,13 @@ static void *listener(void *unused)
for(;;) { for(;;) {
if (ast_socket < 0) if (ast_socket < 0)
return NULL; 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); len = sizeof(sun);
s = accept(ast_socket, (struct sockaddr *)&sun, &len); s = accept(ast_socket, (struct sockaddr *)&sun, &len);
if (s < 0) { if (s < 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment