summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-16 22:31:39 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-16 22:31:39 +0200
commitc48f30ca53695faa09683fc8f506463c07f9c2c3 (patch)
tree80577fb4299ef6e91339be3412b9dbfd432e445a
parentbf3df84cdfbdb0da776d8fb2af9fa2cf53eec985 (diff)
Fixup remaining missed cases of debugging
-rw-r--r--cfgdir.c6
-rw-r--r--main.c20
-rw-r--r--proxy.c5
-rw-r--r--uring.c8
-rw-r--r--utils.c2
5 files changed, 22 insertions, 19 deletions
diff --git a/cfgdir.c b/cfgdir.c
index 040e016..28a300a 100644
--- a/cfgdir.c
+++ b/cfgdir.c
@@ -352,15 +352,13 @@ inotify_cb(struct cfg *cfg, struct uring_task *task, int res)
char *ptr;
struct server *scfg;
- fprintf(stderr, "%s: ret is %i (ref %u)\n", __func__, res, task->refcount);
-
if (task->dead) {
- fprintf(stderr, "%s: task is dead\n", __func__);
+ debug(DBG_CFG, "task is dead\n");
return;
}
if (res <= 0)
- perrordie("inotify_read");
+ perrordie("inotify_read (%i)", res);
for (ptr = iev->buf; ptr < iev->buf + res; ptr += sizeof(struct inotify_event) + event->len) {
event = (const struct inotify_event *)ptr;
diff --git a/main.c b/main.c
index 5296171..148b2d2 100644
--- a/main.c
+++ b/main.c
@@ -129,10 +129,9 @@ cfg_init(int argc, char **argv)
unsigned i;
cfg = zmalloc(sizeof(*cfg));
- if (!cfg) {
- perror("malloc");
- return NULL;
- }
+ if (!cfg)
+ perrordie("malloc");
+
uring_task_init(&cfg->task, "cfg", NULL, cfg_free);
list_init(&cfg->servers);
@@ -220,9 +219,12 @@ dump_tree(struct cfg *cfg)
{
struct server *server;
- fprintf(stderr, "\n\n\n\n");
- fprintf(stderr, "Dumping Tree\n");
- fprintf(stderr, "============\n");
+ if (!debug_enabled(DBG_REF))
+ return;
+
+ debug(DBG_REF, "\n\n\n\n");
+ debug(DBG_REF, "Dumping Tree\n");
+ debug(DBG_REF, "============\n");
uring_task_refdump(&cfg->task);
uring_refdump(cfg->uev);
if (cfg->sev)
@@ -233,8 +235,8 @@ dump_tree(struct cfg *cfg)
cfgdir_refdump(cfg->iev);
list_for_each_entry(server, &cfg->servers, list)
server_refdump(server);
- fprintf(stderr, "============\n");
- fprintf(stderr, "\n\n\n\n");
+ debug(DBG_REF, "============\n");
+ debug(DBG_REF, "\n\n\n\n");
}
static void
diff --git a/proxy.c b/proxy.c
index 91b7c02..fbb9ddf 100644
--- a/proxy.c
+++ b/proxy.c
@@ -67,7 +67,10 @@ proxy_free(struct uring_task *task)
char stc[100];
char duration[100];
- fprintf(stderr, "%s: %s\n", __func__, proxy->scfg->name);
+ debug(DBG_PROXY, "server: %s, src: %s, dst: %s\n",
+ proxy->scfg->name,
+ proxy->client_conn.remotestr,
+ proxy->server_conn.remotestr);
if (proxy->begin > 0) {
format_time(duration, sizeof(duration), time(NULL) - proxy->begin);
diff --git a/uring.c b/uring.c
index dc095c8..10eac79 100644
--- a/uring.c
+++ b/uring.c
@@ -76,9 +76,9 @@ uring_task_refdump(struct uring_task *task)
memcpy(dst, tmp->name, strlen(tmp->name));
}
- fprintf(stderr, "%s (0x%p parent 0x%p free 0x%p fd %i ref %u)\n",
- buf, task, task->parent, task->free, task->fd,
- task->refcount);
+ debug(DBG_REF, "%s (0x%p parent 0x%p free 0x%p fd %i ref %u)\n",
+ buf, task, task->parent, task->free, task->fd,
+ task->refcount);
}
/*
@@ -562,7 +562,7 @@ uring_poll_cancel(struct cfg *cfg, struct uring_task *task)
struct io_uring_sqe *sqe;
if (task->fd < 0) {
- fprintf(stderr, "uring_poll_cancel called with no fd set\n");
+ error("no fd set\n");
return;
}
diff --git a/utils.c b/utils.c
index c36d18a..2d0294a 100644
--- a/utils.c
+++ b/utils.c
@@ -260,7 +260,7 @@ again:
sfd = socket(conn->remote.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (sfd < 0) {
- perror("socket");
+ error("socket: %m");
goto again;
}