Make sure fishd synchronization happens only when needed

darcs-hash:20051127232208-ac50b-927157fb9b5d3e44981f9ec029735531ae59fd61.gz
This commit is contained in:
axel 2005-11-28 09:22:08 +10:00
parent e800fca499
commit bda7948719
4 changed files with 31 additions and 18 deletions

14
env.c
View file

@ -592,7 +592,10 @@ void env_set( const wchar_t *key,
else
{
if( !proc_had_barrier)
{
proc_had_barrier=1;
env_universal_barrier();
}
if( env_universal_get( key ) )
{
@ -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,7 +1090,10 @@ 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 )
{

View file

@ -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();
}
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;
}
@ -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);

View file

@ -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 );