return pool->data + offset;
}
+static int dump_stats(struct fireperf_config* conf, struct fireperf_client_stats* stats) {
+ INFO(conf, "Dumping stats...\n");
+
+ return 0;
+}
+
static int open_connection(struct fireperf_config* conf) {
// Open a new socket
int fd = socket(AF_INET6, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
// What type of event are we handling?
- // Has the socket been disconnected?
- if (events[i].events & EPOLLHUP) {
- if (epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, NULL)) {
- ERROR(conf, "Could not remove socket file descriptor from epoll(): %s\n",
- strerror(errno));
+ // Handle timer events
+ if (fd == timerfd) {
+ uint64_t expirations;
+
+ // Read from the timer to disarm it
+ ssize_t bytes_read = read(timerfd, &expirations, sizeof(expirations));
+ if (bytes_read <= 0) {
+ ERROR(conf, "Could not read from timerfd: %s\n", strerror(errno));
goto ERROR;
}
- close(fd);
-
- stats.connections--;
-
- } else if (events[i].events & EPOLLOUT) {
- r = send_data_to_server(conf, fd, pool);
+ r = dump_stats(conf, &stats);
if (r)
goto ERROR;
+
+ // Handle connection sockets
+ } else {
+ // Has the socket been disconnected?
+ if (events[i].events & EPOLLHUP) {
+ if (epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, NULL)) {
+ ERROR(conf, "Could not remove socket file descriptor from epoll(): %s\n",
+ strerror(errno));
+ goto ERROR;
+ }
+
+ close(fd);
+
+ stats.connections--;
+
+ } else if (events[i].events & EPOLLOUT) {
+ r = send_data_to_server(conf, fd, pool);
+ if (r)
+ goto ERROR;
+ }
}
}
}