From bda7948719555dd7745a416d79aa7e21a252fbdb Mon Sep 17 00:00:00 2001 From: axel Date: Mon, 28 Nov 2005 09:22:08 +1000 Subject: [PATCH] Make sure fishd synchronization happens only when needed darcs-hash:20051127232208-ac50b-927157fb9b5d3e44981f9ec029735531ae59fd61.gz --- env.c | 18 ++++++++++++++++-- env_universal.c | 21 ++++++++++----------- fishd.c | 8 ++++---- input.c | 2 +- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/env.c b/env.c index 578e0350d..d9c53a429 100644 --- a/env.c +++ b/env.c @@ -592,8 +592,11 @@ void env_set( const wchar_t *key, else { if( !proc_had_barrier) + { + proc_had_barrier=1; env_universal_barrier(); - + } + if( env_universal_get( key ) ) { int export = 0; @@ -808,7 +811,11 @@ wchar_t *env_get( const wchar_t *key ) env = env->next; } if( !proc_had_barrier) + { + proc_had_barrier=1; env_universal_barrier(); + } + item = env_universal_get( key ); if( !item || (wcscmp( item, ENV_NULL )==0)) @@ -845,7 +852,11 @@ int env_exist( const wchar_t *key ) env = env->next; } if( !proc_had_barrier) + { + proc_had_barrier=1; env_universal_barrier(); + } + item = env_universal_get( key ); return item != 0; @@ -1079,8 +1090,11 @@ static void export_func2( const void *k, const void *v, void *aux ) char **env_export_arr( int recalc) { if( recalc && !proc_had_barrier) + { + proc_had_barrier=1; env_universal_barrier(); - + } + if( has_changed ) { array_list_t uni; diff --git a/env_universal.c b/env_universal.c index 0a2aaadd5..f9b14b940 100644 --- a/env_universal.c +++ b/env_universal.c @@ -117,19 +117,16 @@ static int get_socket( int fork_ok ) if( connect( s, (struct sockaddr *)&local, len) == -1 ) { close( s ); - if( fork_ok ) + if( fork_ok && start_fishd ) { debug( 2, L"Could not connect to socket %d, starting fishd", s ); - if( start_fishd ) - { - start_fishd(); - } - + start_fishd(); + return get_socket( 0 ); } - debug( 3, L"Could not connect to socket %d, already tried forking, giving up", s ); + debug( 2, L"Could not connect to socket %d, already tried manual restart (or no command supplied), giving up", s ); return -1; } @@ -305,7 +302,7 @@ void env_universal_barrier() if( !init || ( env_universal_server.fd == -1 )) return; - + barrier_reply = 0; /* @@ -330,6 +327,7 @@ void env_universal_barrier() if( env_universal_server.fd == -1 ) { reconnect(); + debug( 2, L"barrier interrupted, exiting" ); return; } @@ -347,6 +345,7 @@ void env_universal_barrier() if( env_universal_server.fd == -1 ) { reconnect(); + debug( 2, L"barrier interrupted, exiting (2)" ); return; } FD_ZERO( &fds ); @@ -365,7 +364,7 @@ void env_universal_set( const wchar_t *name, const wchar_t *value, int export ) if( !init ) return; - debug( 3, L"env_universal_set( %ls, %ls )", name, value ); + debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value ); msg = create_message( export?SET_EXPORT:SET, name, @@ -388,8 +387,8 @@ void env_universal_remove( const wchar_t *name ) if( !init ) return; - debug( 2, - L"env_universal_remove( %ls )", + debug( 3, + L"env_universal_remove( \"%ls\" )", name ); msg= create_message( ERASE, name, 0); diff --git a/fishd.c b/fishd.c index 9f0eee16d..f43d587e9 100644 --- a/fishd.c +++ b/fishd.c @@ -269,7 +269,7 @@ static void daemonize() case 0: { /* - Make fish ignore the HUP signal. + Make fishd ignore the HUP signal. */ struct sigaction act; sigemptyset( & act.sa_mask ); @@ -285,12 +285,12 @@ static void daemonize() exit(0); } } - + /* Put ourself in out own processing group */ setsid(); - + /* Close stdin and stdout. We only use stderr, anyway. */ @@ -427,7 +427,7 @@ int main( int argc, char ** argv ) wperror( L"select" ); exit(1); } - + if( FD_ISSET( sock, &read_fd ) ) { if( (child_socket = diff --git a/input.c b/input.c index 8f04a51bd..f9bbb99da 100644 --- a/input.c +++ b/input.c @@ -698,7 +698,7 @@ static wchar_t *input_expand_sequence( const wchar_t *in ) } debug( 1, L"Invalid sequence - Control-nothing?\n" ); error = 1; - + break; }