summaryrefslogtreecommitdiff
path: root/announce.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-20 14:55:54 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-20 14:55:54 +0200
commit77f9be38d7469eefb0fac3adf43261b4d84315d2 (patch)
tree70c42ec4864e850e15b0c31b9493646ead42a05b /announce.c
parente11014c0443ea687ad65a14b9124aa366da7984a (diff)
Make logging messages consistent in adding a newline for all messages
Diffstat (limited to 'announce.c')
-rw-r--r--announce.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/announce.c b/announce.c
index ecb48af..dd93bec 100644
--- a/announce.c
+++ b/announce.c
@@ -21,7 +21,7 @@ mcast_free(struct uring_task *task)
{
struct announce *aev = container_of(task, struct announce, mcast_task);
- debug(DBG_ANN, "task %p, aev %p\n", task, aev);
+ debug(DBG_ANN, "task %p, aev %p", task, aev);
}
static void
@@ -30,12 +30,12 @@ mcast_sent(struct cfg *cfg, struct uring_task *task, int res)
struct server *server;
if (res < 0)
- error("failure %i\n", res);
+ error("failure %i", res);
else
- debug(DBG_ANN, "result %i\n", res);
+ debug(DBG_ANN, "result %i", res);
if (!task || !task->tbuf) {
- error("task or task->tbuf not set\n");
+ error("task or task->tbuf not set");
return;
}
@@ -56,7 +56,7 @@ mcast_send(struct cfg *cfg, struct announce *aev, struct server *server)
server->pretty_name, server->announce_port);
if (len < 1 || len >= sizeof(server->mcast_buf.buf)) {
- error("snprintf returned %i\n", len);
+ error("snprintf returned %i", len);
return;
}
@@ -72,7 +72,7 @@ mcast_send_all(struct cfg *cfg, struct announce *aev)
struct server *server;
list_for_each_entry(server, &cfg->servers, list) {
- verbose("Announcing server: %s\n", server->name);
+ verbose("Announcing server: %s", server->name);
mcast_send(cfg, aev, server);
}
}
@@ -84,10 +84,12 @@ announce_cb(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_ANN, task);
- if (res != sizeof(aev->value))
- perrordie("timerfd_read");
+ if (res != sizeof(aev->value)) {
+ error("timerfd_read: %m");
+ return;
+ }
- debug(DBG_ANN, "timerfd value %" PRIu64 "\n", aev->value);
+ debug(DBG_ANN, "timerfd value %" PRIu64, aev->value);
mcast_send_all(cfg, aev);
uring_read(cfg, &aev->task, &aev->value, sizeof(aev->value), announce_cb);
}
@@ -97,7 +99,7 @@ announce_free(struct uring_task *task)
{
struct announce *aev = container_of(task, struct announce, task);
- debug(DBG_ANN, "task %p, aev 0x%p\n", task, aev);
+ debug(DBG_ANN, "task %p, aev 0x%p", task, aev);
xfree(aev);
}
@@ -115,11 +117,11 @@ void
announce_delete(struct cfg *cfg)
{
if (!cfg->aev) {
- error("missing parameters\n");
+ error("missing parameters");
return;
}
- debug(DBG_ANN, "closing fd %i\n", cfg->aev->task.fd);
+ debug(DBG_ANN, "closing fd %i", cfg->aev->task.fd);
uring_task_destroy(cfg, &cfg->aev->mcast_task);
uring_task_destroy(cfg, &cfg->aev->task);
cfg->aev = NULL;
@@ -140,7 +142,7 @@ announce_stop(struct announce *aev)
};
if (timerfd_settime(aev->task.fd, 0, &tspec, NULL) != 0)
- perrordie("timerfd_settime");
+ error("timerfd_settime: %m");
}
void
@@ -158,7 +160,7 @@ announce_start(struct announce *aev)
};
if (timerfd_settime(aev->task.fd, 0, &tspec, NULL) != 0)
- perrordie("timerfd_settime");
+ error("timerfd_settime: %m");
}
void
@@ -170,15 +172,15 @@ announce_init(struct cfg *cfg)
aev = zmalloc(sizeof(*aev));
if (!aev)
- perrordie("malloc");
+ die("malloc: %m");
afd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
if (afd < 0)
- perrordie("timerfd_create");
+ die("timerfd_create: %m");
sfd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (sfd < 0)
- perrordie("socket");
+ die("socket: %m");
uring_task_init(&aev->task, "aev", uring_parent(cfg), announce_free);
uring_task_set_fd(&aev->task, afd);