configure: add TCP_NODELAY check
authorJens Axboe <axboe@kernel.dk>
Thu, 31 Jan 2013 09:19:51 +0000 (10:19 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 31 Jan 2013 09:19:51 +0000 (10:19 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
configure
engines/net.c

index 995b5df231e9129b9dceace6b867c7fb717c63be..d332c5eb246f29ad4f478fcaca6bd243715c8eec 100755 (executable)
--- a/configure
+++ b/configure
@@ -201,6 +201,7 @@ CYGWIN*)
   output_sym "CONFIG_GETTIMEOFDAY"
   output_sym "CONFIG_CLOCK_GETTIME"
   output_sym "CONFIG_SCHED_IDLE"
   output_sym "CONFIG_GETTIMEOFDAY"
   output_sym "CONFIG_CLOCK_GETTIME"
   output_sym "CONFIG_SCHED_IDLE"
+  output_sym "CONFIG_TCP_NODELAY"
   echo "CC=$CC" >> $config_host_mak
   echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
   exit 0
   echo "CC=$CC" >> $config_host_mak
   echo "EXTFLAGS=$CFLAGS -include config-host.h -D_GNU_SOURCE" >> $config_host_mak
   exit 0
@@ -861,6 +862,24 @@ if compile_prog "" "" "SCHED_IDLE"; then
 fi
 echo "SCHED_IDLE                    $sched_idle"
 
 fi
 echo "SCHED_IDLE                    $sched_idle"
 
+##########################################
+# Check whether we have TCP_NODELAY
+tcp_nodelay="no"
+cat > $TMPC << EOF
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/tcp.h>
+int main(int argc, char **argv)
+{
+  return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
+}
+EOF
+if compile_prog "" "" "TCP_NODELAY"; then
+  tcp_nodelay="yes"
+fi
+echo "TCP_NODELAY                   $tcp_nodelay"
+
 #############################################################################
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
 #############################################################################
 
 echo "# Automatically generated by configure - do not modify" > $config_host_mak
@@ -967,6 +986,9 @@ fi
 if test "$sched_idle" = "yes" ; then
   output_sym "CONFIG_SCHED_IDLE"
 fi
 if test "$sched_idle" = "yes" ; then
   output_sym "CONFIG_SCHED_IDLE"
 fi
+if test "$tcp_nodelay" = "yes" ; then
+  output_sym "CONFIG_TCP_NODELAY"
+fi
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
 
 echo "LIBS+=$LIBS" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
index d0f4fa0dd25b7c3a4983338301445375e71e5ca4..3e03bc9c8742954049ba6246315ad6364222c49d 100644 (file)
@@ -92,12 +92,14 @@ static struct fio_option options[] = {
                          },
                },
        },
                          },
                },
        },
+#ifdef CONFIG_TCP_NODELAY
        {
                .name   = "nodelay",
                .type   = FIO_OPT_BOOL,
                .off1   = offsetof(struct netio_options, nodelay),
                .help   = "Use TCP_NODELAY on TCP connections",
        },
        {
                .name   = "nodelay",
                .type   = FIO_OPT_BOOL,
                .off1   = offsetof(struct netio_options, nodelay),
                .help   = "Use TCP_NODELAY on TCP connections",
        },
+#endif
        {
                .name   = "listen",
                .type   = FIO_OPT_STR_SET,
        {
                .name   = "listen",
                .type   = FIO_OPT_STR_SET,
@@ -479,6 +481,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
                return 1;
        }
 
+#ifdef CONFIG_TCP_NODELAY
        if (o->nodelay && o->proto == FIO_TYPE_TCP) {
                optval = 1;
                if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) {
        if (o->nodelay && o->proto == FIO_TYPE_TCP) {
                optval = 1;
                if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) {
@@ -486,6 +489,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f)
                        return 1;
                }
        }
                        return 1;
                }
        }
+#endif
 
        if (o->proto == FIO_TYPE_UDP)
                return 0;
 
        if (o->proto == FIO_TYPE_UDP)
                return 0;
@@ -539,6 +543,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f)
                goto err;
        }
 
                goto err;
        }
 
+#ifdef CONFIG_TCP_NODELAY
        if (o->nodelay && o->proto == FIO_TYPE_TCP) {
                optval = 1;
                if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) {
        if (o->nodelay && o->proto == FIO_TYPE_TCP) {
                optval = 1;
                if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) {
@@ -546,6 +551,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f)
                        return 1;
                }
        }
                        return 1;
                }
        }
+#endif
 
        reset_all_stats(td);
        td_set_runstate(td, state);
 
        reset_all_stats(td);
        td_set_runstate(td, state);