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

Diff of /monit/validate.c

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

revision 1.54 by hauk, Thu Jul 24 00:35:25 2003 UTC revision 1.55 by hauk, Thu Jul 24 00:50:18 2003 UTC
# Line 473  static int check_process(Service_T s, Pr Line 473  static int check_process(Service_T s, Pr
473   * Returns TRUE if the connection and protocol test succeeded   * Returns TRUE if the connection and protocol test succeeded
474   * otherwise FALSE.   * otherwise FALSE.
475   */   */
476  static int check_process_connection(Service_T s, Port_T pp, char *report) {  static int check_process_connection(Service_T s, Port_T p, char *report) {
477    
478    Socket_T socket;    Socket_T socket;
479    volatile int rv= TRUE;    volatile int rv= TRUE;
480    
481    ASSERT(s && pp);    ASSERT(s && p);
482        
483    /* Control comes here if a timeout occures */    /* Control comes here if a timeout occures */
484    if(sigsetjmp(timeout, TRUE)) {    if(sigsetjmp(timeout, TRUE)) {
485      snprintf(report, STRLEN, "timed out when testing %s [%s]",      snprintf(report, STRLEN, "timed out when testing %s [%s]",
486               pp->address, pp->protocol->name);               p->address, p->protocol->name);
487      rv= FALSE;      rv= FALSE;
488      goto error;      goto error;
489            
# Line 494  static int check_process_connection(Serv Line 494  static int check_process_connection(Serv
494    alarm(CHECK_TIMEOUT);    alarm(CHECK_TIMEOUT);
495    
496    /* Open a socket to the destination INET[hostname:port] or UNIX[pathname] */    /* Open a socket to the destination INET[hostname:port] or UNIX[pathname] */
497    socket= socket_create(pp);    socket= socket_create(p);
498    if(!socket) {    if(!socket) {
499      snprintf(report, STRLEN,      snprintf(report, STRLEN,
500               "does not accept connection at %s.",               "does not accept connection at %s.",
501               pp->address);               p->address);
502      rv= FALSE;      rv= FALSE;
503      goto error;      goto error;
504    } else {    } else {
505      DEBUG("'%s' succeeded connecting to %s\n", s->name, pp->address);      DEBUG("'%s' succeeded connecting to %s\n", s->name, p->address);
506    }    }
507    
508    /* Verify that the socket is ready for i|o */    /* Verify that the socket is ready for i|o */
509    if(! socket_is_ready(socket)) {    if(! socket_is_ready(socket)) {
510      snprintf(report, STRLEN,      snprintf(report, STRLEN,
511               "socket at %s is not ready for i|o -- %s",               "socket at %s is not ready for i|o -- %s",
512               pp->address, STRERROR);               p->address, STRERROR);
513      rv= FALSE;      rv= FALSE;
514      goto error;      goto error;
515    }    }
516    
517    /* Run the protocol verification routine through the socket */    /* Run the protocol verification routine through the socket */
518    if(! pp->protocol->check(socket)) {    if(! p->protocol->check(socket)) {
519      snprintf(report, STRLEN,      snprintf(report, STRLEN,
520               "test with protocol [%s] failed at %s.",               "test with protocol [%s] failed at %s.",
521               pp->protocol->name, pp->address);               p->protocol->name, p->address);
522      rv= FALSE;      rv= FALSE;
523      goto error;      goto error;
524    } else {    } else {
525      DEBUG("'%s' succeeded testing protocol [%s] at %s\n",      DEBUG("'%s' succeeded testing protocol [%s] at %s\n",
526            s->name, pp->protocol->name, pp->address);            s->name, p->protocol->name, p->address);
527    }    }
528    
529    error:    error:

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55

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