aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc.c21
-rw-r--r--irc.c4
-rw-r--r--irc.h4
3 files changed, 20 insertions, 9 deletions
diff --git a/ipc.c b/ipc.c
index 5fda047c..4777113a 100644
--- a/ipc.c
+++ b/ipc.c
@@ -35,12 +35,15 @@ static int ipc_master_cmd_client( irc_t *data, char **cmd )
{
struct bitlbee_child *child = (void*) data;
- child->host = g_strdup( cmd[1] );
- child->nick = g_strdup( cmd[2] );
- child->realname = g_strdup( cmd[3] );
+ if( child )
+ {
+ child->host = g_strdup( cmd[1] );
+ child->nick = g_strdup( cmd[2] );
+ child->realname = g_strdup( cmd[3] );
+ }
ipc_to_children_str( "OPERMSG :Client connecting (PID=%d): %s@%s (%s)\r\n",
- child->pid, child->nick, child->host, child->realname );
+ child ? child->pid : -1, cmd[2], cmd[1], cmd[3] );
return 1;
}
@@ -307,7 +310,10 @@ void ipc_to_master_str( char *format, ... )
}
else if( global.conf->runmode == RUNMODE_DAEMON )
{
- char **cmd;
+ char **cmd, *s;
+
+ if( ( s = strchr( msg_buf, '\r' ) ) )
+ *s = 0;
cmd = irc_parse_line( msg_buf );
ipc_command_exec( NULL, cmd, ipc_master_commands );
@@ -360,7 +366,10 @@ void ipc_to_children_str( char *format, ... )
}
else if( global.conf->runmode == RUNMODE_DAEMON )
{
- char **cmd;
+ char **cmd, *s;
+
+ if( ( s = strchr( msg_buf, '\r' ) ) )
+ *s = 0;
cmd = irc_parse_line( msg_buf );
ipc_to_children( cmd );
diff --git a/irc.c b/irc.c
index aedbbc83..2f2937cc 100644
--- a/irc.c
+++ b/irc.c
@@ -187,6 +187,8 @@ void irc_free(irc_t * irc)
if( storage_save( irc, TRUE ) != STORAGE_OK )
irc_usermsg( irc, "Error while saving settings!" );
+ closesocket( irc->fd );
+
if( irc->ping_source_id > 0 )
g_source_remove( irc->ping_source_id );
g_source_remove( irc->r_watch_source_id );
@@ -693,7 +695,7 @@ void irc_login( irc_t *irc )
irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQ's are answered there." );
- if( global.conf->runmode == RUNMODE_FORKDAEMON )
+ if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )
ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname );
irc->status = USTATUS_LOGGED_IN;
diff --git a/irc.h b/irc.h
index 093de7c9..309f79e6 100644
--- a/irc.h
+++ b/irc.h
@@ -40,11 +40,11 @@
typedef enum
{
- USTATUS_OFFLINE,
+ USTATUS_OFFLINE = 0,
USTATUS_AUTHORIZED,
USTATUS_LOGGED_IN,
USTATUS_IDENTIFIED,
- USTATUS_SHUTDOWN
+ USTATUS_SHUTDOWN = -1
} irc_status_t;
typedef struct channel