[CLEANUP] various cleanups

This commit is contained in:
Arnaud Cornet 2009-01-17 15:03:06 +01:00
parent fe251f72b5
commit 9882a0cbdc
4 changed files with 18 additions and 11 deletions

View File

@ -830,6 +830,7 @@ static int validate_config(bip_t *bip)
user->name, link->name); user->name, link->name);
link_kill(bip, link); link_kill(bip, link);
r = 0; r = 0;
continue;
} }
} }
@ -842,7 +843,8 @@ static int validate_config(bip_t *bip)
"%s: channel must have" "%s: channel must have"
"a name.", user->name, "a name.", user->name,
link->name); link->name);
return 0; r = 0;
continue;
} }
} }
} }
@ -853,7 +855,8 @@ static int validate_config(bip_t *bip)
"lines to a non-nul value for each user with" "lines to a non-nul value for each user with"
"backlog = true. Faulty user is %s", "backlog = true. Faulty user is %s",
user->name); user->name);
return 0; r = 0;
continue;
} }
} }
@ -907,8 +910,8 @@ void sweep(bip_t *bip)
if (!l->in_use) { if (!l->in_use) {
mylog(LOG_INFO, "Administratively killing %s/%s", mylog(LOG_INFO, "Administratively killing %s/%s",
l->user->name, l->name); l->user->name, l->name);
link_kill(bip, l);
list_remove_if_exists(&bip->conn_list, l); list_remove_if_exists(&bip->conn_list, l);
link_kill(bip, l);
list_it_remove(&lit); list_it_remove(&lit);
} }
} }

View File

@ -822,8 +822,11 @@ list_t *wait_event(list_t *cn_list, int *msec, int *nc)
/* if no connection is active, return the list... empty... */ /* if no connection is active, return the list... empty... */
if (maxfd == -1) { if (maxfd == -1) {
usleep(*msec * 1000); struct timespec req, rem;
*msec = 0; req.tv_sec = *msec * 1000;
req.tv_nsec = 0;
nanosleep(&req, &rem);
*msec = rem.tv_sec;
return cn_newdata; return cn_newdata;
} }

View File

@ -1001,7 +1001,7 @@ static int irc_cli_join(struct link_client *irc, struct line *line)
if (irc_line_count(line) != 2 && irc_line_count(line) != 3) if (irc_line_count(line) != 2 && irc_line_count(line) != 3)
return ERR_PROTOCOL; return ERR_PROTOCOL;
const char *s, *e, *ks, *ke = 0; const char *s, *e, *ks, *ke = NULL;
s = irc_line_elem(line, 1); s = irc_line_elem(line, 1);
if (irc_line_count(line) == 3) if (irc_line_count(line) == 3)
ks = irc_line_elem(line, 2); ks = irc_line_elem(line, 2);

View File

@ -191,17 +191,17 @@ void log_reset(logstore_t *store)
return; return;
} }
while ((olf = list_get_first(&store->file_group)) != while ((olf = list_get_first(&store->file_group)) &&
list_get_last(&store->file_group)) { olf != list_get_last(&store->file_group)) {
logfile_free(olf); logfile_free(olf);
list_remove_first(&store->file_group); list_remove_first(&store->file_group);
} }
if (olf) assert(olf);
list_it_init_last(&store->file_group, &store->file_it);
assert(olf->file); assert(olf->file);
list_it_init_last(&store->file_group, &store->file_it);
fseek(olf->file, 0, SEEK_END); fseek(olf->file, 0, SEEK_END);
olf->len = ftell(olf->file); olf->len = ftell(olf->file);
store->file_offset = olf->len; store->file_offset = olf->len;
@ -275,6 +275,7 @@ static int log_add_file(log_t *logdata, const char *destination,
mylog(LOG_ERROR, "fseek(%s) %s", uniq_fname, mylog(LOG_ERROR, "fseek(%s) %s", uniq_fname,
strerror(errno)); strerror(errno));
free(uniq_fname); free(uniq_fname);
fclose(f);
return 0; return 0;
} }