Commit cdce9652 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Prevent yielding forever when accept socket could not be opened.

parent 6b59f087
......@@ -226,13 +226,13 @@ static void *log_server(void *arg)
(struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
perror("bind() failed");
close(fd_accept);
return NULL;
fd_accept = -1;
}
if (listen(fd_accept, 4) < 0) {
if (fd_accept >= 0 && listen(fd_accept, 4) < 0) {
perror("listen() failed");
close(fd_accept);
return NULL;
fd_accept = -1;
}
while (1) {
......@@ -247,7 +247,7 @@ static void *log_server(void *arg)
sem_wait(&queue_wait);
}
do {
if (fd_accept >= 0) do {
FD_ZERO(&fdset_r);
FD_SET(fd_accept, &fdset_r);
tv.tv_sec = 0;
......@@ -358,9 +358,10 @@ int log_server_start(int port, enum log_type console_level,
printf("Starting log server on port %d\n", port);
pthread_attr_init(&attr);
#ifndef __FreeBSD__
pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN * 2);
#endif
/* PTHREAD_STACK_MIN * 2 seems to be the minimum on some old FreeBSD
releases
*/
pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN * 2 + 65536);
pthread_create(&thread_id, &attr, log_server, NULL);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment