Changes in / [f5d1b31:913545e]


Ignore:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • bitlbee.c

    rf5d1b31 r913545e  
    118118       
    119119        if( global.conf->runmode == RUNMODE_FORKDAEMON )
    120                 ipc_master_load_state( getenv( "_BITLBEE_RESTART_STATE" ) );
     120                ipc_master_load_state();
    121121
    122122        if( global.conf->runmode == RUNMODE_DAEMON || global.conf->runmode == RUNMODE_FORKDAEMON )
  • conf.c

    rf5d1b31 r913545e  
    7878        }
    7979       
    80         while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hu:" ) ) >= 0 )
     80        while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 )
    8181        /*     ^^^^ Just to make sure we skip this step from the REHASH handler. */
    8282        {
     
    145145                                "  -h  Show this help page.\n" );
    146146                        return NULL;
     147                }
     148                else if( opt == 'R' )
     149                {
     150                        /* We can't load the statefile yet (and should make very sure we do this
     151                           only once), so set the filename here and load the state information
     152                           when initializing ForkDaemon. (This option only makes sense in that
     153                           mode anyway!) */
     154                        ipc_master_set_statefile( optarg );
    147155                }
    148156                else if( opt == 'u' )
  • ipc.c

    rf5d1b31 r913545e  
    3333
    3434GSList *child_list = NULL;
     35static char *statefile = NULL;
    3536
    3637static void ipc_master_cmd_client( irc_t *data, char **cmd )
     
    6263}
    6364
    64 static void ipc_master_cmd_deaf( irc_t *data, char **cmd )
    65 {
    66         if( global.conf->runmode == RUNMODE_DAEMON )
    67         {
    68                 b_event_remove( global.listen_watch_source_id );
    69                 close( global.listen_socket );
    70                
    71                 global.listen_socket = global.listen_watch_source_id = -1;
    72        
    73                 ipc_to_children_str( "OPERMSG :Closed listening socket, waiting "
    74                                      "for all users to disconnect." );
    75         }
    76         else
    77         {
    78                 ipc_to_children_str( "OPERMSG :The DEAF command only works in "
    79                                      "normal daemon mode. Try DIE instead." );
    80         }
    81 }
    82 
    8365void ipc_master_cmd_rehash( irc_t *data, char **cmd )
    8466{
     
    11698        { "hello",      0, ipc_master_cmd_client,     0 },
    11799        { "die",        0, ipc_master_cmd_die,        0 },
    118         { "deaf",       0, ipc_master_cmd_deaf,       0 },
    119100        { "wallops",    1, NULL,                      IPC_CMD_TO_CHILDREN },
    120101        { "wall",       1, NULL,                      IPC_CMD_TO_CHILDREN },
     
    501482}
    502483
     484void ipc_master_set_statefile( char *fn )
     485{
     486        statefile = g_strdup( fn );
     487}
     488
    503489
    504490static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond )
     
    564550#endif
    565551
    566 int ipc_master_load_state( char *statefile )
     552int ipc_master_load_state()
    567553{
    568554        struct bitlbee_child *child;
     
    572558        if( statefile == NULL )
    573559                return 0;
    574        
    575560        fp = fopen( statefile, "r" );
    576561        unlink( statefile );    /* Why do it later? :-) */
  • ipc.h

    rf5d1b31 r913545e  
    5858
    5959char *ipc_master_save_state();
    60 int ipc_master_load_state( char *statefile );
     60void ipc_master_set_statefile( char *fn );
     61int ipc_master_load_state();
    6162int ipc_master_listen_socket();
    6263
  • irc.c

    rf5d1b31 r913545e  
    315315        g_free( irc );
    316316       
    317         if( global.conf->runmode == RUNMODE_INETD ||
    318             global.conf->runmode == RUNMODE_FORKDAEMON ||
    319             ( global.conf->runmode == RUNMODE_DAEMON &&
    320               global.listen_socket == -1 &&
    321               irc_connection_list == NULL ) )
     317        if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON )
    322318                b_main_quit();
    323319}
  • irc_commands.c

    rf5d1b31 r913545e  
    626626        { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
    627627        { "die",         0, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
    628         { "deaf",        0, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
    629628        { "wallops",     1, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
    630629        { "wall",        1, NULL,                IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
  • protocols/msn/ns.c

    rf5d1b31 r913545e  
    278278                if( num_parts == 5 )
    279279                {
    280                         int i, groupcount;
    281                        
    282                         groupcount = atoi( cmd[4] );
    283                         if( groupcount > 0 )
    284                         {
    285                                 /* valgrind says this is leaking memory, I'm guessing
    286                                    that this happens during server redirects. */
    287                                 if( md->grouplist )
    288                                 {
    289                                         for( i = 0; i < md->groupcount; i ++ )
    290                                                 g_free( md->grouplist[i] );
    291                                         g_free( md->grouplist );
    292                                 }
    293                                
    294                                 md->groupcount = groupcount;
     280                        md->buddycount = atoi( cmd[3] );
     281                        md->groupcount = atoi( cmd[4] );
     282                        if( md->groupcount > 0 )
    295283                                md->grouplist = g_new0( char *, md->groupcount );
    296                         }
    297                        
    298                         md->buddycount = atoi( cmd[3] );
     284                       
    299285                        if( !*cmd[3] || md->buddycount == 0 )
    300286                                msn_logged_in( ic );
     
    679665                                        imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
    680666                                }
    681                                
    682                                 g_free( inbox );
    683                                 g_free( folders );
    684667                        }
    685668                        else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 )
  • unix.c

    rf5d1b31 r913545e  
    4040static void sighandler( int signal );
    4141
    42 int main( int argc, char *argv[] )
     42int main( int argc, char *argv[], char **envp )
    4343{
    4444        int i = 0;
     
    141141        {
    142142                char *fn = ipc_master_save_state();
     143                char **args;
     144                int n, i;
    143145               
    144146                chdir( old_cwd );
    145147               
    146                 setenv( "_BITLBEE_RESTART_STATE", fn, 1 );
    147                 g_free( fn );
     148                n = 0;
     149                args = g_new0( char *, argc + 3 );
     150                args[n++] = argv[0];
     151                if( fn )
     152                {
     153                        args[n++] = "-R";
     154                        args[n++] = fn;
     155                }
     156                for( i = 1; argv[i] && i < argc; i ++ )
     157                {
     158                        if( strcmp( argv[i], "-R" ) == 0 )
     159                                i += 2;
     160                       
     161                        args[n++] = argv[i];
     162                }
    148163               
    149164                close( global.listen_socket );
    150165               
    151                 if( execv( argv[0], argv ) == -1 )
    152                         /* Apparently the execve() failed, so let's just
    153                            jump back into our own/current main(). */
    154                         /* Need more cleanup code to make this work. */
    155                         return 1; /* main( argc, argv ); */
     166                execve( args[0], args, envp );
    156167        }
    157168       
Note: See TracChangeset for help on using the changeset viewer.