----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

Greg says:

>It looks to me like wrapper_data->config->vmtimeout is used to tell us how
>often to PING (i.e. how often to send the JSERV_PING function call)
>However, inside of the ajpv12 protocol, I do not see where it uses the
>timeout to see how long to wait for a ping reply.   It writes to the socket,
>and then expects to almost immediately read back one byte from the socket.

Greg - I am not sure I'm 100% on this, but I was reading up on the unix system calls 
read()  (see 'man 2 read'), alarm(), and signal() and I'm pretty sure that IFF I 
understood what I read, the following comments are correct.

Please keep in mind that I've done almost zero unix programming (I've been a Mac hack).

Perhaps someone else who IS a unix programmer could confirm my suspicions  indicated 
within the code below:


Summary:  the "alarm( ..vmtimeout )" call sets up a timer that will fire a signal in 
vmtimeout seconds.  The "read()" call will block until either the bytes are read, or 
it receives the signal from the timer.  Thus the value of vmtimeout will effect how 
long the PING code will wait to receive a response.  Suggest you try it and see if it 
works :-)

One thing I'm not clear on is why the write doesn't block, but perhaps it does... in 
either case the timer will still fire and interrupt the "blockage" in the cases where 
JServ is not responding.  When write() returns because of the timer it will not return 
2 and we'll get a different error message.



Details:

--->> I think the line "alarm( ..vmtimeout );"   starts a timer that will fire (by 
sending a signal) in vmtimeout seconds.   Then the routine calls into the protocol 
dispatch code which ends up calling ajpv12_function() that you've listed further down 
below.   I think this timer is Still Active when you've gotten into tha jserv_ajpv12.c 
routine ajpv12_function() below.

>from jserv_wrapper_unix.c in JServ1.1b3
<SNIP>
>            alarm(wrapper_data->config->vmtimeout);
>
>            /* check if we can communicate to JVM */
>            if( jvm_pid != 0 &&
>jserv_protocol_function(wrapper_data->config->protocol,wrapper_data->config,
>                            JSERV_PING,NULL) == JSERV_FUNC_COMMERROR) {
>
>              /* Note that it's harmless that this function is called twice
>                 in case of timeout
>              */
>              kill_hung_jvm(0);
>
>            }
>
>
>            /* Remove the signal, no matter if it was used or not */
>            alarm(0);



>from jserv_ajpv12.c from JServ 1.1b3
>
>/* Our function handler */
>static int ajpv12_function(jserv_config *cfg, int function, char *data) {
>    pool *p=ap_make_sub_pool(NULL);
>    int sock,ret;
>    char signal[2];
>
>#ifdef WIN32
>    signal[0] = (char) 254; /* a signal marker */
>#else
>    signal[0] = 254; /* a signal marker */
>#endif
>
>    if (function==JSERV_SHUTDOWN) {
>        jserv_error(JSERV_LOG_INFO,cfg,"ajp12: %s",
>                    "sending shutdown signal");
>        signal[1]=15;
>    }
>    else if (function==JSERV_RESTART) {
>        jserv_error(JSERV_LOG_INFO,cfg,"ajp12: %s",
>                    "sending restart signal");
>        signal[1]=1;
>    }
>    else if (function==JSERV_PING) {
>      signal[1]=0;
>    }
>    else {
>        jserv_error(JSERV_LOG_ERROR,cfg,"ajp12: %s",
>                    "unknown function requested");
>        ap_destroy_pool(p);
>        return JSERV_FUNC_NOTIMPLEMENTED;
>    }
>
>    /* Check for correct config member */
>    if (cfg==NULL) {
>        jserv_error(JSERV_LOG_EMERG,cfg,"ajp12: %s",
>                    "unknown configuration member for function");
>        ap_destroy_pool(p);
>        return JSERV_FUNC_ERROR;
>    }
>
>    /* Open connection to JServ */
>    sock=ajpv12_open(cfg, p, cfg->hostaddr, cfg->port);
>    if (sock==-1) {
>        jserv_error(JSERV_LOG_EMERG,cfg,"ajp12: %s",
>                    "function connection fail");
>        ap_destroy_pool(p);
>        return JSERV_FUNC_COMMERROR;
>    }
>
>    /* Authenticate socket */
>    ret=ajpv12_auth(cfg, p, sock, cfg->secret, cfg->secretsize);
>    if (ret==-1) {
>        jserv_error(JSERV_LOG_EMERG,cfg,"ajp12: function auth fail");
>        ap_destroy_pool(p);
>        return JSERV_FUNC_ERROR;
>    }
>
>    /* Send the function request */
>    ret = write( sock, signal, 2);
>
>    if (ret!=2) {
>        jserv_error(JSERV_LOG_EMERG,cfg,"ajp12: cannot send function");
>        ap_destroy_pool(p);
>        return JSERV_FUNC_COMMERROR;
>    }
>
>    /* In case of PING wait for some reply */
>    if( function==JSERV_PING ) {
>    int pingret;


----->  This read will "block" until it receives data OR the Timer set with the 
"alarm()" call in jserv_wrapper_unix.c above goes off.  That is why the vmtimeout 
value plays a role here.



>    pingret = read( sock, signal, 1);
>    if( pingret != 1) {
>        jserv_error(JSERV_LOG_EMERG, cfg, "ajp12: ping: no reply (%d) \
>            Please make sure that the wrapper.classpath is pointing \
>            to the correct version of ApacheJServ.jar", \
>            pingret);
>        ap_destroy_pool(p);
>        return JSERV_FUNC_COMMERROR;
>    }
>    }
>

------------------------------------------------------
Tyler Morrison - [EMAIL PROTECTED]


--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to