blob: 12c2c37732c3321c2a08c2e573a4b9c2c79cd12f [file] [log] [blame]
Jens Axboe132159a2011-09-30 15:01:32 -06001#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <limits.h>
5#include <errno.h>
6#include <fcntl.h>
7#include <sys/poll.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <sys/wait.h>
11#include <sys/mman.h>
12#include <netinet/in.h>
13#include <arpa/inet.h>
14#include <netdb.h>
15
16#include "fio.h"
17#include "server.h"
18#include "crc/crc32.h"
Jens Axboeb66570d2011-10-01 11:11:35 -060019#include "flist.h"
Jens Axboe132159a2011-09-30 15:01:32 -060020
Jens Axboeb66570d2011-10-01 11:11:35 -060021struct fio_client {
22 struct flist_head list;
23 struct sockaddr_in addr;
24 char *hostname;
25 int fd;
Jens Axboe81179ee2011-10-04 12:42:06 +020026
27 int state;
Jens Axboe17dd1762011-10-04 13:27:34 +020028 int skip_newline;
Jens Axboe81179ee2011-10-04 12:42:06 +020029
30 uint16_t argc;
31 char **argv;
32};
33
34enum {
Jens Axboe5c2857f2011-10-04 13:14:32 +020035 Client_created = 0,
Jens Axboe81179ee2011-10-04 12:42:06 +020036 Client_connected = 1,
37 Client_started = 2,
38 Client_stopped = 3,
Jens Axboe5c2857f2011-10-04 13:14:32 +020039 Client_exited = 4,
Jens Axboeb66570d2011-10-01 11:11:35 -060040};
41
42static FLIST_HEAD(client_list);
Jens Axboeb66570d2011-10-01 11:11:35 -060043
Jens Axboe0b8f30a2011-10-04 10:31:53 +020044static int handle_client(struct fio_client *client, int one);
45
Jens Axboeb66570d2011-10-01 11:11:35 -060046static struct fio_client *find_client_by_fd(int fd)
47{
48 struct fio_client *client;
49 struct flist_head *entry;
50
51 flist_for_each(entry, &client_list) {
52 client = flist_entry(entry, struct fio_client, list);
53
54 if (client->fd == fd)
55 return client;
56 }
57
58 return NULL;
59}
60
61static struct fio_client *find_client_by_name(const char *name)
62{
63 struct fio_client *client;
64 struct flist_head *entry;
65
66 flist_for_each(entry, &client_list) {
67 client = flist_entry(entry, struct fio_client, list);
68
69 if (!strcmp(name, client->hostname))
70 return client;
71 }
72
73 return NULL;
74}
75
76static void remove_client(struct fio_client *client)
77{
Jens Axboe46c48f12011-10-01 12:50:51 -060078 dprint(FD_NET, "removed client <%s>\n", client->hostname);
Jens Axboeb66570d2011-10-01 11:11:35 -060079 flist_del(&client->list);
80 nr_clients--;
Jens Axboe81179ee2011-10-04 12:42:06 +020081
Jens Axboeb66570d2011-10-01 11:11:35 -060082 free(client->hostname);
Jens Axboe81179ee2011-10-04 12:42:06 +020083 if (client->argv)
84 free(client->argv);
85
Jens Axboeb66570d2011-10-01 11:11:35 -060086 free(client);
87}
Jens Axboe132159a2011-09-30 15:01:32 -060088
Jens Axboe81179ee2011-10-04 12:42:06 +020089static void __fio_client_add_cmd_option(struct fio_client *client,
90 const char *opt)
91{
92 client->argc++;
93 client->argv = realloc(client->argv, sizeof(char *) * client->argc);
94 client->argv[client->argc - 1] = strdup(opt);
95}
96
97void fio_client_add_cmd_option(const char *hostname, const char *opt)
98{
99 struct fio_client *client;
100
101 if (!hostname || !opt)
102 return;
103
104 client = find_client_by_name(hostname);
105 if (!client) {
106 log_err("fio: unknown client %s\n", hostname);
107 return;
108 }
109
110 __fio_client_add_cmd_option(client, opt);
111}
112
Jens Axboea37f69b2011-10-01 12:24:21 -0600113void fio_client_add(const char *hostname)
Jens Axboe132159a2011-09-30 15:01:32 -0600114{
Jens Axboeb66570d2011-10-01 11:11:35 -0600115 struct fio_client *client;
Jens Axboe132159a2011-09-30 15:01:32 -0600116
Jens Axboe46c48f12011-10-01 12:50:51 -0600117 dprint(FD_NET, "added client <%s>\n", hostname);
Jens Axboeb66570d2011-10-01 11:11:35 -0600118 client = malloc(sizeof(*client));
Jens Axboea37f69b2011-10-01 12:24:21 -0600119 memset(client, 0, sizeof(*client));
Jens Axboe81179ee2011-10-04 12:42:06 +0200120
Jens Axboea37f69b2011-10-01 12:24:21 -0600121 client->hostname = strdup(hostname);
122 client->fd = -1;
Jens Axboe81179ee2011-10-04 12:42:06 +0200123
124 __fio_client_add_cmd_option(client, "fio");
125
Jens Axboea37f69b2011-10-01 12:24:21 -0600126 flist_add(&client->list, &client_list);
127 nr_clients++;
128}
129
130static int fio_client_connect(struct fio_client *client)
131{
132 int fd;
Jens Axboe132159a2011-09-30 15:01:32 -0600133
Jens Axboe46c48f12011-10-01 12:50:51 -0600134 dprint(FD_NET, "connect to host %s\n", client->hostname);
135
Jens Axboeb66570d2011-10-01 11:11:35 -0600136 memset(&client->addr, 0, sizeof(client->addr));
137 client->addr.sin_family = AF_INET;
138 client->addr.sin_port = htons(fio_net_port);
139
Jens Axboea37f69b2011-10-01 12:24:21 -0600140 if (inet_aton(client->hostname, &client->addr.sin_addr) != 1) {
Jens Axboe132159a2011-09-30 15:01:32 -0600141 struct hostent *hent;
142
Jens Axboea37f69b2011-10-01 12:24:21 -0600143 hent = gethostbyname(client->hostname);
Jens Axboe132159a2011-09-30 15:01:32 -0600144 if (!hent) {
145 log_err("fio: gethostbyname: %s\n", strerror(errno));
146 return 1;
147 }
148
Jens Axboeb66570d2011-10-01 11:11:35 -0600149 memcpy(&client->addr.sin_addr, hent->h_addr, 4);
Jens Axboe132159a2011-09-30 15:01:32 -0600150 }
151
152 fd = socket(AF_INET, SOCK_STREAM, 0);
153 if (fd < 0) {
154 log_err("fio: socket: %s\n", strerror(errno));
155 return 1;
156 }
157
Jens Axboeb66570d2011-10-01 11:11:35 -0600158 if (connect(fd, (struct sockaddr *) &client->addr, sizeof(client->addr)) < 0) {
Jens Axboe132159a2011-09-30 15:01:32 -0600159 log_err("fio: connect: %s\n", strerror(errno));
Jens Axboecdf54d82011-10-04 08:31:40 +0200160 log_err("fio: failed to connect to %s\n", client->hostname);
Jens Axboe132159a2011-09-30 15:01:32 -0600161 return 1;
162 }
163
Jens Axboeb66570d2011-10-01 11:11:35 -0600164 client->fd = fd;
Jens Axboe81179ee2011-10-04 12:42:06 +0200165 client->state = Client_connected;
Jens Axboe132159a2011-09-30 15:01:32 -0600166 return 0;
167}
168
Jens Axboecc0df002011-10-03 20:53:32 +0200169void fio_clients_terminate(void)
170{
171 struct flist_head *entry;
172 struct fio_client *client;
173
174 flist_for_each(entry, &client_list) {
175 client = flist_entry(entry, struct fio_client, list);
176
177 fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_QUIT, 0);
178 }
179}
180
181static void sig_int(int sig)
182{
183 fio_clients_terminate();
184}
185
186static void client_signal_handler(void)
187{
188 struct sigaction act;
189
190 memset(&act, 0, sizeof(act));
191 act.sa_handler = sig_int;
192 act.sa_flags = SA_RESTART;
193 sigaction(SIGINT, &act, NULL);
194
195 memset(&act, 0, sizeof(act));
196 act.sa_handler = sig_int;
197 act.sa_flags = SA_RESTART;
198 sigaction(SIGTERM, &act, NULL);
199}
200
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200201static void probe_client(struct fio_client *client)
202{
203 fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_PROBE, 0);
204 handle_client(client, 1);
205}
206
Jens Axboe81179ee2011-10-04 12:42:06 +0200207static int send_client_cmd_line(struct fio_client *client)
208{
209 struct cmd_line_pdu *pdu;
210 int i, ret;
211
212 pdu = malloc(sizeof(*pdu));
213 for (i = 0; i < client->argc; i++)
214 strcpy((char *) pdu->argv[i], client->argv[i]);
215
216 pdu->argc = cpu_to_le16(client->argc);
217 ret = fio_net_send_cmd(client->fd, FIO_NET_CMD_JOBLINE, pdu, sizeof(*pdu));
218 free(pdu);
219 return ret;
220}
221
Jens Axboea37f69b2011-10-01 12:24:21 -0600222int fio_clients_connect(void)
223{
224 struct fio_client *client;
225 struct flist_head *entry, *tmp;
226 int ret;
227
Jens Axboecc0df002011-10-03 20:53:32 +0200228 client_signal_handler();
229
Jens Axboea37f69b2011-10-01 12:24:21 -0600230 flist_for_each_safe(entry, tmp, &client_list) {
231 client = flist_entry(entry, struct fio_client, list);
232
233 ret = fio_client_connect(client);
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200234 if (ret) {
Jens Axboea37f69b2011-10-01 12:24:21 -0600235 remove_client(client);
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200236 continue;
237 }
238
239 probe_client(client);
Jens Axboe81179ee2011-10-04 12:42:06 +0200240
241 if (client->argc > 1)
242 send_client_cmd_line(client);
Jens Axboea37f69b2011-10-01 12:24:21 -0600243 }
244
245 return !nr_clients;
246}
247
Jens Axboe132159a2011-09-30 15:01:32 -0600248/*
249 * Send file contents to server backend. We could use sendfile(), but to remain
250 * more portable lets just read/write the darn thing.
251 */
Jens Axboea37f69b2011-10-01 12:24:21 -0600252static int fio_client_send_ini(struct fio_client *client, const char *filename)
Jens Axboe132159a2011-09-30 15:01:32 -0600253{
254 struct stat sb;
255 char *p, *buf;
256 off_t len;
257 int fd, ret;
258
Jens Axboe46c48f12011-10-01 12:50:51 -0600259 dprint(FD_NET, "send ini %s to %s\n", filename, client->hostname);
260
Jens Axboe132159a2011-09-30 15:01:32 -0600261 fd = open(filename, O_RDONLY);
262 if (fd < 0) {
263 log_err("fio: job file open: %s\n", strerror(errno));
264 return 1;
265 }
266
267 if (fstat(fd, &sb) < 0) {
268 log_err("fio: job file stat: %s\n", strerror(errno));
269 return 1;
270 }
271
272 buf = malloc(sb.st_size);
273
274 len = sb.st_size;
275 p = buf;
276 do {
277 ret = read(fd, p, len);
278 if (ret > 0) {
279 len -= ret;
280 if (!len)
281 break;
282 p += ret;
283 continue;
284 } else if (!ret)
285 break;
286 else if (errno == EAGAIN || errno == EINTR)
287 continue;
288 } while (1);
289
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200290 if (len) {
291 log_err("fio: failed reading job file %s\n", filename);
292 return 1;
293 }
294
Jens Axboe81179ee2011-10-04 12:42:06 +0200295 ret = fio_net_send_cmd(client->fd, FIO_NET_CMD_JOB, buf, sb.st_size);
Jens Axboe132159a2011-09-30 15:01:32 -0600296 free(buf);
297 return ret;
298}
Jens Axboe37db14f2011-09-30 17:00:42 -0600299
Jens Axboea37f69b2011-10-01 12:24:21 -0600300int fio_clients_send_ini(const char *filename)
301{
302 struct fio_client *client;
303 struct flist_head *entry, *tmp;
304
305 flist_for_each_safe(entry, tmp, &client_list) {
306 client = flist_entry(entry, struct fio_client, list);
307
308 if (fio_client_send_ini(client, filename))
309 remove_client(client);
310 }
311
312 return !nr_clients;
313}
314
Jens Axboea64e88d2011-10-03 14:20:01 +0200315static void convert_io_stat(struct io_stat *dst, struct io_stat *src)
316{
317 dst->max_val = le64_to_cpu(src->max_val);
318 dst->min_val = le64_to_cpu(src->min_val);
319 dst->samples = le64_to_cpu(src->samples);
320 /* FIXME */
Jens Axboeddcc0b62011-10-03 14:45:27 +0200321 dst->mean = __le64_to_cpu(src->mean);
322 dst->S = __le64_to_cpu(src->S);
Jens Axboea64e88d2011-10-03 14:20:01 +0200323}
324
325static void convert_ts(struct thread_stat *dst, struct thread_stat *src)
326{
327 int i, j;
328
329 dst->error = le32_to_cpu(src->error);
330 dst->groupid = le32_to_cpu(src->groupid);
331 dst->pid = le32_to_cpu(src->pid);
332 dst->members = le32_to_cpu(src->members);
333
334 for (i = 0; i < 2; i++) {
335 convert_io_stat(&dst->clat_stat[i], &src->clat_stat[i]);
336 convert_io_stat(&dst->slat_stat[i], &src->slat_stat[i]);
337 convert_io_stat(&dst->lat_stat[i], &src->lat_stat[i]);
338 convert_io_stat(&dst->bw_stat[i], &src->bw_stat[i]);
339 }
340
341 dst->usr_time = le64_to_cpu(src->usr_time);
342 dst->sys_time = le64_to_cpu(src->sys_time);
343 dst->ctx = le64_to_cpu(src->ctx);
344 dst->minf = le64_to_cpu(src->minf);
345 dst->majf = le64_to_cpu(src->majf);
346 dst->clat_percentiles = le64_to_cpu(src->clat_percentiles);
347 dst->percentile_list = NULL;
348
349 for (i = 0; i < FIO_IO_U_MAP_NR; i++) {
350 dst->io_u_map[i] = le32_to_cpu(src->io_u_map[i]);
351 dst->io_u_submit[i] = le32_to_cpu(src->io_u_submit[i]);
352 dst->io_u_complete[i] = le32_to_cpu(src->io_u_complete[i]);
353 }
354
355 for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) {
356 dst->io_u_lat_u[i] = le32_to_cpu(src->io_u_lat_u[i]);
357 dst->io_u_lat_m[i] = le32_to_cpu(src->io_u_lat_m[i]);
358 }
359
360 for (i = 0; i < 2; i++)
361 for (j = 0; j < FIO_IO_U_PLAT_NR; j++)
362 dst->io_u_plat[i][j] = le32_to_cpu(src->io_u_plat[i][j]);
363
364 for (i = 0; i < 3; i++) {
365 dst->total_io_u[i] = le64_to_cpu(src->total_io_u[i]);
Jens Axboe93eee042011-10-03 21:08:48 +0200366 dst->short_io_u[i] = le64_to_cpu(src->short_io_u[i]);
Jens Axboea64e88d2011-10-03 14:20:01 +0200367 }
368
369 dst->total_submit = le64_to_cpu(src->total_submit);
370 dst->total_complete = le64_to_cpu(src->total_complete);
371
372 for (i = 0; i < 2; i++) {
373 dst->io_bytes[i] = le64_to_cpu(src->io_bytes[i]);
374 dst->runtime[i] = le64_to_cpu(src->runtime[i]);
375 }
376
377 dst->total_run_time = le64_to_cpu(src->total_run_time);
378 dst->continue_on_error = le16_to_cpu(src->continue_on_error);
379 dst->total_err_count = le64_to_cpu(src->total_err_count);
Jens Axboeddcc0b62011-10-03 14:45:27 +0200380 dst->first_error = le32_to_cpu(src->first_error);
381 dst->kb_base = le32_to_cpu(src->kb_base);
Jens Axboea64e88d2011-10-03 14:20:01 +0200382}
383
384static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src)
385{
386 int i;
387
388 for (i = 0; i < 2; i++) {
389 dst->max_run[i] = le64_to_cpu(src->max_run[i]);
390 dst->min_run[i] = le64_to_cpu(src->min_run[i]);
391 dst->max_bw[i] = le64_to_cpu(src->max_bw[i]);
392 dst->min_bw[i] = le64_to_cpu(src->min_bw[i]);
393 dst->io_kb[i] = le64_to_cpu(src->io_kb[i]);
394 dst->agg[i] = le64_to_cpu(src->agg[i]);
395 }
396
397 dst->kb_base = le32_to_cpu(src->kb_base);
398 dst->groupid = le32_to_cpu(src->groupid);
399}
400
401static void handle_ts(struct fio_net_cmd *cmd)
402{
403 struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
404
405 convert_ts(&p->ts, &p->ts);
406 convert_gs(&p->rs, &p->rs);
407
408 show_thread_status(&p->ts, &p->rs);
409}
410
411static void handle_gs(struct fio_net_cmd *cmd)
412{
413 struct group_run_stats *gs = (struct group_run_stats *) cmd->payload;
414
415 convert_gs(gs, gs);
416 show_group_stats(gs);
417}
418
Jens Axboecf451d12011-10-03 16:48:30 +0200419static void handle_eta(struct fio_net_cmd *cmd)
420{
421 struct jobs_eta *je = (struct jobs_eta *) cmd->payload;
422 int i;
423
424 je->nr_running = le32_to_cpu(je->nr_running);
425 je->nr_ramp = le32_to_cpu(je->nr_ramp);
426 je->nr_pending = le32_to_cpu(je->nr_pending);
427 je->files_open = le32_to_cpu(je->files_open);
428 je->m_rate = le32_to_cpu(je->m_rate);
429 je->t_rate = le32_to_cpu(je->t_rate);
430 je->m_iops = le32_to_cpu(je->m_iops);
431 je->t_iops = le32_to_cpu(je->t_iops);
432
433 for (i = 0; i < 2; i++) {
434 je->rate[i] = le32_to_cpu(je->rate[i]);
435 je->iops[i] = le32_to_cpu(je->iops[i]);
436 }
437
438 je->elapsed_sec = le32_to_cpu(je->nr_running);
439 je->eta_sec = le64_to_cpu(je->eta_sec);
440
441 display_thread_status(je);
442}
443
Jens Axboe2e03b4b2011-10-04 09:00:40 +0200444static void handle_probe(struct fio_net_cmd *cmd)
445{
446 struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
447
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200448 log_info("Probe: hostname=%s, fio ver %u.%u.%u\n", probe->hostname,
449 probe->fio_major, probe->fio_minor, probe->fio_patch);
Jens Axboe2e03b4b2011-10-04 09:00:40 +0200450}
451
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200452static int handle_client(struct fio_client *client, int one)
Jens Axboe37db14f2011-09-30 17:00:42 -0600453{
454 struct fio_net_cmd *cmd;
Jens Axboea450e492011-10-03 14:24:03 +0200455 int done = 0;
Jens Axboe37db14f2011-09-30 17:00:42 -0600456
Jens Axboe70e0c312011-10-04 09:18:30 +0200457 while ((cmd = fio_net_recv_cmd(client->fd, 1)) != NULL) {
Jens Axboe46c48f12011-10-01 12:50:51 -0600458 dprint(FD_NET, "%s: got cmd op %d\n", client->hostname,
459 cmd->opcode);
460
Jens Axboea64e88d2011-10-03 14:20:01 +0200461 switch (cmd->opcode) {
Jens Axboea64e88d2011-10-03 14:20:01 +0200462 case FIO_NET_CMD_QUIT:
Jens Axboeb66570d2011-10-01 11:11:35 -0600463 remove_client(client);
Jens Axboe437377e2011-10-01 08:31:30 -0600464 free(cmd);
Jens Axboea450e492011-10-03 14:24:03 +0200465 done = 1;
Jens Axboe437377e2011-10-01 08:31:30 -0600466 break;
Jens Axboe17dd1762011-10-04 13:27:34 +0200467 case FIO_NET_CMD_TEXT: {
468 const char *buf = (const char *) cmd->payload;
469
470 if (!client->skip_newline)
471 fprintf(f_out, "Client <%s>: ", client->hostname);
472 fwrite(buf, cmd->pdu_len, 1, f_out);
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200473 fflush(f_out);
Jens Axboe17dd1762011-10-04 13:27:34 +0200474 client->skip_newline = strchr(buf, '\n') == NULL;
Jens Axboe37db14f2011-09-30 17:00:42 -0600475 free(cmd);
Jens Axboea64e88d2011-10-03 14:20:01 +0200476 break;
Jens Axboe17dd1762011-10-04 13:27:34 +0200477 }
Jens Axboea64e88d2011-10-03 14:20:01 +0200478 case FIO_NET_CMD_TS:
479 handle_ts(cmd);
480 free(cmd);
481 break;
482 case FIO_NET_CMD_GS:
483 handle_gs(cmd);
484 free(cmd);
485 break;
Jens Axboecf451d12011-10-03 16:48:30 +0200486 case FIO_NET_CMD_ETA:
487 handle_eta(cmd);
488 free(cmd);
489 break;
Jens Axboe2e03b4b2011-10-04 09:00:40 +0200490 case FIO_NET_CMD_PROBE:
491 handle_probe(cmd);
492 free(cmd);
493 break;
Jens Axboe81179ee2011-10-04 12:42:06 +0200494 case FIO_NET_CMD_START:
495 client->state = Client_started;
496 free(cmd);
497 break;
498 case FIO_NET_CMD_STOP:
499 client->state = Client_stopped;
500 free(cmd);
501 break;
Jens Axboea64e88d2011-10-03 14:20:01 +0200502 default:
503 log_err("fio: unknown client op: %d\n", cmd->opcode);
504 free(cmd);
505 break;
Jens Axboe37db14f2011-09-30 17:00:42 -0600506 }
Jens Axboea450e492011-10-03 14:24:03 +0200507
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200508 if (done || one)
Jens Axboea450e492011-10-03 14:24:03 +0200509 break;
Jens Axboe37db14f2011-09-30 17:00:42 -0600510 }
511
512 return 0;
513}
Jens Axboeb66570d2011-10-01 11:11:35 -0600514
515int fio_handle_clients(void)
516{
517 struct fio_client *client;
518 struct flist_head *entry;
519 struct pollfd *pfds;
Jens Axboe82a4be12011-10-01 12:40:32 -0600520 int i, ret = 0;
Jens Axboeb66570d2011-10-01 11:11:35 -0600521
522 pfds = malloc(nr_clients * sizeof(struct pollfd));
523
Jens Axboeb66570d2011-10-01 11:11:35 -0600524 while (!exit_backend && nr_clients) {
Jens Axboe82a4be12011-10-01 12:40:32 -0600525 i = 0;
526 flist_for_each(entry, &client_list) {
527 client = flist_entry(entry, struct fio_client, list);
528
529 pfds[i].fd = client->fd;
530 pfds[i].events = POLLIN;
531 i++;
532 }
533
534 assert(i == nr_clients);
535
Jens Axboe5c2857f2011-10-04 13:14:32 +0200536 do {
537 ret = poll(pfds, nr_clients, 100);
538 if (ret < 0) {
539 if (errno == EINTR)
540 continue;
541 log_err("fio: poll clients: %s\n", strerror(errno));
542 break;
543 } else if (!ret)
Jens Axboeb66570d2011-10-01 11:11:35 -0600544 continue;
Jens Axboe5c2857f2011-10-04 13:14:32 +0200545 } while (ret <= 0);
Jens Axboeb66570d2011-10-01 11:11:35 -0600546
547 for (i = 0; i < nr_clients; i++) {
548 if (!(pfds[i].revents & POLLIN))
549 continue;
550
551 client = find_client_by_fd(pfds[i].fd);
552 if (!client) {
553 log_err("fio: unknown client\n");
554 continue;
555 }
Jens Axboe0b8f30a2011-10-04 10:31:53 +0200556 handle_client(client, 0);
Jens Axboeb66570d2011-10-01 11:11:35 -0600557 }
558 }
559
560 free(pfds);
Jens Axboeb66570d2011-10-01 11:11:35 -0600561 return 0;
562}