]> andersk Git - openssh.git/blobdiff - misc.c
- dtucker@cvs.openbsd.org 2004/02/27 22:44:56
[openssh.git] / misc.c
diff --git a/misc.c b/misc.c
index 9e5a5aba63121aaec458d21468742fffa2a76e31..1f320353ef16a9803ba4dd53f9ba722b491c42ce 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1,5 +1,3 @@
-/*     $OpenBSD: misc.c,v 1.18 2002/03/04 13:10:46 markus Exp $        */
-
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  *
@@ -25,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.18 2002/03/04 13:10:46 markus Exp $");
+RCSID("$OpenBSD: misc.c,v 1.23 2003/10/28 09:08:06 markus Exp $");
 
 #include "misc.h"
 #include "log.h"
@@ -62,7 +60,7 @@ set_nonblock(int fd)
                debug2("fd %d is O_NONBLOCK", fd);
                return;
        }
-       debug("fd %d setting O_NONBLOCK", fd);
+       debug2("fd %d setting O_NONBLOCK", fd);
        val |= O_NONBLOCK;
        if (fcntl(fd, F_SETFL, val) == -1)
                debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
@@ -99,7 +97,7 @@ set_nodelay(int fd)
 
        optlen = sizeof opt;
        if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, &optlen) == -1) {
-               error("getsockopt TCP_NODELAY: %.100s", strerror(errno));
+               debug("getsockopt TCP_NODELAY: %.100s", strerror(errno));
                return;
        }
        if (opt == 1) {
@@ -107,7 +105,7 @@ set_nodelay(int fd)
                return;
        }
        opt = 1;
-       debug("fd %d setting TCP_NODELAY", fd);
+       debug2("fd %d setting TCP_NODELAY", fd);
        if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof opt) == -1)
                error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
 }
@@ -310,44 +308,21 @@ addargs(arglist *args, char *fmt, ...)
 {
        va_list ap;
        char buf[1024];
+       int nalloc;
 
        va_start(ap, fmt);
        vsnprintf(buf, sizeof(buf), fmt, ap);
        va_end(ap);
 
+       nalloc = args->nalloc;
        if (args->list == NULL) {
-               args->nalloc = 32;
+               nalloc = 32;
                args->num = 0;
-       } else if (args->num+2 >= args->nalloc)
-               args->nalloc *= 2;
+       } else if (args->num+2 >= nalloc)
+               nalloc *= 2;
 
-       args->list = xrealloc(args->list, args->nalloc * sizeof(char *));
+       args->list = xrealloc(args->list, nalloc * sizeof(char *));
+       args->nalloc = nalloc;
        args->list[args->num++] = xstrdup(buf);
        args->list[args->num] = NULL;
 }
-
-mysig_t
-mysignal(int sig, mysig_t act)
-{
-#ifdef HAVE_SIGACTION
-       struct sigaction sa, osa;
-
-       if (sigaction(sig, NULL, &osa) == -1)
-               return (mysig_t) -1;
-       if (osa.sa_handler != act) {
-               memset(&sa, 0, sizeof(sa));
-               sigemptyset(&sa.sa_mask);
-               sa.sa_flags = 0;
-#if defined(SA_INTERRUPT)
-               if (sig == SIGALRM)
-                       sa.sa_flags |= SA_INTERRUPT;
-#endif
-               sa.sa_handler = act;
-               if (sigaction(sig, &sa, NULL) == -1)
-                       return (mysig_t) -1;
-       }
-       return (osa.sa_handler);
-#else
-       return (signal(sig, act));
-#endif
-}
This page took 0.03145 seconds and 4 git commands to generate.