aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2008-06-29 10:35:41 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2008-06-29 10:35:41 +0100
commit565a1eaa8b36ca64a7806e6ad74a9a26495c0c6e (patch)
treec6d404b6600b4e10b7b0d5bd4d4c185f4954e4ac
parente0f9170849e9c4aaa679f86703a60686d36607bb (diff)
Added the DEAF command, which makes the daemon stop listening for new
connections. This makes it easier to upgrade a BitlBee without having to disconnect all current users immediately. Closes #428.
-rw-r--r--ipc.c20
-rw-r--r--irc.c6
-rw-r--r--irc_commands.c1
3 files changed, 26 insertions, 1 deletions
diff --git a/ipc.c b/ipc.c
index f853a18f..9121026a 100644
--- a/ipc.c
+++ b/ipc.c
@@ -62,6 +62,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 +116,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 },
diff --git a/irc.c b/irc.c
index a6220140..b98f7048 100644
--- a/irc.c
+++ b/irc.c
@@ -313,7 +313,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 },