Skip to content

Commit

Permalink
Log the number of send iterations of a client
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Apr 18, 2021
1 parent 5b84736 commit 129acbd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions endlessh.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ struct client {
unsigned long long connect_time;
unsigned long long send_next;
unsigned long long bytes_sent;
unsigned long send_iter;
struct client *next;
int port;
int fd;
Expand All @@ -133,6 +134,7 @@ client_new(int fd, unsigned long long send_next)
c->connect_time = epochms();
c->send_next = send_next;
c->bytes_sent = 0;
c->send_iter = 0;
c->next = 0;
c->fd = fd;
c->port = 0;
Expand Down Expand Up @@ -173,10 +175,11 @@ client_destroy(struct client *client)
unsigned long long dt = epochms() - client->connect_time;
logmsg(log_info,
"CLOSE host=%s port=%d fd=%d "
"time=%llu.%03llu bytes=%llu",
"time=%llu.%03llu bytes=%llu iter=%lu",
client->ipaddr, client->port, client->fd,
dt / 1000, dt % 1000,
client->bytes_sent);
client->bytes_sent,
client->send_iter);
statistics.milliseconds += dt;
close(client->fd);
free(client);
Expand Down Expand Up @@ -647,6 +650,7 @@ sendline(struct client *client, int max_line_length, unsigned long *rng)
}
} else {
client->bytes_sent += out;
client->send_iter++;
statistics.bytes_sent += out;
return client;
}
Expand Down

0 comments on commit 129acbd

Please sign in to comment.