X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fnet.c;h=61bdfdd19be81a06fe1ae295b7898546f803de39;hp=110e158f114cbe210656476ff81af305d7d80248;hb=f6846c6545e25638ab95676b04e58b7f36993d1c;hpb=c3afb7639f41e58e44481151e3aa4caa6be789f6 diff --git a/engines/net.c b/engines/net.c index 110e158f..61bdfdd1 100644 --- a/engines/net.c +++ b/engines/net.c @@ -515,11 +515,13 @@ static int __fio_netio_queue(struct thread_data *td, struct io_u *io_u, ret = 0; /* must be a SYNC */ if (ret != (int) io_u->xfer_buflen) { - if (ret >= 0) { + if (ret > 0) { io_u->resid = io_u->xfer_buflen - ret; io_u->error = 0; return FIO_Q_COMPLETED; - } else { + } else if (!ret) + return FIO_Q_BUSY; + else { int err = errno; if (ddir == DDIR_WRITE && err == EMSGSIZE) @@ -945,7 +947,8 @@ static int fio_netio_setup_connect_unix(struct thread_data *td, struct sockaddr_un *soun = &nd->addr_un; soun->sun_family = AF_UNIX; - strcpy(soun->sun_path, path); + memset(soun->sun_path, 0, sizeof(soun->sun_path)); + strncpy(soun->sun_path, path, sizeof(soun->sun_path) - 1); return 0; } @@ -976,7 +979,7 @@ static int fio_netio_setup_listen_unix(struct thread_data *td, const char *path) memset(addr, 0, sizeof(*addr)); addr->sun_family = AF_UNIX; - strcpy(addr->sun_path, path); + strncpy(addr->sun_path, path, sizeof(addr->sun_path) - 1); unlink(path); len = sizeof(addr->sun_family) + strlen(path) + 1; @@ -998,13 +1001,11 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port) struct netio_options *o = td->eo; struct ip_mreq mr; struct sockaddr_in sin; - struct sockaddr_in6 sin6; struct sockaddr *saddr; int fd, opt, type, domain; socklen_t len; memset(&sin, 0, sizeof(sin)); - memset(&sin6, 0, sizeof(sin6)); if (o->proto == FIO_TYPE_TCP) { type = SOCK_STREAM; @@ -1087,11 +1088,12 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port) len = sizeof(nd->addr6); nd->addr6.sin6_family = AF_INET6; - nd->addr6.sin6_addr = sin6.sin6_addr.s6_addr ? sin6.sin6_addr : in6addr_any; + nd->addr6.sin6_addr = in6addr_any; nd->addr6.sin6_port = htons(port); } if (bind(fd, saddr, len) < 0) { + close(fd); td_verror(td, errno, "bind"); return 1; } @@ -1196,6 +1198,7 @@ static int fio_netio_setup(struct thread_data *td) if (!td->files_index) { add_file(td, td->o.filename ?: "net", 0, 0); td->o.nr_files = td->o.nr_files ?: 1; + td->o.open_files++; } if (!td->io_ops->data) { @@ -1212,7 +1215,7 @@ static int fio_netio_setup(struct thread_data *td) static void fio_netio_terminate(struct thread_data *td) { - kill(td->pid, SIGUSR2); + kill(td->pid, SIGTERM); } #ifdef CONFIG_LINUX_SPLICE