NSM: Don't wait on clients that have died while executing a command.

This commit is contained in:
Jonathan Moore Liles 2013-07-14 12:08:49 -07:00
parent d9ba4bda2b
commit fad4f7938c
1 changed files with 23 additions and 22 deletions

View File

@ -97,6 +97,8 @@ enum {
static int pending_operation = COMMAND_NONE; static int pending_operation = COMMAND_NONE;
static void wait ( long );
#define GUIMSG( fmt, args... ) \ #define GUIMSG( fmt, args... ) \
{ \ { \
@ -352,7 +354,6 @@ handle_client_process_death ( int pid )
} }
} }
void handle_sigchld ( ) void handle_sigchld ( )
{ {
for ( ;; ) for ( ;; )
@ -382,7 +383,6 @@ path_is_valid ( const char *path )
return r; return r;
} }
int int
mkpath ( const char *path, bool create_final_directory ) mkpath ( const char *path, bool create_final_directory )
{ {
@ -545,9 +545,9 @@ wait_for_announce ( void )
{ {
n -= 100; n -= 100;
osc_server->wait(100); wait(100);
active = number_of_active_clients(); active = number_of_active_clients();
if ( client.size() == active ) if ( client.size() == active )
break; break;
@ -568,7 +568,7 @@ wait_for_replies ( void )
{ {
n -= 100; n -= 100;
osc_server->wait(100); wait(100);
if ( ! replies_still_pending() ) if ( ! replies_still_pending() )
break; break;
@ -2164,16 +2164,30 @@ OSC_HANDLER( null )
static void
wait ( long timeout )
{
struct signalfd_siginfo fdsi;
ssize_t s = read(signal_fd, &fdsi, sizeof(struct signalfd_siginfo));
if (s == sizeof(struct signalfd_siginfo))
{
if (fdsi.ssi_signo == SIGCHLD)
handle_sigchld();
}
osc_server->wait( timeout );
purge_dead_clients();
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
sigset_t mask; sigset_t mask;
sigemptyset( &mask ); sigemptyset( &mask );
sigaddset( &mask, SIGCHLD ); sigaddset( &mask, SIGCHLD );
sigprocmask(SIG_BLOCK, &mask, NULL ); sigprocmask(SIG_BLOCK, &mask, NULL );
signal_fd = signalfd( -1, &mask, SFD_NONBLOCK ); signal_fd = signalfd( -1, &mask, SFD_NONBLOCK );
/* generate random seed for client ids */ /* generate random seed for client ids */
@ -2318,23 +2332,10 @@ int main(int argc, char *argv[])
} }
} }
struct signalfd_siginfo fdsi;
/* listen for sigchld signals and process OSC messages forever */ /* listen for sigchld signals and process OSC messages forever */
for ( ;; ) for ( ;; )
{ {
ssize_t s = read(signal_fd, &fdsi, sizeof(struct signalfd_siginfo)); wait( 1000 );
if (s == sizeof(struct signalfd_siginfo))
{
if (fdsi.ssi_signo == SIGCHLD)
handle_sigchld();
}
osc_server->wait( 1000 );
purge_dead_clients();
} }
// osc_server->run(); // osc_server->run();