summaryrefslogtreecommitdiffstats
path: root/src/core.c
diff options
context:
space:
mode:
authortiptorrent development team <tiptorrent@soleta.eu>2021-09-08 16:51:47 +0200
committertiptorrent development team <tiptorrent@soleta.eu>2021-09-29 15:47:55 +0200
commit9523d7d8fd7840dbc4d94fa3a2bd45e01050612c (patch)
tree19c8f8a1dd9c01c8562c015b00cfe25e86f5bd31 /src/core.c
parente72dc5e1cbf7c2e5456ce60000e694f219d47cc1 (diff)
add more logging for easier debugging
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/core.c b/src/core.c
index 2b64347..d086dfe 100644
--- a/src/core.c
+++ b/src/core.c
@@ -148,7 +148,9 @@ static void tip_client_read_cb(struct ev_loop *loop, struct ev_io *io, int event
case TIP_CLIENT_PROCESSING_REQUEST:
ret = tip_client_state_process_payload(cli);
if (ret > 0) {
- /* client is pending. */
+ syslog(LOG_INFO, "client %s:%hu for %s enters pending state\n",
+ inet_ntoa(cli->addr.sin_addr),
+ ntohs(cli->addr.sin_port), cli->uri);
return;
} else if (ret < 0) {
syslog(LOG_ERR, "Failed to process HTTP request from %s:%hu\n",
@@ -157,6 +159,10 @@ static void tip_client_read_cb(struct ev_loop *loop, struct ev_io *io, int event
goto close;
}
+ syslog(LOG_INFO, "client %s:%hu starts download for %s\n",
+ inet_ntoa(cli->addr.sin_addr),
+ ntohs(cli->addr.sin_port), cli->uri);
+
ev_io_stop(loop, &cli->io);
ev_io_set(&cli->io, tip_client_socket(cli), EV_READ | EV_WRITE);
ev_io_start(loop, &cli->io);
@@ -320,8 +326,11 @@ static void tip_client_activate_pending(void)
if (cli->state != TIP_CLIENT_PENDING)
continue;
- tip_client_redirect(cli);
-
+ if (!tip_client_redirect(cli)) {
+ syslog(LOG_INFO, "sending %s to client %s:%hu",
+ cli->uri, inet_ntoa(cli->addr.sin_addr),
+ htons(cli->addr.sin_port));
+ }
ev_io_set(&cli->io, tip_client_socket(cli), EV_READ | EV_WRITE);
ev_io_start(tip_main_loop, &cli->io);
ev_timer_start(tip_main_loop, &cli->timer);
@@ -348,9 +357,10 @@ bool tip_client_redirect(struct tip_client *cli)
cli->redirect = true;
cli->redirect_addr = redir->addr;
- syslog(LOG_INFO, "redirecting client %s:%hu to %s:%hu",
+ syslog(LOG_INFO, "redirecting client %s:%hu to %s:%hu for %s",
addr, htons(cli->addr.sin_port),
- inet_ntoa(redir->addr.sin_addr), htons(redir->addr.sin_port));
+ inet_ntoa(redir->addr.sin_addr), htons(redir->addr.sin_port),
+ cli->uri);
free((void *)redir->uri);
ev_timer_stop(tip_main_loop, &redir->timer);