]> andersk Git - gssapi-openssh.git/blobdiff - openssh/misc.c
Import of OpenSSH 3.1p1
[gssapi-openssh.git] / openssh / misc.c
index 620121fdca29f7e2fbf915c764a2e4bfb73e7949..e9fcef6ca3018c88a1d7fd9e776df351b769c3ff 100644 (file)
@@ -1,5 +1,3 @@
-/*     $OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $        */
-
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  *
@@ -25,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $");
+RCSID("$OpenBSD: misc.c,v 1.19 2002/03/04 17:27:39 stevesk Exp $");
 
 #include "misc.h"
 #include "log.h"
@@ -37,7 +35,7 @@ chop(char *s)
 {
        char *t = s;
        while (*t) {
-               if(*t == '\n' || *t == '\r') {
+               if (*t == '\n' || *t == '\r') {
                        *t = '\0';
                        return s;
                }
@@ -65,9 +63,8 @@ set_nonblock(int fd)
        debug("fd %d setting O_NONBLOCK", fd);
        val |= O_NONBLOCK;
        if (fcntl(fd, F_SETFL, val) == -1)
-               if (errno != ENODEV)
-                       error("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
-                           fd, strerror(errno));
+               debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
+                   fd, strerror(errno));
 }
 
 void
@@ -87,9 +84,30 @@ unset_nonblock(int fd)
        debug("fd %d clearing O_NONBLOCK", fd);
        val &= ~O_NONBLOCK;
        if (fcntl(fd, F_SETFL, val) == -1)
-               if (errno != ENODEV)
-                       error("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
-                           fd, strerror(errno));
+               debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
+                   fd, strerror(errno));
+}
+
+/* disable nagle on socket */
+void
+set_nodelay(int fd)
+{
+       int opt;
+       socklen_t optlen;
+
+       optlen = sizeof opt;
+       if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, &optlen) == -1) {
+               error("getsockopt TCP_NODELAY: %.100s", strerror(errno));
+               return;
+       }
+       if (opt == 1) {
+               debug2("fd %d is TCP_NODELAY", fd);
+               return;
+       }
+       opt = 1;
+       debug("fd %d setting TCP_NODELAY", fd);
+       if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof opt) == -1)
+               error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
 }
 
 /* Characters considered whitespace in strsep calls. */
@@ -298,7 +316,7 @@ addargs(arglist *args, char *fmt, ...)
        if (args->list == NULL) {
                args->nalloc = 32;
                args->num = 0;
-       } else if (args->num+2 >= args->nalloc) 
+       } else if (args->num+2 >= args->nalloc)
                args->nalloc *= 2;
 
        args->list = xrealloc(args->list, args->nalloc * sizeof(char *));
This page took 0.037506 seconds and 4 git commands to generate.