diff --git a/src/bip.c b/src/bip.c index 5a52e00..5ded1ba 100644 --- a/src/bip.c +++ b/src/bip.c @@ -830,6 +830,7 @@ static int validate_config(bip_t *bip) user->name, link->name); link_kill(bip, link); r = 0; + continue; } } @@ -842,7 +843,8 @@ static int validate_config(bip_t *bip) "%s: channel must have" "a name.", user->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" "backlog = true. Faulty user is %s", user->name); - return 0; + r = 0; + continue; } } @@ -907,8 +910,8 @@ void sweep(bip_t *bip) if (!l->in_use) { mylog(LOG_INFO, "Administratively killing %s/%s", l->user->name, l->name); - link_kill(bip, l); list_remove_if_exists(&bip->conn_list, l); + link_kill(bip, l); list_it_remove(&lit); } } diff --git a/src/connection.c b/src/connection.c index bfdec8b..c1e2e13 100644 --- a/src/connection.c +++ b/src/connection.c @@ -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 (maxfd == -1) { - usleep(*msec * 1000); - *msec = 0; + struct timespec req, rem; + req.tv_sec = *msec * 1000; + req.tv_nsec = 0; + nanosleep(&req, &rem); + *msec = rem.tv_sec; return cn_newdata; } diff --git a/src/irc.c b/src/irc.c index cf587e1..d06ce58 100644 --- a/src/irc.c +++ b/src/irc.c @@ -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) return ERR_PROTOCOL; - const char *s, *e, *ks, *ke = 0; + const char *s, *e, *ks, *ke = NULL; s = irc_line_elem(line, 1); if (irc_line_count(line) == 3) ks = irc_line_elem(line, 2); diff --git a/src/log.c b/src/log.c index 528e9bc..65288dd 100644 --- a/src/log.c +++ b/src/log.c @@ -191,17 +191,17 @@ void log_reset(logstore_t *store) return; } - while ((olf = list_get_first(&store->file_group)) != - list_get_last(&store->file_group)) { + while ((olf = list_get_first(&store->file_group)) && + olf != list_get_last(&store->file_group)) { logfile_free(olf); list_remove_first(&store->file_group); } - if (olf) - list_it_init_last(&store->file_group, &store->file_it); - + assert(olf); assert(olf->file); + list_it_init_last(&store->file_group, &store->file_it); + fseek(olf->file, 0, SEEK_END); olf->len = ftell(olf->file); 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, strerror(errno)); free(uniq_fname); + fclose(f); return 0; }