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:
parent
0a689b19f8
commit
32e47b900c
15
src/bip.c
15
src/bip.c
@ -414,7 +414,19 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
|
|||||||
MOVE_STRING(l->vhost, t->pdata);
|
MOVE_STRING(l->vhost, t->pdata);
|
||||||
break;
|
break;
|
||||||
case LEX_CHANNEL:
|
case LEX_CHANNEL:
|
||||||
|
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);
|
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;
|
ci->backlog = 1;
|
||||||
|
|
||||||
while ((t2 = list_remove_first(t->pdata))) {
|
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);
|
list_free(t->pdata);
|
||||||
|
|
||||||
hash_insert(&l->chan_infos, ci->name, ci);
|
|
||||||
list_add_last(&l->chan_infos_order, ci);
|
|
||||||
break;
|
break;
|
||||||
case LEX_FOLLOW_NICK:
|
case LEX_FOLLOW_NICK:
|
||||||
l->follow_nick = t->ndata;
|
l->follow_nick = t->ndata;
|
||||||
|
@ -1011,8 +1011,10 @@ connection_t *accept_new(connection_t *cn)
|
|||||||
|
|
||||||
mylog(LOG_DEBUG, "Trying to accept new client on %d", cn->handle);
|
mylog(LOG_DEBUG, "Trying to accept new client on %d", cn->handle);
|
||||||
err = accept(cn->handle, &sa, &sa_len);
|
err = accept(cn->handle, &sa, &sa_len);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
|
mylog(LOG_ERROR, "accept failed: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
socket_set_nonblock(err);
|
socket_set_nonblock(err);
|
||||||
|
|
||||||
conn = connection_init(cn->anti_flood, cn->ssl, cn->timeout, 0);
|
conn = connection_init(cn->anti_flood, cn->ssl, cn->timeout, 0);
|
||||||
|
@ -2385,8 +2385,11 @@ void irc_main(bip_t *bip)
|
|||||||
{
|
{
|
||||||
int timeleft = 1000;
|
int timeleft = 1000;
|
||||||
|
|
||||||
/* XXX: This one MUST be first */
|
/*
|
||||||
/* TODO: maybe not anymore, check */
|
* 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);
|
list_add_first(&bip->conn_list, bip->listener);
|
||||||
|
|
||||||
while (!sighup) {
|
while (!sighup) {
|
||||||
@ -2412,8 +2415,6 @@ void irc_main(bip_t *bip)
|
|||||||
bip_on_event(bip, conn);
|
bip_on_event(bip, conn);
|
||||||
list_free(ready);
|
list_free(ready);
|
||||||
}
|
}
|
||||||
while (list_remove_first(&bip->conn_list))
|
|
||||||
;
|
|
||||||
while (list_remove_first(&bip->link_list))
|
while (list_remove_first(&bip->link_list))
|
||||||
;
|
;
|
||||||
while (list_remove_first(&bip->connecting_client_list))
|
while (list_remove_first(&bip->connecting_client_list))
|
||||||
|
@ -625,4 +625,3 @@ int ischannel(char p)
|
|||||||
{
|
{
|
||||||
return (p == '#' || p == '&' || p == '+' || p == '!');
|
return (p == '#' || p == '&' || p == '+' || p == '!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user