diff options
-rw-r--r-- | bitlbee.c | 16 | ||||
-rw-r--r-- | irc.c | 15 |
2 files changed, 11 insertions, 20 deletions
@@ -49,12 +49,11 @@ int bitlbee_daemon_init() hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; - i = getaddrinfo( global.conf->iface, global.conf->port, &hints, - &addrinfo_bind ); + i = getaddrinfo( global.conf->iface, global.conf->port, &hints, &addrinfo_bind ); if( i ) { - log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s", - global.conf->iface, gai_strerror(i) ); + log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s", + global.conf->iface, gai_strerror(i) ); return -1; } @@ -62,15 +61,13 @@ int bitlbee_daemon_init() for( res = addrinfo_bind; res; res = res->ai_next ) { - global.listen_socket = socket( res->ai_family, res->ai_socktype, - res->ai_protocol ); + global.listen_socket = socket( res->ai_family, res->ai_socktype, res->ai_protocol ); if( global.listen_socket < 0 ) continue; /* TIME_WAIT (?) sucks.. */ i = 1; - setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, - sizeof( i ) ); + setsockopt( global.listen_socket, SOL_SOCKET, SO_REUSEADDR, &i, sizeof( i ) ); i = bind( global.listen_socket, res->ai_addr, res->ai_addrlen ); if( i == -1 ) @@ -118,8 +115,7 @@ int bitlbee_daemon_init() if( global.conf->runmode == RUNMODE_FORKDAEMON ) ipc_master_load_state(); - if( global.conf->runmode == RUNMODE_DAEMON || - global.conf->runmode == RUNMODE_FORKDAEMON ) + if( global.conf->runmode == RUNMODE_DAEMON || global.conf->runmode == RUNMODE_FORKDAEMON ) ipc_master_listen_socket(); if( ( fp = fopen( global.conf->pidfile, "w" ) ) ) @@ -77,11 +77,6 @@ irc_t *irc_new( int fd ) { irc->myhost = g_strdup( ipv6_unwrap( buf ) ); } - else - { - /* Rare, but possible. */ - strncpy( irc->myhost, "localhost.localdomain", NI_MAXHOST ); - } } if( getpeername( irc->fd, (struct sockaddr*) &sock, &socklen ) == 0 ) @@ -93,13 +88,13 @@ irc_t *irc_new( int fd ) { irc->host = g_strdup( ipv6_unwrap( buf ) ); } - else - { - /* Rare, but possible. */ - strncpy( irc->host, "localhost.localdomain", NI_MAXHOST ); - } } + if( irc->host == NULL ) + irc->host = g_strdup( "localhost.localdomain" ); + if( irc->myhost == NULL ) + irc->myhost = g_strdup( "localhost.localdomain" ); + if( global.conf->ping_interval > 0 && global.conf->ping_timeout > 0 ) irc->ping_source_id = b_timeout_add( global.conf->ping_interval * 1000, irc_userping, irc ); |