};
struct epoll_event events[EPOLL_MAX_EVENTS];
- // Let us know when the socket is ready for sending data
+ // Let us know when the socket is ready for receiving data
if (!conf->keepalive_only)
- ev.events |= EPOLLOUT;
+ ev.events |= EPOLLIN;
DEBUG(conf, "Opening %lu connections...\n", conf->parallel);
close(fd);
stats->open_connections--;
+ } else {
+ // Handle incoming data
+ if (events[i].events & EPOLLIN) {
+ r = handle_connection_recv(conf, stats, fd);
+ if (r < 0)
+ goto ERROR;
+ }
- } else if (events[i].events & EPOLLOUT) {
- r = handle_connection_ready(conf, stats, fd);
- if (r)
- goto ERROR;
+ // Handle outgoing data
+ if (events[i].events & EPOLLOUT) {
+ r = handle_connection_ready(conf, stats, fd);
+ if (r)
+ goto ERROR;
+ }
}
}
}
char* bps = NULL;
switch (mode) {
case FIREPERF_MODE_CLIENT:
- bps = format_size(stats->bytes_sent * 8 / delta, FIREPERF_FORMAT_BITS);
+ bps = format_size(stats->bytes_received * 8 / delta, FIREPERF_FORMAT_BITS);
break;
case FIREPERF_MODE_SERVER:
- bps = format_size(stats->bytes_received * 8 / delta, FIREPERF_FORMAT_BITS);
+ bps = format_size(stats->bytes_sent * 8 / delta, FIREPERF_FORMAT_BITS);
break;
}
char* total_bytes = NULL;
switch (mode) {
case FIREPERF_MODE_CLIENT:
- total_bytes = format_size(stats->total_bytes_sent, FIREPERF_FORMAT_BYTES);
- INFO(conf, " %-20s: %20s\n", "Total Bytes Sent", total_bytes);
+ total_bytes = format_size(stats->total_bytes_received, FIREPERF_FORMAT_BYTES);
+ INFO(conf, " %-20s: %20s\n", "Total Bytes Received", total_bytes);
break;
case FIREPERF_MODE_SERVER:
- total_bytes = format_size(stats->total_bytes_received, FIREPERF_FORMAT_BYTES);
- INFO(conf, " %-20s: %20s\n", "Total Bytes Received", total_bytes);
+ total_bytes = format_size(stats->total_bytes_sent, FIREPERF_FORMAT_BYTES);
+ INFO(conf, " %-20s: %20s\n", "Total Bytes Sent", total_bytes);
break;
}
goto ERROR;
// Add the new socket to epoll()
- ev.events = EPOLLIN|EPOLLRDHUP;
+ ev.events = EPOLLOUT|EPOLLRDHUP;
ev.data.fd = connfd;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, connfd, &ev)) {
continue;
}
- // One of the connections had IO
+ // Handle incoming data
if (events[i].events & EPOLLIN) {
r = handle_connection_recv(conf, stats, fd);
if (r < 0)
goto ERROR;
}
+
+ // Handle outgoing data
+ if (events[i].events & EPOLLOUT) {
+ r = handle_connection_send(conf, stats, fd);
+ if (r < 0)
+ goto ERROR;
+ }
}
}
}