aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitlbee.c2
-rw-r--r--conf.c10
-rw-r--r--ipc.c29
-rw-r--r--ipc.h3
-rw-r--r--irc.c6
-rw-r--r--irc_commands.c1
-rw-r--r--protocols/msn/ns.c23
-rw-r--r--unix.c27
8 files changed, 59 insertions, 42 deletions
diff --git a/bitlbee.c b/bitlbee.c
index ab142dc5..b31c31fe 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -117,7 +117,7 @@ int bitlbee_daemon_init()
#endif
if( global.conf->runmode == RUNMODE_FORKDAEMON )
- ipc_master_load_state();
+ ipc_master_load_state( getenv( "_BITLBEE_RESTART_STATE" ) );
if( global.conf->runmode == RUNMODE_DAEMON || global.conf->runmode == RUNMODE_FORKDAEMON )
ipc_master_listen_socket();
diff --git a/conf.c b/conf.c
index 2bdead65..909d331a 100644
--- a/conf.c
+++ b/conf.c
@@ -77,7 +77,7 @@ conf_t *conf_load( int argc, char *argv[] )
at a *valid* configuration file. */
}
- while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 )
+ while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hu:" ) ) >= 0 )
/* ^^^^ Just to make sure we skip this step from the REHASH handler. */
{
if( opt == 'i' )
@@ -145,14 +145,6 @@ conf_t *conf_load( int argc, char *argv[] )
" -h Show this help page.\n" );
return NULL;
}
- else if( opt == 'R' )
- {
- /* We can't load the statefile yet (and should make very sure we do this
- only once), so set the filename here and load the state information
- when initializing ForkDaemon. (This option only makes sense in that
- mode anyway!) */
- ipc_master_set_statefile( optarg );
- }
else if( opt == 'u' )
{
g_free( conf->user );
diff --git a/ipc.c b/ipc.c
index 625ff2f9..d6b850f1 100644
--- a/ipc.c
+++ b/ipc.c
@@ -32,7 +32,6 @@
#endif
GSList *child_list = NULL;
-static char *statefile = NULL;
static void ipc_master_cmd_client( irc_t *data, char **cmd )
{
@@ -62,6 +61,25 @@ static void ipc_master_cmd_die( irc_t *data, char **cmd )
bitlbee_shutdown( NULL, -1, 0 );
}
+static void ipc_master_cmd_deaf( irc_t *data, char **cmd )
+{
+ if( global.conf->runmode == RUNMODE_DAEMON )
+ {
+ b_event_remove( global.listen_watch_source_id );
+ close( global.listen_socket );
+
+ global.listen_socket = global.listen_watch_source_id = -1;
+
+ ipc_to_children_str( "OPERMSG :Closed listening socket, waiting "
+ "for all users to disconnect." );
+ }
+ else
+ {
+ ipc_to_children_str( "OPERMSG :The DEAF command only works in "
+ "normal daemon mode. Try DIE instead." );
+ }
+}
+
void ipc_master_cmd_rehash( irc_t *data, char **cmd )
{
runmode_t oldmode;
@@ -97,6 +115,7 @@ static const command_t ipc_master_commands[] = {
{ "client", 3, ipc_master_cmd_client, 0 },
{ "hello", 0, ipc_master_cmd_client, 0 },
{ "die", 0, ipc_master_cmd_die, 0 },
+ { "deaf", 0, ipc_master_cmd_deaf, 0 },
{ "wallops", 1, NULL, IPC_CMD_TO_CHILDREN },
{ "wall", 1, NULL, IPC_CMD_TO_CHILDREN },
{ "opermsg", 1, NULL, IPC_CMD_TO_CHILDREN },
@@ -481,11 +500,6 @@ char *ipc_master_save_state()
}
}
-void ipc_master_set_statefile( char *fn )
-{
- statefile = g_strdup( fn );
-}
-
static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond )
{
@@ -549,7 +563,7 @@ int ipc_master_listen_socket()
}
#endif
-int ipc_master_load_state()
+int ipc_master_load_state( char *statefile )
{
struct bitlbee_child *child;
FILE *fp;
@@ -557,6 +571,7 @@ int ipc_master_load_state()
if( statefile == NULL )
return 0;
+
fp = fopen( statefile, "r" );
unlink( statefile ); /* Why do it later? :-) */
if( fp == NULL )
diff --git a/ipc.h b/ipc.h
index f3d24614..0e71c520 100644
--- a/ipc.h
+++ b/ipc.h
@@ -57,8 +57,7 @@ void ipc_to_children_str( char *format, ... ) G_GNUC_PRINTF( 1, 2 );
void ipc_master_cmd_rehash( irc_t *data, char **cmd );
char *ipc_master_save_state();
-void ipc_master_set_statefile( char *fn );
-int ipc_master_load_state();
+int ipc_master_load_state( char *statefile );
int ipc_master_listen_socket();
extern GSList *child_list;
diff --git a/irc.c b/irc.c
index c850b65c..ea6098a1 100644
--- a/irc.c
+++ b/irc.c
@@ -314,7 +314,11 @@ void irc_free( irc_t * irc )
g_free( irc );
- if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON )
+ if( global.conf->runmode == RUNMODE_INETD ||
+ global.conf->runmode == RUNMODE_FORKDAEMON ||
+ ( global.conf->runmode == RUNMODE_DAEMON &&
+ global.listen_socket == -1 &&
+ irc_connection_list == NULL ) )
b_main_quit();
}
diff --git a/irc_commands.c b/irc_commands.c
index 6a47007a..fb2bc7cf 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -625,6 +625,7 @@ static const command_t irc_commands[] = {
{ "version", 0, irc_cmd_version, IRC_CMD_LOGGED_IN },
{ "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
{ "die", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
+ { "deaf", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
{ "wallops", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
{ "wall", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
{ "rehash", 0, irc_cmd_rehash, IRC_CMD_OPER_ONLY },
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index ffaa90a7..fe48f96d 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -277,11 +277,25 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts )
{
if( num_parts == 5 )
{
- md->buddycount = atoi( cmd[3] );
- md->groupcount = atoi( cmd[4] );
- if( md->groupcount > 0 )
+ int i, groupcount;
+
+ groupcount = atoi( cmd[4] );
+ if( groupcount > 0 )
+ {
+ /* valgrind says this is leaking memory, I'm guessing
+ that this happens during server redirects. */
+ if( md->grouplist )
+ {
+ for( i = 0; i < md->groupcount; i ++ )
+ g_free( md->grouplist[i] );
+ g_free( md->grouplist );
+ }
+
+ md->groupcount = groupcount;
md->grouplist = g_new0( char *, md->groupcount );
+ }
+ md->buddycount = atoi( cmd[3] );
if( !*cmd[3] || md->buddycount == 0 )
msn_logged_in( ic );
}
@@ -664,6 +678,9 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int
{
imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders );
}
+
+ g_free( inbox );
+ g_free( folders );
}
else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 )
{
diff --git a/unix.c b/unix.c
index 0566fa56..56b0ab46 100644
--- a/unix.c
+++ b/unix.c
@@ -39,7 +39,7 @@ global_t global; /* Against global namespace pollution */
static void sighandler( int signal );
-int main( int argc, char *argv[], char **envp )
+int main( int argc, char *argv[] )
{
int i = 0;
char *old_cwd = NULL;
@@ -140,30 +140,19 @@ int main( int argc, char *argv[], char **envp )
if( global.restart )
{
char *fn = ipc_master_save_state();
- char **args;
- int n, i;
chdir( old_cwd );
- n = 0;
- args = g_new0( char *, argc + 3 );
- args[n++] = argv[0];
- if( fn )
- {
- args[n++] = "-R";
- args[n++] = fn;
- }
- for( i = 1; argv[i] && i < argc; i ++ )
- {
- if( strcmp( argv[i], "-R" ) == 0 )
- i += 2;
-
- args[n++] = argv[i];
- }
+ setenv( "_BITLBEE_RESTART_STATE", fn, 1 );
+ g_free( fn );
close( global.listen_socket );
- execve( args[0], args, envp );
+ if( execv( argv[0], argv ) == -1 )
+ /* Apparently the execve() failed, so let's just
+ jump back into our own/current main(). */
+ /* Need more cleanup code to make this work. */
+ return 1; /* main( argc, argv ); */
}
return( 0 );