diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-16 22:31:39 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-16 22:31:39 +0200 |
commit | c48f30ca53695faa09683fc8f506463c07f9c2c3 (patch) | |
tree | 80577fb4299ef6e91339be3412b9dbfd432e445a | |
parent | bf3df84cdfbdb0da776d8fb2af9fa2cf53eec985 (diff) |
Fixup remaining missed cases of debugging
-rw-r--r-- | cfgdir.c | 6 | ||||
-rw-r--r-- | main.c | 20 | ||||
-rw-r--r-- | proxy.c | 5 | ||||
-rw-r--r-- | uring.c | 8 | ||||
-rw-r--r-- | utils.c | 2 |
5 files changed, 22 insertions, 19 deletions
@@ -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; @@ -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 @@ -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); @@ -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; } @@ -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; } |