/[monit]/monit/socket.c
ViewVC logotype

Diff of /monit/socket.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by hauk, Thu Jul 31 02:24:14 2003 UTC revision 1.12 by hauk, Fri Aug 1 01:10:59 2003 UTC
# Line 53  Line 53 
53    
54  /* ------------------------------------------------------------- Definitions */  /* ------------------------------------------------------------- Definitions */
55    
 #define READ_TIMEOUT  5  
   
56  struct Socket_T {  struct Socket_T {
57    int port;    int port;
58    int type;    int type;
# Line 327  int socket_write(Socket_T s, void *b, in Line 325  int socket_write(Socket_T s, void *b, in
325        n= sock_write(s->socket, p, size);        n= sock_write(s->socket, p, size);
326      }      }
327    
328      if(n < 0) break;      if(n <= 0) break;
329      p+= n;      p+= n;
330      size-= n;      size-= n;
331    
332    }    }
333    
334    if(n < 0) {    if(n < 0 && p==b) {
335      return -1;      return -1;
336    }    }
337      
338    return p - b;    return p - b;
339    
340  }  }
# Line 351  int socket_write(Socket_T s, void *b, in Line 349  int socket_write(Socket_T s, void *b, in
349   */   */
350  int socket_read(Socket_T s, void *b, int size) {  int socket_read(Socket_T s, void *b, int size) {
351    
352    ASSERT(s);    int n= 0;
353      void *p= b;
354        
355    if(s->ssl)    ASSERT(s);
       return recv_ssl_socket(s->ssl, b, size);  
   else  
       return sock_read(s->socket, b, size, READ_TIMEOUT);  
356    
357      while(size > 0) {
358        
359        if(s->ssl) {
360          n= recv_ssl_socket(s->ssl, p, size);
361        } else {
362          n= sock_read(s->socket, p, size, 0);
363        }
364    
365        if(n <= 0) break;
366        p+= n;
367        size-= n;
368        
369      }
370    
371      if(n < 0 && p==b) {
372        return -1;
373      }
374      
375      return p - b;
376    
377  }  }
378    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26