- Timestamp:
- 2006-01-15T20:31:59Z (18 years ago)
- Branches:
- master
- Children:
- daa9e02
- Parents:
- 6fda350
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ipc.c
r6fda350 rf4a5940 42 42 } 43 43 44 static int ipc_master_cmd_wallops( irc_t *data, char **cmd ) 45 { 46 ipc_to_children( cmd ); 44 static int ipc_master_cmd_rehash( irc_t *data, char **cmd ) 45 { 46 runmode_t oldmode; 47 48 oldmode = global.conf->runmode; 49 50 g_free( global.conf ); 51 global.conf = conf_load( 0, NULL ); 52 53 if( global.conf->runmode != oldmode ) 54 { 55 log_message( LOGLVL_WARNING, "Can't change RunMode setting at runtime, restoring original setting" ); 56 global.conf->runmode = oldmode; 57 } 58 59 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 60 ipc_to_children( cmd ); 47 61 48 62 return 1; … … 51 65 static const command_t ipc_master_commands[] = { 52 66 { "die", 0, ipc_master_cmd_die, 0 }, 53 { "wallops", 1, ipc_master_cmd_wallops, 0 }, 54 { "lilo", 1, ipc_master_cmd_wallops, 0 }, 67 { "wallops", 1, NULL, IPC_CMD_TO_CHILDREN }, 68 { "lilo", 1, NULL, IPC_CMD_TO_CHILDREN }, 69 { "rehash", 0, ipc_master_cmd_rehash, 0 }, 55 70 { NULL } 56 71 }; … … 80 95 if( strchr( irc->umode, 's' ) ) 81 96 irc_write( irc, ":%s NOTICE %s :%s", irc->myhost, irc->nick, cmd[1] ); 97 98 return 1; 99 } 100 101 static int ipc_child_cmd_rehash( irc_t *data, char **cmd ) 102 { 103 runmode_t oldmode; 104 105 oldmode = global.conf->runmode; 106 107 g_free( global.conf ); 108 global.conf = conf_load( 0, NULL ); 109 110 global.conf->runmode = oldmode; 82 111 83 112 return 1; … … 88 117 { "wallops", 1, ipc_child_cmd_wallops, 0 }, 89 118 { "lilo", 1, ipc_child_cmd_lilo, 0 }, 119 { "rehash", 0, ipc_child_cmd_rehash, 0 }, 90 120 { NULL } 91 121 }; … … 102 132 if( g_strcasecmp( commands[i].command, cmd[0] ) == 0 ) 103 133 { 104 commands[i].execute( data, cmd ); 134 if( commands[i].flags & IPC_CMD_TO_CHILDREN ) 135 ipc_to_children( cmd ); 136 else 137 commands[i].execute( data, cmd ); 138 105 139 return; 106 140 } … … 198 232 { 199 233 char *s = irc_build_line( cmd ); 200 write( global.listen_socket, s, strlen( s ) ); 234 ipc_to_master_str( s ); 235 g_free( s ); 236 } 237 else if( global.conf->runmode == RUNMODE_DAEMON ) 238 { 239 ipc_command_exec( NULL, cmd, ipc_master_commands ); 240 } 241 } 242 243 void ipc_to_master_str( char *msg_buf ) 244 { 245 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 246 { 247 write( global.listen_socket, msg_buf, strlen( msg_buf ) ); 248 } 249 else if( global.conf->runmode == RUNMODE_DAEMON ) 250 { 251 char *s, **cmd; 252 253 /* irc_parse_line() wants a read-write string, so get it one: */ 254 s = g_strdup( msg_buf ); 255 cmd = irc_parse_line( s ); 256 257 ipc_command_exec( NULL, cmd, ipc_master_commands ); 258 259 g_free( cmd ); 201 260 g_free( s ); 202 261 } … … 210 269 ipc_to_children_str( msg_buf ); 211 270 g_free( msg_buf ); 271 } 272 else if( global.conf->runmode == RUNMODE_DAEMON ) 273 { 274 GSList *l; 275 276 for( l = irc_connection_list; l; l = l->next ) 277 ipc_command_exec( l->data, cmd, ipc_child_commands ); 212 278 } 213 279 } … … 226 292 } 227 293 } 228 } 294 else if( global.conf->runmode == RUNMODE_DAEMON ) 295 { 296 char *s, **cmd; 297 298 /* irc_parse_line() wants a read-write string, so get it one: */ 299 s = g_strdup( msg_buf ); 300 cmd = irc_parse_line( s ); 301 302 ipc_to_children( cmd ); 303 304 g_free( cmd ); 305 g_free( s ); 306 } 307 }
Note: See TracChangeset
for help on using the changeset viewer.