[BACK]Return to misc.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/misc.c between version 1.21 and 1.21.2.2

version 1.21, 2003/04/12 10:15:36 version 1.21.2.2, 2004/08/19 22:37:31
Line 46 
Line 46 
 }  }
   
 /* set/unset filedescriptor to non-blocking */  /* set/unset filedescriptor to non-blocking */
 void  int
 set_nonblock(int fd)  set_nonblock(int fd)
 {  {
         int val;          int val;
Line 54 
Line 54 
         val = fcntl(fd, F_GETFL, 0);          val = fcntl(fd, F_GETFL, 0);
         if (val < 0) {          if (val < 0) {
                 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));                  error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
                 return;                  return (-1);
         }          }
         if (val & O_NONBLOCK) {          if (val & O_NONBLOCK) {
                 debug2("fd %d is O_NONBLOCK", fd);                  debug3("fd %d is O_NONBLOCK", fd);
                 return;                  return (0);
         }          }
         debug2("fd %d setting O_NONBLOCK", fd);          debug2("fd %d setting O_NONBLOCK", fd);
         val |= O_NONBLOCK;          val |= O_NONBLOCK;
         if (fcntl(fd, F_SETFL, val) == -1)          if (fcntl(fd, F_SETFL, val) == -1) {
                 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",                  debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd,
                     fd, strerror(errno));                      strerror(errno));
                   return (-1);
           }
           return (0);
 }  }
   
 void  int
 unset_nonblock(int fd)  unset_nonblock(int fd)
 {  {
         int val;          int val;
Line 75 
Line 78 
         val = fcntl(fd, F_GETFL, 0);          val = fcntl(fd, F_GETFL, 0);
         if (val < 0) {          if (val < 0) {
                 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));                  error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
                 return;                  return (-1);
         }          }
         if (!(val & O_NONBLOCK)) {          if (!(val & O_NONBLOCK)) {
                 debug2("fd %d is not O_NONBLOCK", fd);                  debug3("fd %d is not O_NONBLOCK", fd);
                 return;                  return (0);
         }          }
         debug("fd %d clearing O_NONBLOCK", fd);          debug("fd %d clearing O_NONBLOCK", fd);
         val &= ~O_NONBLOCK;          val &= ~O_NONBLOCK;
         if (fcntl(fd, F_SETFL, val) == -1)          if (fcntl(fd, F_SETFL, val) == -1) {
                 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",                  debug("fcntl(%d, F_SETFL, ~O_NONBLOCK): %s",
                     fd, strerror(errno));                      fd, strerror(errno));
                   return (-1);
           }
           return (0);
 }  }
   
 /* disable nagle on socket */  /* disable nagle on socket */
Line 97 
Line 103 
   
         optlen = sizeof opt;          optlen = sizeof opt;
         if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, &optlen) == -1) {          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;                  return;
         }          }
         if (opt == 1) {          if (opt == 1) {
Line 302 
Line 308 
 {  {
         va_list ap;          va_list ap;
         char buf[1024];          char buf[1024];
           u_int nalloc;
   
         va_start(ap, fmt);          va_start(ap, fmt);
         vsnprintf(buf, sizeof(buf), fmt, ap);          vsnprintf(buf, sizeof(buf), fmt, ap);
         va_end(ap);          va_end(ap);
   
           nalloc = args->nalloc;
         if (args->list == NULL) {          if (args->list == NULL) {
                 args->nalloc = 32;                  nalloc = 32;
                 args->num = 0;                  args->num = 0;
         } else if (args->num+2 >= args->nalloc)          } else if (args->num+2 >= nalloc)
                 args->nalloc *= 2;                  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++] = xstrdup(buf);
         args->list[args->num] = NULL;          args->list[args->num] = NULL;
 }  }

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.21.2.2