Better handling of changes in the list of chatservers

This commit is contained in:
Michiel Broek 2005-12-17 19:31:06 +00:00
parent 42a5043091
commit 351e4bbac5
2 changed files with 81 additions and 74 deletions

View File

@ -2,6 +2,9 @@ $Id$
v0.83.5 16-Dec-2005
mbtask:
Better handling of changes in the list of chatservers.
v0.83.4 04-Dec-2005 - 16-Dec-2005

View File

@ -632,50 +632,21 @@ void check_servers(void)
if ((fp = fopen(scfgfn, "r"))) {
fread(&ibcsrvhdr, sizeof(ibcsrvhdr), 1, fp);
while (fread(&ibcsrv, ibcsrvhdr.recsize, 1, fp)) {
crc = 0xffffffff;
crc = upd_crc32((char *)&ibcsrv, crc, sizeof(ibcsrv));
/*
* Check for new configured servers
*/
if (ibcsrv.Active) {
inlist = FALSE;
for (tnsl = ncsl; tnsl; tnsl = tnsl->next) {
if (strcmp(tnsl->server, ibcsrv.server) == 0) {
inlist = TRUE;
}
}
for (srv = servers; srv; srv = srv->next) {
if ((strcmp(srv->server, ibcsrv.server) == 0) && (strcmp(srv->router, ibcsrv.server))) {
inlist = TRUE;
Syslog('+', "IBC: can't add new configured server %s: already connected via %s",
ibcsrv.server, srv->router);
}
}
if (!inlist ) {
fill_ncslist(&ncsl, ibcsrv.server, ibcsrv.myname, ibcsrv.passwd, ibcsrv.Dyndns, crc);
srvchg = TRUE;
callchg = TRUE;
Syslog('+', "IBC: new configured Internet BBS Chatserver: %s", ibcsrv.server);
}
}
}
/*
* Now check for neighbours to delete
* Check for neighbour servers to delete
*/
for (tnsl = ncsl; tnsl; tnsl = tnsl->next) {
fseek(fp, ibcsrvhdr.hdrsize, SEEK_SET);
inlist = FALSE;
while (fread(&ibcsrv, ibcsrvhdr.recsize, 1, fp)) {
if ((strcmp(tnsl->server, ibcsrv.server) == 0) && ibcsrv.Active) {
crc = 0xffffffff;
crc = upd_crc32((char *)&ibcsrv, crc, sizeof(ibcsrv));
if ((strcmp(tnsl->server, ibcsrv.server) == 0) && ibcsrv.Active && (tnsl->crc == crc)) {
inlist = TRUE;
}
}
if (!inlist) {
Syslog('+', "IBC: server %s removed from configuration", tnsl->server);
Syslog('+', "IBC: server %s configuration changed or removed", tnsl->server);
pthread_mutex_lock(&b_mutex);
tnsl->remove = TRUE;
tnsl->action = now;
@ -684,14 +655,10 @@ void check_servers(void)
callchg = TRUE;
}
}
fclose(fp);
}
scfg_time = file_time(scfgfn);
}
dump_ncslist();
/*
* Start removing servers
*/
Remove = FALSE;
for (tnsl = ncsl; tnsl; tnsl = tnsl->next) {
if (tnsl->remove) {
@ -712,7 +679,6 @@ void check_servers(void)
srvchg = TRUE;
}
}
dump_ncslist();
/*
@ -735,7 +701,46 @@ void check_servers(void)
}
pthread_mutex_unlock(&b_mutex);
}
dump_ncslist();
/*
* Changed or deleted servers are now removed, add new
* configured servers or changed servers.
*/
fseek(fp, ibcsrvhdr.hdrsize, SEEK_SET);
while (fread(&ibcsrv, ibcsrvhdr.recsize, 1, fp)) {
/*
* Check for new configured servers
*/
if (ibcsrv.Active) {
inlist = FALSE;
for (tnsl = ncsl; tnsl; tnsl = tnsl->next) {
if (strcmp(tnsl->server, ibcsrv.server) == 0) {
inlist = TRUE;
}
}
for (srv = servers; srv; srv = srv->next) {
if ((strcmp(srv->server, ibcsrv.server) == 0) && (strcmp(srv->router, ibcsrv.server))) {
inlist = TRUE;
Syslog('+', "IBC: can't add new configured server %s: already connected via %s",
ibcsrv.server, srv->router);
}
}
if (!inlist ) {
crc = 0xffffffff;
crc = upd_crc32((char *)&ibcsrv, crc, sizeof(ibcsrv));
fill_ncslist(&ncsl, ibcsrv.server, ibcsrv.myname, ibcsrv.passwd, ibcsrv.Dyndns, crc);
srvchg = TRUE;
callchg = TRUE;
Syslog('+', "IBC: new configured Internet BBS Chatserver: %s", ibcsrv.server);
}
}
}
fclose(fp);
}
scfg_time = file_time(scfgfn);
}
dump_ncslist();
/*
@ -843,7 +848,6 @@ void check_servers(void)
* In this state we check if the connection is still alive
*/
j = (int)now - (int)tnsl->last;
if (tnsl->halfdead > 5) {
/*
* Halfdead means 5 times received a PASS while we are in