From: Jens Axboe Date: Thu, 28 Feb 2013 07:24:23 +0000 (+0100) Subject: net: fix warning for systems without TCP_NODELAY X-Git-Tag: fio-2.0.15~46^2~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=6264c7a8ddd0998f371604c227d3aea491922681 net: fix warning for systems without TCP_NODELAY Signed-off-by: Jens Axboe --- diff --git a/engines/net.c b/engines/net.c index 3e03bc9c..624ff158 100644 --- a/engines/net.c +++ b/engines/net.c @@ -458,7 +458,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f) { struct netio_data *nd = td->io_ops->data; struct netio_options *o = td->eo; - int type, domain, optval; + int type, domain; if (o->proto == FIO_TYPE_TCP) { domain = AF_INET; @@ -483,7 +483,8 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f) #ifdef CONFIG_TCP_NODELAY if (o->nodelay && o->proto == FIO_TYPE_TCP) { - optval = 1; + int optval = 1; + if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) { log_err("fio: cannot set TCP_NODELAY option on socket (%s), disable with 'nodelay=0'\n", strerror(errno)); return 1; @@ -522,7 +523,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f) struct netio_data *nd = td->io_ops->data; struct netio_options *o = td->eo; socklen_t socklen = sizeof(nd->addr); - int state, optval; + int state; if (o->proto == FIO_TYPE_UDP) { f->fd = nd->listenfd; @@ -545,7 +546,8 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f) #ifdef CONFIG_TCP_NODELAY if (o->nodelay && o->proto == FIO_TYPE_TCP) { - optval = 1; + int optval = 1; + if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) { log_err("fio: cannot set TCP_NODELAY option on socket (%s), disable with 'nodelay=0'\n", strerror(errno)); return 1;