summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-12-14 18:36:41 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-12-14 18:36:41 +0000
commite7880fe8e7cf20b1b9f88f9f53239f1a29293438 (patch)
tree15cd9823a3745a32e4b7d7f8f71d3d28ac6cb1df
parentlistener info output on SIG USR1 (diff)
client info contains bytes received and transferred now
git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@60 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
-rw-r--r--src/clients.c10
-rw-r--r--src/clients.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/src/clients.c b/src/clients.c
index 4175603..696e2e4 100644
--- a/src/clients.c
+++ b/src/clients.c
@@ -92,6 +92,7 @@ static int handle_connect(client_t* c, int32_t buffer_size_)
if(!c->write_buf_[i].buf_) return -2;
c->write_buf_[i].length_ = buffer_size_;
c->write_buf_offset_[i] = 0;
+ c->transferred_[i] = 0;
}
log_printf(INFO, "successfully added client %d", c->fd_[0]);
@@ -210,8 +211,12 @@ void clients_print(clients_t* list)
while(tmp) {
client_t* c = (client_t*)tmp->data_;
if(c) {
- // TODO: print useful info
- log_printf(NOTICE, "client #%d/%d: tba...", c->fd_[0], c->fd_[1]);
+ char state = '?';
+ switch(c->state_) {
+ case CONNECTING: state = '>'; break;
+ case CONNECTED: state = 'c'; break;
+ }
+ log_printf(NOTICE, "[%c] client #%d/%d: %lld bytes received, %lld bytes sent", state, c->fd_[0], c->fd_[1], c->transferred_[0], c->transferred_[1]);
}
tmp = tmp->next_;
}
@@ -323,6 +328,7 @@ int clients_write(clients_t* list, fd_set* set)
break;
}
else {
+ c->transferred_[i] += len;
if(c->write_buf_offset_[i] > len) {
memmove(c->write_buf_[i].buf_, &c->write_buf_[i].buf_[len], c->write_buf_offset_[i] - len);
c->write_buf_offset_[i] -= len;
diff --git a/src/clients.h b/src/clients.h
index 76311d1..8085b97 100644
--- a/src/clients.h
+++ b/src/clients.h
@@ -43,6 +43,7 @@ typedef struct {
buffer_t write_buf_[2];
u_int32_t write_buf_offset_[2];
client_state_t state_;
+ u_int64_t transferred_[2];
} client_t;
void clients_delete_element(void* e);