11 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <arpa/inet.h>
29 struct flist_head list;
30 struct flist_head hash_list;
31 struct flist_head arg_list;
32 struct sockaddr_in addr;
33 struct sockaddr_un addr_un;
46 struct flist_head eta_list;
47 struct client_eta *eta_in_flight;
49 struct flist_head cmd_list;
55 static struct timeval eta_tv;
65 static FLIST_HEAD(client_list);
66 static FLIST_HEAD(eta_list);
68 static FLIST_HEAD(arg_list);
70 static struct thread_stat client_ts;
71 static struct group_run_stats client_gs;
72 static int sum_stat_clients;
73 static int sum_stat_nr;
75 #define FIO_CLIENT_HASH_BITS 7
76 #define FIO_CLIENT_HASH_SZ (1 << FIO_CLIENT_HASH_BITS)
77 #define FIO_CLIENT_HASH_MASK (FIO_CLIENT_HASH_SZ - 1)
78 static struct flist_head client_hash[FIO_CLIENT_HASH_SZ];
80 static int handle_client(struct fio_client *client);
81 static void dec_jobs_eta(struct client_eta *eta);
83 static void fio_client_add_hash(struct fio_client *client)
85 int bucket = hash_long(client->fd, FIO_CLIENT_HASH_BITS);
87 bucket &= FIO_CLIENT_HASH_MASK;
88 flist_add(&client->hash_list, &client_hash[bucket]);
91 static void fio_client_remove_hash(struct fio_client *client)
93 if (!flist_empty(&client->hash_list))
94 flist_del_init(&client->hash_list);
97 static void fio_init fio_client_hash_init(void)
101 for (i = 0; i < FIO_CLIENT_HASH_SZ; i++)
102 INIT_FLIST_HEAD(&client_hash[i]);
105 static struct fio_client *find_client_by_fd(int fd)
107 int bucket = hash_long(fd, FIO_CLIENT_HASH_BITS) & FIO_CLIENT_HASH_MASK;
108 struct fio_client *client;
109 struct flist_head *entry;
111 flist_for_each(entry, &client_hash[bucket]) {
112 client = flist_entry(entry, struct fio_client, hash_list);
114 if (client->fd == fd)
121 static void remove_client(struct fio_client *client)
123 dprint(FD_NET, "client: removed <%s>\n", client->hostname);
124 flist_del(&client->list);
126 fio_client_remove_hash(client);
128 if (!flist_empty(&client->eta_list)) {
129 flist_del_init(&client->eta_list);
130 dec_jobs_eta(client->eta_in_flight);
133 free(client->hostname);
144 static void __fio_client_add_cmd_option(struct fio_client *client,
149 index = client->argc++;
150 client->argv = realloc(client->argv, sizeof(char *) * client->argc);
151 client->argv[index] = strdup(opt);
152 dprint(FD_NET, "client: add cmd %d: %s\n", index, opt);
155 void fio_client_add_cmd_option(void *cookie, const char *opt)
157 struct fio_client *client = cookie;
158 struct flist_head *entry;
163 __fio_client_add_cmd_option(client, opt);
166 * Duplicate arguments to shared client group
168 flist_for_each(entry, &arg_list) {
169 client = flist_entry(entry, struct fio_client, arg_list);
171 __fio_client_add_cmd_option(client, opt);
175 int fio_client_add(const char *hostname, void **cookie)
177 struct fio_client *existing = *cookie;
178 struct fio_client *client;
182 * We always add our "exec" name as the option, hence 1
185 if (existing->argc == 1)
186 flist_add_tail(&existing->arg_list, &arg_list);
188 while (!flist_empty(&arg_list))
189 flist_del_init(arg_list.next);
193 client = malloc(sizeof(*client));
194 memset(client, 0, sizeof(*client));
196 INIT_FLIST_HEAD(&client->list);
197 INIT_FLIST_HEAD(&client->hash_list);
198 INIT_FLIST_HEAD(&client->arg_list);
199 INIT_FLIST_HEAD(&client->eta_list);
200 INIT_FLIST_HEAD(&client->cmd_list);
202 if (fio_server_parse_string(hostname, &client->hostname,
203 &client->is_sock, &client->port,
204 &client->addr.sin_addr))
209 __fio_client_add_cmd_option(client, "fio");
211 flist_add(&client->list, &client_list);
213 dprint(FD_NET, "client: added <%s>\n", client->hostname);
218 static int fio_client_connect_ip(struct fio_client *client)
222 client->addr.sin_family = AF_INET;
223 client->addr.sin_port = htons(client->port);
225 fd = socket(AF_INET, SOCK_STREAM, 0);
227 log_err("fio: socket: %s\n", strerror(errno));
231 if (connect(fd, (struct sockaddr *) &client->addr, sizeof(client->addr)) < 0) {
232 log_err("fio: connect: %s\n", strerror(errno));
233 log_err("fio: failed to connect to %s:%u\n", client->hostname,
242 static int fio_client_connect_sock(struct fio_client *client)
244 struct sockaddr_un *addr = &client->addr_un;
248 memset(addr, 0, sizeof(*addr));
249 addr->sun_family = AF_UNIX;
250 strcpy(addr->sun_path, client->hostname);
252 fd = socket(AF_UNIX, SOCK_STREAM, 0);
254 log_err("fio: socket: %s\n", strerror(errno));
258 len = sizeof(addr->sun_family) + strlen(addr->sun_path) + 1;
259 if (connect(fd, (struct sockaddr *) addr, len) < 0) {
260 log_err("fio: connect; %s\n", strerror(errno));
268 static int fio_client_connect(struct fio_client *client)
272 dprint(FD_NET, "client: connect to host %s\n", client->hostname);
275 fd = fio_client_connect_sock(client);
277 fd = fio_client_connect_ip(client);
279 dprint(FD_NET, "client: %s connected %d\n", client->hostname, fd);
285 fio_client_add_hash(client);
286 client->state = Client_connected;
290 void fio_clients_terminate(void)
292 struct flist_head *entry;
293 struct fio_client *client;
295 dprint(FD_NET, "client: terminate clients\n");
297 flist_for_each(entry, &client_list) {
298 client = flist_entry(entry, struct fio_client, list);
300 fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_QUIT, 0, NULL);
304 static void sig_int(int sig)
306 dprint(FD_NET, "client: got signal %d\n", sig);
307 fio_clients_terminate();
310 static void client_signal_handler(void)
312 struct sigaction act;
314 memset(&act, 0, sizeof(act));
315 act.sa_handler = sig_int;
316 act.sa_flags = SA_RESTART;
317 sigaction(SIGINT, &act, NULL);
319 memset(&act, 0, sizeof(act));
320 act.sa_handler = sig_int;
321 act.sa_flags = SA_RESTART;
322 sigaction(SIGTERM, &act, NULL);
325 static void probe_client(struct fio_client *client)
327 dprint(FD_NET, "client: send probe\n");
329 fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_PROBE, 0, &client->cmd_list);
332 static int send_client_cmd_line(struct fio_client *client)
334 struct cmd_single_line_pdu *cslp;
335 struct cmd_line_pdu *clp;
336 unsigned long offset;
342 dprint(FD_NET, "client: send cmdline %d\n", client->argc);
344 lens = malloc(client->argc * sizeof(unsigned int));
347 * Find out how much mem we need
349 for (i = 0, mem = 0; i < client->argc; i++) {
350 lens[i] = strlen(client->argv[i]) + 1;
355 * We need one cmd_line_pdu, and argc number of cmd_single_line_pdu
357 mem += sizeof(*clp) + (client->argc * sizeof(*cslp));
361 offset = sizeof(*clp);
363 for (i = 0; i < client->argc; i++) {
364 uint16_t arg_len = lens[i];
367 strcpy((char *) cslp->text, client->argv[i]);
368 cslp->len = cpu_to_le16(arg_len);
369 offset += sizeof(*cslp) + arg_len;
373 clp->lines = cpu_to_le16(client->argc);
374 ret = fio_net_send_cmd(client->fd, FIO_NET_CMD_JOBLINE, pdu, mem, 0);
379 int fio_clients_connect(void)
381 struct fio_client *client;
382 struct flist_head *entry, *tmp;
385 dprint(FD_NET, "client: connect all\n");
387 client_signal_handler();
389 flist_for_each_safe(entry, tmp, &client_list) {
390 client = flist_entry(entry, struct fio_client, list);
392 ret = fio_client_connect(client);
394 remove_client(client);
398 probe_client(client);
400 if (client->argc > 1)
401 send_client_cmd_line(client);
408 * Send file contents to server backend. We could use sendfile(), but to remain
409 * more portable lets just read/write the darn thing.
411 static int fio_client_send_ini(struct fio_client *client, const char *filename)
418 dprint(FD_NET, "send ini %s to %s\n", filename, client->hostname);
420 fd = open(filename, O_RDONLY);
422 log_err("fio: job file <%s> open: %s\n", filename, strerror(errno));
426 if (fstat(fd, &sb) < 0) {
427 log_err("fio: job file stat: %s\n", strerror(errno));
432 buf = malloc(sb.st_size);
437 ret = read(fd, p, len);
446 else if (errno == EAGAIN || errno == EINTR)
451 log_err("fio: failed reading job file %s\n", filename);
457 ret = fio_net_send_cmd(client->fd, FIO_NET_CMD_JOB, buf, sb.st_size, 0);
463 int fio_clients_send_ini(const char *filename)
465 struct fio_client *client;
466 struct flist_head *entry, *tmp;
468 flist_for_each_safe(entry, tmp, &client_list) {
469 client = flist_entry(entry, struct fio_client, list);
471 if (fio_client_send_ini(client, filename))
472 remove_client(client);
478 static void convert_io_stat(struct io_stat *dst, struct io_stat *src)
480 dst->max_val = le64_to_cpu(src->max_val);
481 dst->min_val = le64_to_cpu(src->min_val);
482 dst->samples = le64_to_cpu(src->samples);
485 * Floats arrive as IEEE 754 encoded uint64_t, convert back to double
487 dst->mean.u.f = fio_uint64_to_double(le64_to_cpu(dst->mean.u.i));
488 dst->S.u.f = fio_uint64_to_double(le64_to_cpu(dst->S.u.i));
491 static void convert_ts(struct thread_stat *dst, struct thread_stat *src)
495 dst->error = le32_to_cpu(src->error);
496 dst->groupid = le32_to_cpu(src->groupid);
497 dst->pid = le32_to_cpu(src->pid);
498 dst->members = le32_to_cpu(src->members);
500 for (i = 0; i < 2; i++) {
501 convert_io_stat(&dst->clat_stat[i], &src->clat_stat[i]);
502 convert_io_stat(&dst->slat_stat[i], &src->slat_stat[i]);
503 convert_io_stat(&dst->lat_stat[i], &src->lat_stat[i]);
504 convert_io_stat(&dst->bw_stat[i], &src->bw_stat[i]);
507 dst->usr_time = le64_to_cpu(src->usr_time);
508 dst->sys_time = le64_to_cpu(src->sys_time);
509 dst->ctx = le64_to_cpu(src->ctx);
510 dst->minf = le64_to_cpu(src->minf);
511 dst->majf = le64_to_cpu(src->majf);
512 dst->clat_percentiles = le64_to_cpu(src->clat_percentiles);
514 for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++) {
515 fio_fp64_t *fps = &src->percentile_list[i];
516 fio_fp64_t *fpd = &dst->percentile_list[i];
518 fpd->u.f = fio_uint64_to_double(le64_to_cpu(fps->u.i));
521 for (i = 0; i < FIO_IO_U_MAP_NR; i++) {
522 dst->io_u_map[i] = le32_to_cpu(src->io_u_map[i]);
523 dst->io_u_submit[i] = le32_to_cpu(src->io_u_submit[i]);
524 dst->io_u_complete[i] = le32_to_cpu(src->io_u_complete[i]);
527 for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) {
528 dst->io_u_lat_u[i] = le32_to_cpu(src->io_u_lat_u[i]);
529 dst->io_u_lat_m[i] = le32_to_cpu(src->io_u_lat_m[i]);
532 for (i = 0; i < 2; i++)
533 for (j = 0; j < FIO_IO_U_PLAT_NR; j++)
534 dst->io_u_plat[i][j] = le32_to_cpu(src->io_u_plat[i][j]);
536 for (i = 0; i < 3; i++) {
537 dst->total_io_u[i] = le64_to_cpu(src->total_io_u[i]);
538 dst->short_io_u[i] = le64_to_cpu(src->short_io_u[i]);
541 dst->total_submit = le64_to_cpu(src->total_submit);
542 dst->total_complete = le64_to_cpu(src->total_complete);
544 for (i = 0; i < 2; i++) {
545 dst->io_bytes[i] = le64_to_cpu(src->io_bytes[i]);
546 dst->runtime[i] = le64_to_cpu(src->runtime[i]);
549 dst->total_run_time = le64_to_cpu(src->total_run_time);
550 dst->continue_on_error = le16_to_cpu(src->continue_on_error);
551 dst->total_err_count = le64_to_cpu(src->total_err_count);
552 dst->first_error = le32_to_cpu(src->first_error);
553 dst->kb_base = le32_to_cpu(src->kb_base);
556 static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src)
560 for (i = 0; i < 2; i++) {
561 dst->max_run[i] = le64_to_cpu(src->max_run[i]);
562 dst->min_run[i] = le64_to_cpu(src->min_run[i]);
563 dst->max_bw[i] = le64_to_cpu(src->max_bw[i]);
564 dst->min_bw[i] = le64_to_cpu(src->min_bw[i]);
565 dst->io_kb[i] = le64_to_cpu(src->io_kb[i]);
566 dst->agg[i] = le64_to_cpu(src->agg[i]);
569 dst->kb_base = le32_to_cpu(src->kb_base);
570 dst->groupid = le32_to_cpu(src->groupid);
573 static void handle_ts(struct fio_net_cmd *cmd)
575 struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
577 convert_ts(&p->ts, &p->ts);
578 convert_gs(&p->rs, &p->rs);
580 show_thread_status(&p->ts, &p->rs);
582 if (sum_stat_clients == 1)
585 sum_thread_stats(&client_ts, &p->ts, sum_stat_nr);
586 sum_group_stats(&client_gs, &p->rs);
589 client_ts.groupid = p->ts.groupid;
591 if (++sum_stat_nr == sum_stat_clients) {
592 strcpy(client_ts.name, "All clients");
593 show_thread_status(&client_ts, &client_gs);
597 static void handle_gs(struct fio_net_cmd *cmd)
599 struct group_run_stats *gs = (struct group_run_stats *) cmd->payload;
602 show_group_stats(gs);
605 static void convert_agg(struct disk_util_agg *agg)
609 for (i = 0; i < 2; i++) {
610 agg->ios[i] = le32_to_cpu(agg->ios[i]);
611 agg->merges[i] = le32_to_cpu(agg->merges[i]);
612 agg->sectors[i] = le64_to_cpu(agg->sectors[i]);
613 agg->ticks[i] = le32_to_cpu(agg->ticks[i]);
616 agg->io_ticks = le32_to_cpu(agg->io_ticks);
617 agg->time_in_queue = le32_to_cpu(agg->time_in_queue);
618 agg->slavecount = le32_to_cpu(agg->slavecount);
619 agg->max_util.u.f = __le64_to_cpu(fio_uint64_to_double(agg->max_util.u.i));
622 static void convert_dus(struct disk_util_stat *dus)
626 for (i = 0; i < 2; i++) {
627 dus->ios[i] = le32_to_cpu(dus->ios[i]);
628 dus->merges[i] = le32_to_cpu(dus->merges[i]);
629 dus->sectors[i] = le64_to_cpu(dus->sectors[i]);
630 dus->ticks[i] = le32_to_cpu(dus->ticks[i]);
633 dus->io_ticks = le32_to_cpu(dus->io_ticks);
634 dus->time_in_queue = le32_to_cpu(dus->time_in_queue);
635 dus->msec = le64_to_cpu(dus->msec);
638 static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd)
640 struct cmd_du_pdu *du = (struct cmd_du_pdu *) cmd->payload;
642 convert_dus(&du->dus);
643 convert_agg(&du->agg);
645 if (!client->disk_stats_shown) {
646 client->disk_stats_shown = 1;
647 log_info("\nDisk stats (read/write):\n");
650 print_disk_util(&du->dus, &du->agg, terse_output);
653 static void convert_jobs_eta(struct jobs_eta *je)
657 je->nr_running = le32_to_cpu(je->nr_running);
658 je->nr_ramp = le32_to_cpu(je->nr_ramp);
659 je->nr_pending = le32_to_cpu(je->nr_pending);
660 je->files_open = le32_to_cpu(je->files_open);
661 je->m_rate = le32_to_cpu(je->m_rate);
662 je->t_rate = le32_to_cpu(je->t_rate);
663 je->m_iops = le32_to_cpu(je->m_iops);
664 je->t_iops = le32_to_cpu(je->t_iops);
666 for (i = 0; i < 2; i++) {
667 je->rate[i] = le32_to_cpu(je->rate[i]);
668 je->iops[i] = le32_to_cpu(je->iops[i]);
671 je->elapsed_sec = le64_to_cpu(je->elapsed_sec);
672 je->eta_sec = le64_to_cpu(je->eta_sec);
675 static void sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
679 dst->nr_running += je->nr_running;
680 dst->nr_ramp += je->nr_ramp;
681 dst->nr_pending += je->nr_pending;
682 dst->files_open += je->files_open;
683 dst->m_rate += je->m_rate;
684 dst->t_rate += je->t_rate;
685 dst->m_iops += je->m_iops;
686 dst->t_iops += je->t_iops;
688 for (i = 0; i < 2; i++) {
689 dst->rate[i] += je->rate[i];
690 dst->iops[i] += je->iops[i];
693 dst->elapsed_sec += je->elapsed_sec;
695 if (je->eta_sec > dst->eta_sec)
696 dst->eta_sec = je->eta_sec;
699 static void dec_jobs_eta(struct client_eta *eta)
701 if (!--eta->pending) {
702 display_thread_status(&eta->eta);
707 static void remove_reply_cmd(struct fio_client *client, struct fio_net_cmd *cmd)
709 struct fio_net_int_cmd *icmd = NULL;
710 struct flist_head *entry;
712 flist_for_each(entry, &client->cmd_list) {
713 icmd = flist_entry(entry, struct fio_net_int_cmd, list);
715 if (cmd->tag == (uintptr_t) icmd)
722 log_err("fio: client: unable to find matching tag\n");
726 flist_del(&icmd->list);
727 cmd->tag = icmd->saved_tag;
731 static void handle_eta(struct fio_client *client, struct fio_net_cmd *cmd)
733 struct jobs_eta *je = (struct jobs_eta *) cmd->payload;
734 struct client_eta *eta = (struct client_eta *) (uintptr_t) cmd->tag;
736 dprint(FD_NET, "client: got eta tag %p, %d\n", eta, eta->pending);
738 assert(client->eta_in_flight == eta);
740 client->eta_in_flight = NULL;
741 flist_del_init(&client->eta_list);
743 convert_jobs_eta(je);
744 sum_jobs_eta(&eta->eta, je);
748 static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
750 struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
751 const char *os, *arch;
754 os = fio_get_os_string(probe->os);
758 arch = fio_get_arch_string(probe->arch);
762 sprintf(bit, "%d-bit", probe->bpp * 8);
764 log_info("hostname=%s, be=%u, %s, os=%s, arch=%s, fio=%u.%u.%u\n",
765 probe->hostname, probe->bigendian, bit, os, arch,
766 probe->fio_major, probe->fio_minor, probe->fio_patch);
769 client->name = strdup((char *) probe->hostname);
772 static int handle_client(struct fio_client *client)
774 struct fio_net_cmd *cmd;
776 dprint(FD_NET, "client: handle %s\n", client->hostname);
778 cmd = fio_net_recv_cmd(client->fd);
782 dprint(FD_NET, "client: got cmd op %s from %s\n",
783 fio_server_op(cmd->opcode), client->hostname);
785 switch (cmd->opcode) {
786 case FIO_NET_CMD_QUIT:
787 remove_client(client);
790 case FIO_NET_CMD_TEXT: {
791 const char *buf = (const char *) cmd->payload;
795 name = client->name ? client->name : client->hostname;
797 if (!client->skip_newline)
798 fprintf(f_out, "<%s> ", name);
799 ret = fwrite(buf, cmd->pdu_len, 1, f_out);
801 client->skip_newline = strchr(buf, '\n') == NULL;
806 handle_du(client, cmd);
817 case FIO_NET_CMD_ETA:
818 remove_reply_cmd(client, cmd);
819 handle_eta(client, cmd);
822 case FIO_NET_CMD_PROBE:
823 remove_reply_cmd(client, cmd);
824 handle_probe(client, cmd);
827 case FIO_NET_CMD_START:
828 client->state = Client_started;
831 case FIO_NET_CMD_STOP:
832 client->state = Client_stopped;
836 log_err("fio: unknown client op: %s\n", fio_server_op(cmd->opcode));
844 static void request_client_etas(void)
846 struct fio_client *client;
847 struct flist_head *entry;
848 struct client_eta *eta;
851 dprint(FD_NET, "client: request eta (%d)\n", nr_clients);
853 eta = malloc(sizeof(*eta));
854 memset(&eta->eta, 0, sizeof(eta->eta));
855 eta->pending = nr_clients;
857 flist_for_each(entry, &client_list) {
858 client = flist_entry(entry, struct fio_client, list);
860 if (!flist_empty(&client->eta_list)) {
865 assert(!client->eta_in_flight);
866 flist_add_tail(&client->eta_list, &eta_list);
867 client->eta_in_flight = eta;
868 fio_net_send_simple_cmd(client->fd, FIO_NET_CMD_SEND_ETA,
869 (uintptr_t) eta, &client->cmd_list);
875 dprint(FD_NET, "client: requested eta tag %p\n", eta);
878 static int client_check_cmd_timeout(struct fio_client *client,
881 struct fio_net_int_cmd *cmd;
882 struct flist_head *entry, *tmp;
885 flist_for_each_safe(entry, tmp, &client->cmd_list) {
886 cmd = flist_entry(entry, struct fio_net_int_cmd, list);
888 if (mtime_since(&cmd->tv, now) < FIO_NET_CLIENT_TIMEOUT)
891 log_err("fio: client %s, timeout on cmd %s\n", client->hostname,
892 fio_server_op(cmd->cmd.opcode));
893 flist_del(&cmd->list);
898 return flist_empty(&client->cmd_list) && ret;
901 static int fio_client_timed_out(void)
903 struct fio_client *client;
904 struct flist_head *entry, *tmp;
908 gettimeofday(&tv, NULL);
910 flist_for_each_safe(entry, tmp, &client_list) {
911 client = flist_entry(entry, struct fio_client, list);
913 if (flist_empty(&client->cmd_list))
916 if (!client_check_cmd_timeout(client, &tv))
919 log_err("fio: client %s timed out\n", client->hostname);
920 remove_client(client);
927 int fio_handle_clients(void)
929 struct fio_client *client;
930 struct flist_head *entry;
934 gettimeofday(&eta_tv, NULL);
936 pfds = malloc(nr_clients * sizeof(struct pollfd));
938 sum_stat_clients = nr_clients;
939 init_thread_stat(&client_ts);
940 init_group_run_stat(&client_gs);
942 while (!exit_backend && nr_clients) {
944 flist_for_each(entry, &client_list) {
945 client = flist_entry(entry, struct fio_client, list);
947 pfds[i].fd = client->fd;
948 pfds[i].events = POLLIN;
952 assert(i == nr_clients);
957 gettimeofday(&tv, NULL);
958 if (mtime_since(&eta_tv, &tv) >= 900) {
959 request_client_etas();
960 memcpy(&eta_tv, &tv, sizeof(tv));
962 if (fio_client_timed_out())
966 ret = poll(pfds, nr_clients, 100);
970 log_err("fio: poll clients: %s\n", strerror(errno));
976 for (i = 0; i < nr_clients; i++) {
977 if (!(pfds[i].revents & POLLIN))
980 client = find_client_by_fd(pfds[i].fd);
982 log_err("fio: unknown client fd %d\n", pfds[i].fd);
985 if (!handle_client(client)) {
986 log_info("client: host=%s disconnected\n",
988 remove_client(client);