threads hung on read call with SMP configuration
Status: Alpha
Brought to you by:
coroberti
From: Mathieu <mat...@gm...> - 2015-05-31 12:05:38
|
Hi, When using the -t <threads_count> option, the created threads are blocked after one cycle (the screen is not refreshed anymore, and no more client is added). However, entering anything on the keyboard unblock one thread, but just for one cycle. Not using the -t option works as well. The configuration used is the following: - Hardware: HP server with 8cores intel CPU (not a virtual machine) - OS: Debian Jessie - Kernel: 3.16.0 Funnily enough, doing a strace on the main process group unblock the situation (it seems attaching strace sends a signal to the process that could cause this behaviour). Nonetheless, making a strace on only one of the thread shows that it is blocked on the read call (in screen.c), apparently ignoring the VTIME timer. Not sure if anyone encountered the same problem, but if so, below and attached is a patch that fixes it (using select prior to read). -- Mat --- screen.c 2007-04-26 09:26:59.000000000 +0200 +++ /usr/src/curl-loader-0.56/screen.c 2015-05-31 10:44:41.712447334 +0200 @@ -82,6 +82,9 @@ struct termios otty, ntty; int ch = -1; + struct timeval tv; + fd_set readset; + tcgetattr(STDIN_FILENO, &otty); ntty = otty; @@ -98,6 +101,10 @@ ntty.c_cc[VMIN] = 0; /* non-block for input */ ntty.c_cc[VTIME] = 1; /* with timer*/ + tv.tv_sec = 0; + tv.tv_usec = 100000; + + #if 0 /* * use this to flush the input buffer before @@ -115,15 +122,21 @@ if (!tcsetattr(STDIN_FILENO, FLAG, &ntty)) { + FD_ZERO(&readset); + FD_SET(STDIN_FILENO, &readset); + select(STDIN_FILENO + 1, &readset, NULL, NULL, &tv); /* get a single character from stdin */ - if (read (STDIN_FILENO, &ch, 1 ) == -1) - { - if (!stop_loading) - { - fprintf(stderr, "%s - read() failed with errno %d.\n", - __func__, errno); - } - return -1; + if (FD_ISSET(fileno(stdin), &readset)) + { + if (read (STDIN_FILENO, &ch, 1 ) == -1) + { + if (!stop_loading) + { + fprintf(stderr, "%s - read() failed with errno %d.\n", + __func__, errno); + } + return -1; + } } /* restore old settings */ |