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

Diff for /src/usr.bin/ssh/packet.c between version 1.153 and 1.154

version 1.153, 2008/05/19 06:14:02 version 1.154, 2008/06/12 20:38:28
Line 134 
Line 134 
   
 int keep_alive_timeouts = 0;  int keep_alive_timeouts = 0;
   
   /* Set to the maximum time that we will wait to send or receive a packet */
   static int packet_timeout_ms = -1;
   
 /* Session key information for Encryption and MAC */  /* Session key information for Encryption and MAC */
 Newkeys *newkeys[MODE_MAX];  Newkeys *newkeys[MODE_MAX];
 static struct packet_state {  static struct packet_state {
Line 187 
Line 190 
         }          }
 }  }
   
   void
   packet_set_timeout(int timeout, int count)
   {
           if (timeout == 0 || count == 0) {
                   packet_timeout_ms = -1;
                   return;
           }
           if ((INT_MAX / 1000) / count < timeout)
                   packet_timeout_ms = INT_MAX;
           else
                   packet_timeout_ms = timeout * count * 1000;
   }
   
 /* Returns 1 if remote host is connected via socket, 0 if not. */  /* Returns 1 if remote host is connected via socket, 0 if not. */
   
 int  int
Line 882 
Line 898 
 int  int
 packet_read_seqnr(u_int32_t *seqnr_p)  packet_read_seqnr(u_int32_t *seqnr_p)
 {  {
         int type, len;          int type, len, ret, ms_remain;
         fd_set *setp;          fd_set *setp;
         char buf[8192];          char buf[8192];
         DBG(debug("packet_read()"));          DBG(debug("packet_read()"));
           struct timeval timeout, start, *timeoutp = NULL;
   
         setp = (fd_set *)xcalloc(howmany(connection_in+1, NFDBITS),          setp = (fd_set *)xcalloc(howmany(connection_in+1, NFDBITS),
             sizeof(fd_mask));              sizeof(fd_mask));
Line 916 
Line 933 
                     sizeof(fd_mask));                      sizeof(fd_mask));
                 FD_SET(connection_in, setp);                  FD_SET(connection_in, setp);
   
                   if (packet_timeout_ms > 0) {
                           ms_remain = packet_timeout_ms;
                           timeoutp = &timeout;
                   }
                 /* Wait for some data to arrive. */                  /* Wait for some data to arrive. */
                 while (select(connection_in + 1, setp, NULL, NULL, NULL) == -1 &&                  for (;;) {
                     (errno == EAGAIN || errno == EINTR))                          if (packet_timeout_ms != -1) {
                         ;                                  ms_to_timeval(&timeout, ms_remain);
                                   gettimeofday(&start, NULL);
                           }
                           if ((ret = select(connection_in + 1, setp, NULL,
                               NULL, timeoutp)) >= 0)
                                   break;
                           if (errno != EAGAIN && errno != EINTR)
                                   break;
                           if (packet_timeout_ms == -1)
                                   continue;
                           ms_subtract_diff(&start, &ms_remain);
                           if (ms_remain <= 0) {
                                   ret = 0;
                                   break;
                           }
                   }
                   if (ret == 0) {
                           logit("Connection to %.200s timed out while "
                               "waiting to read", get_remote_ipaddr());
                           cleanup_exit(255);
                   }
                 /* Read data from the socket. */                  /* Read data from the socket. */
                 len = read(connection_in, buf, sizeof(buf));                  len = read(connection_in, buf, sizeof(buf));
                 if (len == 0) {                  if (len == 0) {
Line 1443 
Line 1483 
 packet_write_wait(void)  packet_write_wait(void)
 {  {
         fd_set *setp;          fd_set *setp;
           int ret, ms_remain;
           struct timeval start, timeout, *timeoutp = NULL;
   
         setp = (fd_set *)xcalloc(howmany(connection_out + 1, NFDBITS),          setp = (fd_set *)xcalloc(howmany(connection_out + 1, NFDBITS),
             sizeof(fd_mask));              sizeof(fd_mask));
Line 1451 
Line 1493 
                 memset(setp, 0, howmany(connection_out + 1, NFDBITS) *                  memset(setp, 0, howmany(connection_out + 1, NFDBITS) *
                     sizeof(fd_mask));                      sizeof(fd_mask));
                 FD_SET(connection_out, setp);                  FD_SET(connection_out, setp);
                 while (select(connection_out + 1, NULL, setp, NULL, NULL) == -1 &&  
                     (errno == EAGAIN || errno == EINTR))                  if (packet_timeout_ms > 0) {
                         ;                          ms_remain = packet_timeout_ms;
                           timeoutp = &timeout;
                   }
                   for (;;) {
                           if (packet_timeout_ms != -1) {
                                   ms_to_timeval(&timeout, ms_remain);
                                   gettimeofday(&start, NULL);
                           }
                           if ((ret = select(connection_out + 1, NULL, setp,
                               NULL, timeoutp)) >= 0)
                                   break;
                           if (errno != EAGAIN && errno != EINTR)
                                   break;
                           if (packet_timeout_ms == -1)
                                   continue;
                           ms_subtract_diff(&start, &ms_remain);
                           if (ms_remain <= 0) {
                                   ret = 0;
                                   break;
                           }
                   }
                   if (ret == 0) {
                           logit("Connection to %.200s timed out while "
                               "waiting to write", get_remote_ipaddr());
                           cleanup_exit(255);
                   }
                 packet_write_poll();                  packet_write_poll();
         }          }
         xfree(setp);          xfree(setp);

Legend:
Removed from v.1.153  
changed lines
  Added in v.1.154