Commit 4ce6f129 authored by Jan Včelák's avatar Jan Včelák 🚀

server code: migrate to new logging API

parent d8e2ed5a
......@@ -497,8 +497,8 @@ int log_reconfigure(const struct conf_t *conf, void *data)
if (facility == LOGT_FILE) {
facility = log_open_file(log, facility_conf->file);
if (facility < 0) {
log_server_error("Failed to open logfile '%s'.\n",
facility_conf->file);
log_error("Failed to open logfile '%s'\n",
facility_conf->file);
continue;
}
}
......
......@@ -84,8 +84,8 @@ static void cf_print_error(void *scanner, const char *msg)
filename = new_config->filename;
}
log_server_error("Config error in '%s' (line %d token '%s') - %s\n",
filename, lineno, text, msg);
log_error("Config error in '%s' (line %d token '%s'): %s\n",
filename, lineno, text, msg);
_parser_res = KNOT_EPARSEFAIL;
}
......@@ -225,8 +225,8 @@ static int conf_process(conf_t *conf)
/* Check for ACL existence. */
if (!EMPTY_LIST(conf->ctl.allow)) {
log_server_warning("Control 'allow' statement "
"does not affect UNIX sockets.\n");
log_warning("Control 'allow' statement does not "
"affect UNIX sockets\n");
}
} else if (sockaddr_port(&ctl_if->addr) <= 0) {
sockaddr_port_set(&ctl_if->addr, REMOTE_DPORT);
......@@ -363,10 +363,9 @@ static int conf_process(conf_t *conf)
if (!EMPTY_LIST(zone->acl.notify_in) ||
!EMPTY_LIST(zone->acl.xfr_in)
) {
log_server_warning("Automatic DNSSEC signing "
"for zone '%s', disabling "
"incoming XFRs.\n",
zone->name);
log_zone_str_warning(zone->name, "Automatic "
"DNSSEC signing enabled, disabling "
"incoming XFRs\n");
WALK_LIST_FREE(zone->acl.notify_in);
WALK_LIST_FREE(zone->acl.xfr_in);
......@@ -394,14 +393,12 @@ static int conf_process(conf_t *conf)
/* Check paths existence. */
if (!is_existing_dir(zone->storage)) {
log_server_error("Storage dir '%s' does not exist.\n",
zone->storage);
log_error("Storage dir '%s' does not exist\n", zone->storage);
ret = KNOT_EINVAL;
continue;
}
if (zone->dnssec_enable && !is_existing_dir(zone->dnssec_keydir)) {
log_server_error("DNSSEC key dir '%s' does not exist.\n",
zone->dnssec_keydir);
log_error("DNSSEC key dir '%s' does not exist\n", zone->dnssec_keydir);
ret = KNOT_EINVAL;
continue;
......@@ -821,7 +818,8 @@ char* strcpath(char *path)
char* remainder = strchr(path,'~');
if (remainder != NULL) {
if (remainder[1] != '/') {
log_server_warning("Cannot expand non-login user home directory '%s', use full path instead", path);
log_warning("Cannot expand non-login user home"
"directory '%s', use full path instead", path);
}
// Get full path
......
......@@ -183,16 +183,14 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
/* Check remote address. */
conf_iface_t *r = conf()->ctl.iface;
if (!r || r->addr.ss_family == AF_UNSPEC) {
log_server_error("No remote address for '%s' configured.\n",
cmd);
log_error("No remote address for '%s' configured.\n", cmd);
return 1;
}
/* Make query. */
knot_pkt_t *pkt = remote_query(cmd, r->key);
if (!pkt) {
log_server_warning("Could not prepare query for '%s'.\n",
cmd);
log_warning("Could not prepare query for '%s'.\n", cmd);
return 1;
}
......@@ -202,7 +200,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
knot_rrset_t rr;
int res = remote_build_rr(&rr, "data.", rrt);
if (res != KNOT_EOK) {
log_server_error("Couldn't create the query.\n");
log_error("Couldn't create the query.\n");
knot_pkt_free(&pkt);
return 1;
}
......@@ -219,7 +217,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
}
res = knot_pkt_put(pkt, 0, &rr, KNOT_PF_FREE);
if (res != KNOT_EOK) {
log_server_error("Couldn't create the query.\n");
log_error("Couldn't create the query.\n");
knot_rrset_clear(&rr, NULL);
knot_pkt_free(&pkt);
return 1;
......@@ -229,7 +227,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
if (r->key) {
int res = remote_query_sign(pkt->wire, &pkt->size, pkt->max_size, r->key);
if (res != KNOT_EOK) {
log_server_error("Couldn't sign the packet.\n");
log_error("Couldn't sign the packet.\n");
knot_pkt_free(&pkt);
return 1;
}
......@@ -243,7 +241,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
int s = net_connected_socket(SOCK_STREAM, &r->addr, &r->via, 0);
if (s < 0) {
log_server_error("Couldn't connect to remote host '%s'.\n", addr_str);
log_error("Couldn't connect to remote host '%s'.\n", addr_str);
knot_pkt_free(&pkt);
return 1;
}
......@@ -251,7 +249,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
/* Wait for availability. */
struct pollfd pfd = { s, POLLOUT, 0 };
if (poll(&pfd, 1, conf()->max_conn_reply) != 1) {
log_server_error("Couldn't connect to remote host '%s'.\n", addr_str);
log_error("Couldn't connect to remote host '%s'.\n", addr_str);
close(s);
knot_pkt_free(&pkt);
return 1;
......@@ -263,7 +261,7 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
/* Evaluate and wait for reply. */
if (ret <= 0) {
log_server_error("Couldn't connect to remote host '%s'.\n", addr_str);
log_error("Couldn't connect to remote host '%s'.\n", addr_str);
close(s);
return 1;
}
......@@ -274,8 +272,8 @@ static int cmd_remote(const char *cmd, uint16_t rrt, int argc, char *argv[])
ret = cmd_remote_reply(s);
if (ret != KNOT_EOK) {
if (ret != KNOT_ECONN) {
log_server_warning("Remote command reply: %s\n",
knot_strerror(ret));
log_warning("Remote command reply: %s\n",
knot_strerror(ret));
rc = 1;
}
break;
......@@ -375,7 +373,7 @@ static int tsig_parse_file(knot_tsig_key_t *k, const char *f)
{
FILE* fp = fopen(f, "r");
if (!fp) {
log_server_error("Couldn't open key-file '%s'.\n", f);
log_error("Couldn't open key-file '%s'.\n", f);
return KNOT_EINVAL;
}
......@@ -395,9 +393,8 @@ static int tsig_parse_file(knot_tsig_key_t *k, const char *f)
}
if (c == '\n') {
if (k->name) {
log_server_error("Only 1 key definition "
"allowed in '%s'.\n",
f);
log_error("Only one key definition allowed "
"in '%s'.\n", f);
ret = KNOT_EMALF;
break;
}
......@@ -458,16 +455,14 @@ int main(int argc, char **argv)
case 'y':
if (tsig_parse_str(&r_key, optarg) != KNOT_EOK) {
rc = 1;
log_server_error("Couldn't parse TSIG key '%s' "
"\n", optarg);
log_error("Couldn't parse TSIG key '%s'\n", optarg);
goto exit;
}
break;
case 'k':
if (tsig_parse_file(&r_key, optarg) != KNOT_EOK) {
rc = 1;
log_server_error("Couldn't parse TSIG key file "
"'%s'\n", optarg);
log_error("Couldn't parse TSIG key file '%s'\n", optarg);
goto exit;
}
break;
......@@ -517,7 +512,7 @@ int main(int argc, char **argv)
/* Command not found. */
if (!cmd->name) {
log_server_error("Invalid command: '%s'\n", argv[optind]);
log_error("Invalid command: '%s'\n", argv[optind]);
rc = 1;
goto exit;
}
......@@ -530,8 +525,7 @@ int main(int argc, char **argv)
/* Check if config file is required. */
if (has_flag(flags, F_NOCONF) && cmd->need_conf) {
log_server_error("Couldn't find a config file, refusing to "
"continue.\n");
log_error("Couldn't find a config file, refusing to continue\n");
rc = 1;
goto exit;
}
......@@ -660,7 +654,7 @@ static int cmd_checkconf(int argc, char *argv[], unsigned flags)
UNUSED(argv);
UNUSED(flags);
log_server_info("OK, configuration is valid.\n");
log_info("OK, configuration is valid\n");
return 0;
}
......@@ -708,7 +702,7 @@ static int cmd_checkzone(int argc, char *argv[], unsigned flags)
continue;
}
log_zone_info("Zone '%s' OK.\n", zone->name);
log_zone_str_info(zone->name, "Zone is OK\n");
zone_contents_deep_free(&loaded_zone);
}
hattrie_iter_free(z_iter);
......@@ -765,7 +759,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
.htable_size = 0, .rdata_size = 0,
.record_count = 0 };
if (est.node_table == NULL) {
log_server_error("Not enough memory.\n");
log_error("Not enough memory\n");
continue;
}
......@@ -777,7 +771,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
&est);
if (loader == NULL) {
rc = 1;
log_zone_error("Could not load zone %s\n", zone->name);
log_zone_str_error(zone->name, "Could not load zone\n");
hattrie_free(est.node_table);
continue;
}
......@@ -786,7 +780,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
int ret = zs_loader_process(loader);
if (ret != KNOT_EOK) {
rc = 1;
log_zone_error("Failed to parse zone %s.\n", zone->name);
log_zone_str_error(zone->name, "Failed to parse zone\n");
hattrie_apply_rev(est.node_table, estimator_free_trie_node, NULL);
hattrie_free(est.node_table);
zs_loader_free(loader);
......@@ -807,8 +801,8 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
est.htable_size +
malloc_size) * ESTIMATE_MAGIC) / (1024.0 * 1024.0);
log_zone_info("Zone %s: %zu RRs, used memory estimation is %zuMB.\n",
zone->name, est.record_count, (size_t)zone_size);
log_zone_str_info(zone->name, "%zu RRs, used memory estimation is %zuMB\n",
est.record_count, (size_t)zone_size);
zs_loader_free(loader);
total_size += zone_size;
conf_free_zone(zone);
......@@ -816,7 +810,7 @@ static int cmd_memstats(int argc, char *argv[], unsigned flags)
hattrie_iter_free(z_iter);
if (rc == 0 && argc == 0) { // for all zones
log_zone_info("Estimated memory consumption for all zones is %zuMB.\n", (size_t)total_size);
log_info("Estimated memory consumption for all zones is %zuMB\n", (size_t)total_size);
}
return rc;
......
......@@ -139,21 +139,18 @@ int proc_update_privileges(int uid, int gid)
/* Drop supplementary groups. */
if ((uid_t)uid != getuid() || (gid_t)gid != getgid()) {
if (setgroups(0, NULL) < 0) {
log_server_warning("Failed to drop supplementary groups"
" for uid '%d' (%s).\n",
getuid(), strerror(errno));
log_warning("Failed to drop supplementary groups for "
"uid '%d': %s\n", getuid(), strerror(errno));
}
# ifdef HAVE_INITGROUPS
struct passwd *pw;
if ((pw = getpwuid(uid)) == NULL) {
log_server_warning("Failed to get passwd entry"
" for uid '%d' (%s).\n",
uid, strerror(errno));
log_warning("Failed to get passwd entry for uid '%d': %s\n",
uid, strerror(errno));
} else {
if (initgroups(pw->pw_name, gid) < 0) {
log_server_warning("Failed to set supplementary groups"
" for uid '%d' (%s).\n",
uid, strerror(errno));
log_warning("Failed to set supplementary groups "
"for uid '%d': %s\n", uid, strerror(errno));
}
}
# endif /* HAVE_INITGROUPS */
......@@ -162,17 +159,15 @@ int proc_update_privileges(int uid, int gid)
/* Watch uid/gid. */
if ((gid_t)gid != getgid()) {
log_server_info("Changing group id to '%d'.\n", gid);
log_info("Changing GID to '%d'\n", gid);
if (setregid(gid, gid) < 0) {
log_server_error("Failed to change gid to '%d'.\n",
gid);
log_error("Failed to change GID to '%d'\n", gid);
}
}
if ((uid_t)uid != getuid()) {
log_server_info("Changing user id to '%d'.\n", uid);
log_info("Changing UID to '%d'.\n", uid);
if (setreuid(uid, uid) < 0) {
log_server_error("Failed to change uid to '%d'.\n",
uid);
log_error("Failed to change UID to '%d'\n", uid);
}
}
......@@ -189,8 +184,8 @@ int proc_update_privileges(int uid, int gid)
assert(lfile != NULL);
FILE* fp = fopen(lfile, "w");
if (fp == NULL) {
log_server_warning("Storage directory '%s' is not "
"writeable.\n", zone->storage);
log_warning("Storage directory '%s' is not writable\n",
zone->storage);
ret = KNOT_EACCES;
} else {
fclose(fp);
......@@ -215,18 +210,18 @@ char *pid_check_and_create()
/* Check PID for existence and liveness. */
if (pid > 0 && pid_running(pid)) {
log_server_error("Server PID found, already running.\n");
log_error("Server PID found, already running\n");
free(pidfile);
return NULL;
} else if (stat(pidfile, &st) == 0) {
log_server_warning("Removing stale PID file '%s'.\n", pidfile);
log_warning("Removing stale PID file '%s'\n", pidfile);
pid_remove(pidfile);
}
/* Create a PID file. */
int ret = pid_write(pidfile);
if (ret != KNOT_EOK) {
log_server_error("Couldn't create a PID file '%s'.\n", pidfile);
log_error("Couldn't create a PID file '%s'\n", pidfile);
free(pidfile);
return NULL;
}
......
......@@ -411,7 +411,7 @@ int remote_bind(conf_iface_t *desc)
char addr_str[SOCKADDR_STRLEN] = {0};
sockaddr_tostr(&desc->addr, addr_str, sizeof(addr_str));
log_server_info("Binding remote control interface to '%s'.\n", addr_str);
log_info("Binding remote control interface to '%s'\n", addr_str);
/* Create new socket. */
mode_t old_umask = umask(KNOT_CTL_SOCKET_UMASK);
......@@ -424,7 +424,7 @@ int remote_bind(conf_iface_t *desc)
/* Start listening. */
int ret = listen(sock, TCP_BACKLOG_SIZE);
if (ret < 0) {
log_server_error("Could not bind to '%s'.\n", addr_str);
log_error("Could not bind to '%s'\n", addr_str);
close(sock);
return ret;
}
......@@ -563,7 +563,7 @@ static void log_command(const char *cmd, const remote_cmdargs_t* args)
}
}
log_server_info("Remote command: '%s%s'\n", cmd, params);
log_info("Remote command: '%s%s'\n", cmd, params);
}
int remote_answer(int sock, server_t *s, knot_pkt_t *pkt)
......@@ -657,7 +657,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
assert(tsig_rcode != NULL);
if (query->tsig_rr == NULL) {
log_server_info("TSIG key required, but not in query - REFUSED.\n");
log_info("TSIG: key required, query REFUSED\n");
*rcode = KNOT_RCODE_REFUSED;
return KNOT_TSIG_EBADKEY;
}
......@@ -667,8 +667,7 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
*/
knot_tsig_algorithm_t alg = tsig_rdata_alg(query->tsig_rr);
if (knot_tsig_digest_length(alg) == 0) {
log_server_info("Unsupported digest algorithm "
"requested, treating as bad key\n");
log_info("TSIG: unsupported algorithm, query NOTAUTH\n");
/*! \todo [TSIG] It is unclear from RFC if I
* should treat is as a bad key
* or some other error.
......@@ -711,8 +710,8 @@ static int zones_verify_tsig_query(const knot_pkt_t *query,
if (mac_len > digest_max_size) {
*rcode = KNOT_RCODE_FORMERR;
log_server_info("MAC length %zu exceeds digest "
"maximum size %zu\n", mac_len, digest_max_size);
log_info("TSIG: MAC length %zu exceeds maximum size %zu\n",
mac_len, digest_max_size);
return KNOT_EMALF;
} else {
//memcpy(digest, mac, mac_len);
......@@ -790,9 +789,8 @@ int remote_process(server_t *s, conf_iface_t *ctl_if, int sock,
uint16_t ts_trc = 0;
uint64_t ts_tmsigned = 0;
if (match == NULL) {
log_server_warning("Denied remote control for '%s' "
"(doesn't match ACL).\n",
addr_str);
log_warning("Denied remote control for '%s', "
"no matching ACL\n", addr_str);
remote_senderr(client, pkt->wire, pkt->size);
ret = KNOT_EACCES;
goto finish;
......@@ -803,9 +801,8 @@ int remote_process(server_t *s, conf_iface_t *ctl_if, int sock,
/* Check TSIG. */
if (tsig_key) {
if (pkt->tsig_rr == NULL) {
log_server_warning("Denied remote control for '%s' "
"(key required).\n",
addr_str);
log_warning("Denied remote control for '%s', "
"key required\n", addr_str);
remote_senderr(client, pkt->wire, pkt->size);
ret = KNOT_EACCES;
goto finish;
......@@ -813,9 +810,8 @@ int remote_process(server_t *s, conf_iface_t *ctl_if, int sock,
ret = zones_verify_tsig_query(pkt, tsig_key, &ts_rc,
&ts_trc, &ts_tmsigned);
if (ret != KNOT_EOK) {
log_server_warning("Denied remote control for '%s' "
"(key verification failed).\n",
addr_str);
log_warning("Denied remote control for '%s', "
"key verification failed\n", addr_str);
remote_senderr(client, pkt->wire, pkt->size);
ret = KNOT_EACCES;
goto finish;
......
......@@ -62,7 +62,7 @@ static void knot_crypto_deinit(void)
static void pid_cleanup(char *pidfile)
{
if (pidfile && pid_remove(pidfile) < 0) {
log_server_warning("Failed to remove PID file.\n");
log_warning("Failed to remove PID file\n");
}
}
......@@ -114,12 +114,12 @@ static void setup_capabilities(void)
/* Apply. */
if (capng_apply(CAPNG_SELECT_BOTH) < 0) {
log_server_error("Couldn't set process capabilities - "
"%s.\n", strerror(errno));
log_error("Couldn't set process capabilities: %s\n",
strerror(errno));
}
} else {
log_server_info("User uid=%d is not allowed to set "
"capabilities, skipping.\n", getuid());
log_info("User UID %d is not allowed to set capabilities, "
"skipping.\n", getuid());
}
#endif /* HAVE_CAP_NG_H */
}
......@@ -267,8 +267,8 @@ int main(int argc, char **argv)
int res = conf_open(config_fn);
conf_t *config = conf();
if (res != KNOT_EOK) {
log_server_fatal("Couldn't load configuration '%s': %s\n",
config_fn, knot_strerror(res));
log_fatal("Couldn't load configuration '%s': %s\n",
config_fn, knot_strerror(res));
return EXIT_FAILURE;
}
......@@ -281,8 +281,7 @@ int main(int argc, char **argv)
server_t server;
res = server_init(&server, conf_bg_threads(config));
if (res != KNOT_EOK) {
log_server_fatal("Could not initialize server: %s\n",
knot_strerror(res));
log_fatal("Could not initialize server: %s\n", knot_strerror(res));
conf_free(conf());
log_close();
return EXIT_FAILURE;
......@@ -292,8 +291,8 @@ int main(int argc, char **argv)
* @note This MUST be done before we drop privileges. */
server_reconfigure(config, &server);
conf_add_hook(config, CONF_ALL, server_reconfigure, &server);
log_server_info("Configured %zu interfaces and %zu zones.\n",
list_size(&config->ifaces), hattrie_weight(config->zones));
log_info("Configured %zu interfaces and %zu zones\n",
list_size(&config->ifaces), hattrie_weight(config->zones));
/* Alter privileges. */
......@@ -317,13 +316,12 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
log_server_info("PID stored in '%s'\n", pidfile);
log_info("PID stored in '%s'\n", pidfile);
if (chdir(daemon_root) != 0) {
log_server_warning("Can't change working directory to %s.\n",
daemon_root);
log_warning("Can't change working directory to %s\n",
daemon_root);
} else {
log_server_info("Changed directory to %s.\n",
daemon_root);
log_info("Changed directory to %s.\n", daemon_root);
}
}
......@@ -338,21 +336,20 @@ int main(int argc, char **argv)
rcu_register_thread();
/* Populate zone database and add reconfiguration hook. */
log_server_info("Loading zones...\n");
log_info("Loading zones\n");
server_update_zones(config, &server);
conf_add_hook(config, CONF_ALL, server_update_zones, &server);
/* Check number of loaded zones. */
if (knot_zonedb_size(server.zone_db) == 0) {
log_server_warning("No zones loaded.\n");
log_warning("No zones loaded\n");
}
/* Start it up. */
log_server_info("Starting server...\n");
log_info("Starting server\n");
res = server_start(&server, config->async_start);
if (res != KNOT_EOK) {
log_server_fatal("Failed to start server: %s.\n",
knot_strerror(res));
log_fatal("Failed to start server: %s\n", knot_strerror(res));
server_deinit(&server);
rcu_unregister_thread();
pid_cleanup(pidfile);
......@@ -362,9 +359,9 @@ int main(int argc, char **argv)
}
if (daemonize) {
log_server_info("Server started as a daemon, PID = %ld\n", pid);
log_info("Server started as a daemon, PID %ld\n", pid);
} else {
log_server_info("Server started in foreground, PID = %ld\n", pid);
log_info("Server started in foreground, PID %ld\n", pid);
init_signal_started();
}
......@@ -384,7 +381,7 @@ int main(int argc, char **argv)
/* Cleanup PID file. */
pid_cleanup(pidfile);
log_server_info("Shut down.\n");
log_info("Shutting down\n");
log_close();
return EXIT_SUCCESS;
......
......@@ -57,8 +57,8 @@ int net_unbound_socket(int type, const struct sockaddr_storage *ss)
/* Create socket. */
int socket = socket_create(ss->ss_family, type, 0);
if (socket < 0) {
log_server_error("Could not create socket for '%s': %s\n",
addr_str, knot_strerror(socket));
log_error("Could not create socket for '%s': %s\n",
addr_str, knot_strerror(socket));
return socket;
}
......@@ -96,8 +96,8 @@ int net_bound_socket(int type, const struct sockaddr_storage *ss)
int ret = bind(socket, (const struct sockaddr *)ss, sockaddr_len(ss));
if (ret < 0) {
ret = knot_map_errno(EADDRINUSE, EINVAL, EACCES, ENOMEM);
log_server_error("Cannot bind to address '%s': %s\n",
addr_str, knot_strerror(ret));
log_error("Cannot bind to address '%s': %s\n",
addr_str, knot_strerror(ret));
close(socket);
return ret;
}
......
......@@ -286,8 +286,8 @@ static void rrl_log_state(const struct sockaddr_storage *ss, uint16_t flags, uin
what = "enters";
}
log_server_notice("Address '%s' %s rate-limiting (class '%s').\n",
addr_str, what, rrl_clsstr(cls));
log_notice("Address '%s' %s rate-limiting (class '%s')\n",
addr_str, what, rrl_clsstr(cls));
#endif
}
......
......@@ -142,7 +142,7 @@ static int server_init_iface(iface_t *new_if, conf_iface_t *cfg_if)
if (ret < 0) {
close(new_if->fd[IO_UDP]);
close(new_if->fd[IO_TCP]);
log_server_error("Failed to listen on TCP interface '%s'.\n", addr_str);
log_error("Failed to listen on TCP interface '%s'\n", addr_str);
return KNOT_ERROR;
}
......@@ -150,7 +150,7 @@ static int server_init_iface(iface_t *new_if, conf_iface_t *cfg_if)
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
close(new_if->fd[IO_UDP]);
close(new_if->fd[IO_TCP]);
log_server_error("Failed to listen on '%s' in non-blocking mode.\n", addr_str);
log_error("Failed to listen on '%s' in non-blocking mode\n", addr_str);
return KNOT_ERROR;
}
......@@ -166,7 +166,7 @@ static void remove_ifacelist(struct ref_t *p)
iface_t *n = NULL, *m = NULL;
WALK_LIST_DELSAFE(n, m, ifaces->u) {
sockaddr_tostr(&n->addr, addr_str, sizeof(addr_str));
log_server_info("Removing interface '%s'.\n", addr_str);
log_info("Removing interface '%s'\n", addr_str);
server_remove_iface(n);
}
WALK_LIST_DELSAFE(n, m, ifaces->l) {
......@@ -223,7 +223,7 @@ static int reconfigure_sockets(const struct conf_t *conf, server_t *s)
rem_node((node_t *)m);
} else {
sockaddr_tostr(&cfg_if->addr, addr_str, sizeof(addr_str));
log_server_info("Binding to interface %s.\n", addr_str);
log_info("Binding to interface %s\n", addr_str);
/* Create new interface. */
m = malloc(sizeof(iface_t));
......@@ -439,22 +439,17 @@ int server_reload(server_t *server, const char *cf)
return KNOT_EINVAL;
}
log_server_info("Reloading configuration...\n");
log_info("Reloading configuration\n");
int cf_ret = conf_open(cf);
switch (cf_ret) {
case KNOT_EOK:
log_server_info("Configuration "
"reloaded.\n");
log_info("Configuration reloaded\n");
break;
case KNOT_ENOENT:
log_server_error("Configuration "
"file '%s' "
"not found.\n",
conf()->filename);
log_error("Configuration file '%s' not found\n", conf()->filename);
break;
default:
log_server_error("Configuration "
"reload failed.\n");
log_error("Configuration reload failed\n");
break;
}
......@@ -464,7 +459,7 @@ int server_reload(server_t *server, const char *cf)
void server_stop(server_t *server)
{
log_server_info("Stopping server...\n");
log_info("Stopping server\n");
/* Send termination event. */
event_t *term_ev = evsched_event_create(&server->sched, NULL, NULL);
......@@ -496,8 +491,8 @@ static int reconfigure_threads(const struct conf_t *conf, server_t *server)
ret = server_init_handler(server, IO_UDP, conf_udp_threads(conf),
&udp_master, &udp_master_destruct);
if (ret != KNOT_EOK) {
log_server_error("Failed to create UDP threads: %s\n",
knot_strerror(ret));
log_error("Failed to create UDP threads: %s\n",
knot_strerror(ret));
return ret;
}
......@@ -506,8 +501,8 @@ static int reconfigure_threads(const struct conf_t *conf, server_t *server)
ret = server_init_handler(server, IO_TCP, conf_tcp_threads(conf),
&tcp_master, &tcp_master_destruct);
if (ret != KNOT_EOK) {
log_server_error("Failed to create TCP threads: %s\n",
knot_strerror(ret));
log_error("Failed to create TCP threads: %s\n",
knot_strerror(ret));
return ret;
}
......@@ -529,7 +524,7 @@ static int reconfigure_rate_limits(const struct conf_t *conf, server_t *server)
if (!server->rrl && conf->rrl > 0) {
server->rrl = rrl_create(conf->rrl_size);
if (!server->rrl) {
log_server_error("Couldn't init rate limiting table.\n");
log_error("Couldn't init rate limiting table\n");
} else {
rrl_setlocks(server->rrl, RRL_LOCK_GRANULARITY);
}
......@@ -539,10 +534,10 @@ static int reconfigure_rate_limits(const struct conf_t *conf, server_t *server)
/* We cannot free it, threads may use it.
* Setting it to <1 will disable rate limiting. */
if (conf->rrl < 1) {
log_server_info("Rate limiting disabled.\n");
log_info("Rate limiting disabled\n");
} else {
log_server_info("Rate limiting set to %u "
"responses/sec.\n", conf->rrl);
log_info("Rate limiting set to %u responses/sec\n",
conf->rrl);
}
rrl_setrate(server->rrl, conf->rrl);
......@@ -562,25 +557,25 @@ int server_reconfigure(const struct conf_t *conf, void *data)
/* First reconfiguration. */
if (!(server->state & ServerRunning)) {
log_server_info("Knot DNS %s starting.\n", PACKAGE_VERSION);
log_info("Knot DNS %s starting\n", PACKAGE_VERSION);
}
/* Reconfigure rate limits. */
int ret = KNOT_EOK;
if ((ret = reconfigure_rate_limits(conf, server)) < 0) {
log_server_error("Failed to reconfigure rate limits.\n");
log_error("Failed to reconfigure rate limits\n");
return ret;
}
/* Reconfigure server threads. */
if ((ret = reconfigure_threads(conf, server)) < 0) {
log_server_error("Failed to reconfigure server threads.\n");
log_error("Failed to reconfigure server threads\n");
return ret;
}
/* Update bound sockets. */
if ((ret = reconfigure_sockets(conf, server)) < 0) {
log_server_error("Failed to reconfigure server sockets.\n");
log_error("Failed to reconfigure server sockets\n");
return ret;
}
......