Fixes to get the /BIP RELOAD command to at least work in a quick test.

- reuse existing channel infos
- dont clear conn_list on end of irc_main and don't add the listener if
conn_list is not empty at start of irc_main
This commit is contained in:
Arnaud Cornet 2007-10-20 23:12:22 +02:00
parent 0a689b19f8
commit 32e47b900c
4 changed files with 25 additions and 14 deletions

View File

@ -414,7 +414,19 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
MOVE_STRING(l->vhost, t->pdata);
break;
case LEX_CHANNEL:
ci = calloc(sizeof(struct chan_info), 1);
name = get_tuple_value(t->pdata, LEX_NAME);
if (name == NULL) {
conf_die("Channel with no name");
return 0;
}
ci = hash_get(&l->chan_infos, name);
if (!ci) {
ci = calloc(sizeof(struct chan_info), 1);
hash_insert(&l->chan_infos, name, ci);
/* FIXME: this order is not reloaded */
list_add_last(&l->chan_infos_order, ci);
}
ci->backlog = 1;
while ((t2 = list_remove_first(t->pdata))) {
@ -431,9 +443,6 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
}
}
list_free(t->pdata);
hash_insert(&l->chan_infos, ci->name, ci);
list_add_last(&l->chan_infos_order, ci);
break;
case LEX_FOLLOW_NICK:
l->follow_nick = t->ndata;
@ -542,9 +551,9 @@ static int add_user(bip_t *bip, list_t *data)
case LEX_NAME:
MOVE_STRING(u->name, t->pdata);
break;
case LEX_ADMIN:
u->admin = t->ndata;
break;
case LEX_ADMIN:
u->admin = t->ndata;
break;
case LEX_PASSWORD:
hash_binary(t->pdata, &u->password, &u->seed);
free(t->pdata);

View File

@ -1011,8 +1011,10 @@ connection_t *accept_new(connection_t *cn)
mylog(LOG_DEBUG, "Trying to accept new client on %d", cn->handle);
err = accept(cn->handle, &sa, &sa_len);
if (err < 0)
if (err < 0) {
mylog(LOG_ERROR, "accept failed: %s", strerror(errno));
return NULL;
}
socket_set_nonblock(err);
conn = connection_init(cn->anti_flood, cn->ssl, cn->timeout, 0);

View File

@ -2385,9 +2385,12 @@ void irc_main(bip_t *bip)
{
int timeleft = 1000;
/* XXX: This one MUST be first */
/* TODO: maybe not anymore, check */
list_add_first(&bip->conn_list, bip->listener);
/*
* If the list is empty, we are starting. Otherwise we are reloading,
* and conn_list is kept accross reloads.
*/
if (list_is_empty(&bip->conn_list))
list_add_first(&bip->conn_list, bip->listener);
while (!sighup) {
connection_t *conn;
@ -2412,8 +2415,6 @@ void irc_main(bip_t *bip)
bip_on_event(bip, conn);
list_free(ready);
}
while (list_remove_first(&bip->conn_list))
;
while (list_remove_first(&bip->link_list))
;
while (list_remove_first(&bip->connecting_client_list))

View File

@ -625,4 +625,3 @@ int ischannel(char p)
{
return (p == '#' || p == '&' || p == '+' || p == '!');
}