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
23
src/bip.c
23
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:
|
||||||
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;
|
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;
|
||||||
|
@ -542,9 +551,9 @@ static int add_user(bip_t *bip, list_t *data)
|
||||||
case LEX_NAME:
|
case LEX_NAME:
|
||||||
MOVE_STRING(u->name, t->pdata);
|
MOVE_STRING(u->name, t->pdata);
|
||||||
break;
|
break;
|
||||||
case LEX_ADMIN:
|
case LEX_ADMIN:
|
||||||
u->admin = t->ndata;
|
u->admin = t->ndata;
|
||||||
break;
|
break;
|
||||||
case LEX_PASSWORD:
|
case LEX_PASSWORD:
|
||||||
hash_binary(t->pdata, &u->password, &u->seed);
|
hash_binary(t->pdata, &u->password, &u->seed);
|
||||||
free(t->pdata);
|
free(t->pdata);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
11
src/irc.c
11
src/irc.c
|
@ -2385,9 +2385,12 @@ 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,
|
||||||
list_add_first(&bip->conn_list, bip->listener);
|
* and conn_list is kept accross reloads.
|
||||||
|
*/
|
||||||
|
if (list_is_empty(&bip->conn_list))
|
||||||
|
list_add_first(&bip->conn_list, bip->listener);
|
||||||
|
|
||||||
while (!sighup) {
|
while (!sighup) {
|
||||||
connection_t *conn;
|
connection_t *conn;
|
||||||
|
@ -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