}
static int send_data_to_server(struct fireperf_config* conf,
- struct fireperf_stats* stats, int fd, struct fireperf_random_pool* pool) {
+ struct fireperf_stats* stats, int fd) {
const char* buffer = ZERO;
ssize_t bytes_sent;
- if (pool) {
- buffer = fireperf_random_pool_get_slice(pool, SOCKET_SEND_BUFFER_SIZE);
+ if (conf->pool) {
+ buffer = fireperf_random_pool_get_slice(conf->pool, SOCKET_SEND_BUFFER_SIZE);
}
do {
}
static int handle_connection_ready(struct fireperf_config* conf,
- struct fireperf_stats* stats, int fd, struct fireperf_random_pool* pool) {
+ struct fireperf_stats* stats, int fd) {
// Are we supposed to close this connection straight away?
if (conf->close) {
DEBUG(conf, "Closing connection %d\n", fd);
return 0;
}
- return send_data_to_server(conf, stats, fd, pool);
+ return send_data_to_server(conf, stats, fd);
}
int fireperf_client(struct fireperf_config* conf, struct fireperf_stats* stats,
int epollfd, int timerfd) {
- struct fireperf_random_pool* pool = NULL;
-
DEBUG(conf, "Launching " PACKAGE_NAME " in client mode\n");
- // Initialize random pool
- if (!conf->zero) {
- pool = fireperf_random_pool_create(conf, CLIENT_RANDOM_POOL_SIZE);
- if (!pool) {
- ERROR(conf, "Could not allocate random data\n");
- return 1;
- }
- }
-
int r = 1;
struct epoll_event ev = {
stats->open_connections--;
} else if (events[i].events & EPOLLOUT) {
- r = handle_connection_ready(conf, stats, fd, pool);
+ r = handle_connection_ready(conf, stats, fd);
if (r)
goto ERROR;
}
r = 0;
ERROR:
- if (pool)
- fireperf_random_pool_free(pool);
-
return r;
}
#define DEFAULT_PARALLEL 1
#define DEFAULT_PORT 5001
#define DEFAULT_LISTENING_SOCKETS 1
+#define DEFAULT_RANDOM_POOL_SIZE (SOCKET_SEND_BUFFER_SIZE * 512)
#define DEFAULT_TIMEOUT 300
#define MAX_PARALLEL (1 << 20)
#define SOCKET_RECV_BUFFER_SIZE SOCKET_BUFFER_SIZE
#define SOCKET_SEND_BUFFER_SIZE SOCKET_BUFFER_SIZE
-// Random pool size
-#define CLIENT_RANDOM_POOL_SIZE (SOCKET_SEND_BUFFER_SIZE * 512)
-
#define EPOLL_MAX_EVENTS 128
+// Forward declaration
+struct fireperf_random_pool;
+
struct fireperf_config {
int terminated;
int loglevel;
int keepalive_only;
int keepalive_count;
int keepalive_interval;
+ struct fireperf_random_pool* pool;
int port;
unsigned int listening_sockets;
unsigned long parallel;