}
// Chose a random port
- int port = conf->port + (random() % conf->sockets);
+ int port = conf->port + (random() % conf->listening_sockets);
DEBUG(conf, "Opening socket %d (port %d)...\n", fd, port);
struct fireperf_config conf = {
.keepalive_count = DEFAULT_KEEPALIVE_COUNT,
.keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL,
+ .listening_sockets = DEFAULT_LISTENING_SOCKETS,
.loglevel = DEFAULT_LOG_LEVEL,
.mode = FIREPERF_MODE_NONE,
.port = DEFAULT_PORT,
.parallel = DEFAULT_PARALLEL,
- .sockets = DEFAULT_SOCKETS,
.timeout = DEFAULT_TIMEOUT,
};
int r;
#define DEFAULT_LOG_LEVEL LOG_INFO
#define DEFAULT_PARALLEL 1
#define DEFAULT_PORT 5001
-#define DEFAULT_SOCKETS 10
+#define DEFAULT_LISTENING_SOCKETS 1
#define DEFAULT_TIMEOUT 300
#define MAX_PARALLEL (1 << 20)
int keepalive_count;
int keepalive_interval;
int port;
- unsigned int sockets;
+ unsigned int listening_sockets;
unsigned long parallel;
unsigned int timeout;
int zero;
}
static int is_listening_socket(struct fireperf_config* conf, int* sockets, int fd) {
- for (unsigned int i = 0; i < conf->sockets; i++) {
+ for (unsigned int i = 0; i < conf->listening_sockets; i++) {
if (sockets[i] == fd)
return 1;
}
DEBUG(conf, "Launching " PACKAGE_NAME " in server mode\n");
- int sockets[conf->sockets];
+ int listening_sockets[conf->listening_sockets];
int epollfd = -1;
struct epoll_event events[EPOLL_MAX_EVENTS];
}
// Create listening sockets
- for (unsigned int i = 0; i < conf->sockets; i++) {
+ for (unsigned int i = 0; i < conf->listening_sockets; i++) {
int sockfd = create_socket(conf, i);
if (sockfd < 0)
return 1;
- sockets[i] = sockfd;
+ listening_sockets[i] = sockfd;
// Add listening socket to epoll
struct epoll_event ev = {
int fd = events[i].data.fd;
// The listening socket
- if (is_listening_socket(conf, sockets, fd)) {
+ if (is_listening_socket(conf, listening_sockets, fd)) {
int connfd = accept_connection(conf, fd);
if (connfd < 0)
goto ERROR;
}
ERROR:
- for (unsigned int i = 0; i < conf->sockets; i++) {
- if (sockets[i] > 0)
- close(sockets[i]);
+ for (unsigned int i = 0; i < conf->listening_sockets; i++) {
+ if (listening_sockets[i] > 0)
+ close(listening_sockets[i]);
}
if (epollfd > 0)