Exportable universal variables

darcs-hash:20050922201652-ac50b-f70e7607b4ace24da4020f2d432718dc335e5bdd.gz
This commit is contained in:
axel
2005-09-23 06:16:52 +10:00
parent fcdaed44d7
commit f971e02256
19 changed files with 539 additions and 203 deletions

33
fishd.c
View File

@@ -107,48 +107,29 @@ int get_socket()
return s;
}
void enqueue( const void *k,
const void *v,
void *q)
{
const wchar_t *key = (const wchar_t *)k;
const wchar_t *val = (const wchar_t *)v;
queue_t *queue = (queue_t *)q;
message_t *msg = create_message( SET, key, val );
msg->count=1;
q_put( queue, msg );
}
void enqueue_all( connection_t *c )
{
hash_foreach2( &env_universal_var,
&enqueue,
(void *)&c->unsent );
try_send_all( c );
}
void broadcast( int type, const wchar_t *key, const wchar_t *val )
{
connection_t *c;
message_t *msg;
debug( 1, L"Got message %d %ls %ls", type, key, val );
if( !conn )
return;
msg = create_message( type, key, val );
msg = create_message( type, key, val );
/*
Don't merge loops, or try_send_all can free the message prematurely
*/
for( c = conn; c; c=c->next )
{
msg->count++;
q_put( &c->unsent, msg );
}
for( c = conn; c; c=c->next )
{
try_send_all( c );