diff options
-rw-r--r-- | src/clients.c | 10 | ||||
-rw-r--r-- | src/clients.h | 1 |
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); |