From 05a93fcf7f541e2e969820efa35375190fdc3ce6 Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Wed, 27 Mar 2019 14:51:31 +0200 Subject: daemon: improve debug output. It now outputs the ip address of the client once it connects. This commit is part of Ticket 3. Signed-off-by: Gediminas Jakutis --- src/daemon/net.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/daemon/net.c b/src/daemon/net.c index cf6650a..2969d9b 100644 --- a/src/daemon/net.c +++ b/src/daemon/net.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -158,7 +159,8 @@ static void *dolisten(void * state) struct netstate *st; ssize_t recvbufsize; int cancelstate; - int oldstatus = NONEWDATA; + int oldstatus = DEAD; + char *ipstring; st = state; @@ -187,10 +189,12 @@ static void *dolisten(void * state) if (oldstatus != st->status) { oldstatus = st->status; - if(oldstatus == DEAD) + if(st->status == DEAD) + /* this timestamp is arbitraty */ fprintf(stderr, "Connection with the client has been lost. Last reply since: %li \n", st->lastreply.tv_sec); else{ - fprintf(stderr,"Connected \n"); + ipstring = inet_ntoa(clientaddr.sin_addr); + fprintf(stderr, "Successful incoming connection from %s\n", ipstring); } } pthread_mutex_unlock(&st->datamutex); -- cgit v1.2.3