Opened at 2005-12-11T22:57:26Z
Last modified at 2014-12-06T23:59:10Z
#50 closed enhancement
Patch to register SIGUSR1 for reconnecting all — at Initial Version
Reported by: | yath | Owned by: | |
---|---|---|---|
Priority: | wishlist | Milestone: | |
Component: | BitlBee | Version: | 1.0 |
Keywords: | Cc: | ||
IRC client+version: | Client-independent | Operating System: | Public server |
OS version/distro: |
Description
Moin,
I wrote a patch against bitlbee 1.0 which extends bitlbee by a signal handler for SIGUSR1. When bitlbee (with this patch :)) receives this signal, it reconnects all active connections on all connected clients. This is useful for, e.g., placing a "killall -USR1 bitlbee" in /etc/ppp/ip-up or similiar, as bitlbee's oscar module only notices connection loss after some time.
Patch is here: diff -ur bitlbee-1.0/account.c bitlbee-1.0.new/account.c --- bitlbee-1.0/account.c 2005-11-18 01:17:04.000000000 +0100 +++ bitlbee-1.0.new/account.c 2005-12-11 19:50:00.258792320 +0100 @@ -154,3 +154,25 @@
cancel_auto_reconnect( a );
}
}
+ +void reconnect_all_accounts( void ) +{ + irc_t *irc; + account_t *account; + GSList *ircconn; + + for ( ircconn = irc_connection_list; ircconn; + ircconn = ircconn->next ) { + irc = ircconn->data; + if ( !set_getint( irc, "auto_reconnect" ) ) + continue; + + irc_usermsg( irc, "Reconnecting active accounts..." ); + + for ( account = irc->accounts; account; + account = account->next ) { + if ( account->gc ) + signoff( account-> gc ); + } + } +} diff -ur bitlbee-1.0/account.h bitlbee-1.0.new/account.h --- bitlbee-1.0/account.h 2005-11-18 01:17:04.000000000 +0100 +++ bitlbee-1.0.new/account.h 2005-12-11 19:50:00.258792320 +0100 @@ -45,5 +45,6 @@
void account_del( irc_t *irc, account_t *acc ); void account_on( irc_t *irc, account_t *a ); void account_off( irc_t *irc, account_t *a );
+void reconnect_all_accounts( void );
#endif
diff -ur bitlbee-1.0/doc/bitlbee.8 bitlbee-1.0.new/doc/bitlbee.8 --- bitlbee-1.0/doc/bitlbee.8 2005-11-21 12:41:29.000000000 +0100 +++ bitlbee-1.0.new/doc/bitlbee.8 2005-12-11 23:37:11.929463384 +0100 @@ -86,6 +86,12 @@
.SH COMMANDS To get a complete list of commands, please use the \fBhelp commands\fP command in the &bitlbee channel.
+.SH SIGNALS +.IP SIGTERM +Sending \fBSIGTERM\fP twice causes bitlbee to exit. +.IP SIGUSR1 +Upon receiving \fBSIGUSR1\fP, bitlbee reconnects all active accounts on +all connected clients.
.SH "SEE ALSO" .BR ircd (8), .BR inetd (8),
diff -ur bitlbee-1.0/unix.c bitlbee-1.0.new/unix.c --- bitlbee-1.0/unix.c 2005-11-18 01:17:04.000000000 +0100 +++ bitlbee-1.0.new/unix.c 2005-12-11 19:50:00.258792320 +0100 @@ -74,6 +74,7 @@
memset( &sig, 0, sizeof( sig ) ); sig.sa_handler = sighandler; sigaction( SIGPIPE, &sig, &old );
+ sigaction( SIGUSR1, &sig, &old );
sig.sa_flags = SA_RESETHAND; sigaction( SIGINT, &sig, &old ); sigaction( SIGILL, &sig, &old );
@@ -126,6 +127,10 @@
raise( signal );
}
}
+ else if( signal == SIGUSR1) + { + reconnect_all_accounts(); + }
else if( signal != SIGPIPE ) {
log_message( LOGLVL_ERROR, "Fatal signal received: %d. That's probably a bug.", signal );