Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 71851 invoked from network); 19 Feb 2005 09:27:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 19 Feb 2005 09:27:14 -0000 Received: (qmail 24345 invoked by uid 500); 19 Feb 2005 09:27:05 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 24275 invoked by uid 500); 19 Feb 2005 09:27:04 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 24259 invoked by uid 99); 19 Feb 2005 09:27:04 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from Unknown (HELO mail.bocnet.com.au) (203.7.135.37) by apache.org (qpsmtpd/0.28) with ESMTP; Sat, 19 Feb 2005 01:27:02 -0800 Received: from [10.202.65.180] [203.7.134.203] by mail.bocnet.com.au with ESMTP (SMTPD32-6.06) id A4D0673D0148; Sat, 19 Feb 2005 20:20:16 +1100 Message-ID: <42170687.90501@bocnet.com.au> Date: Sat, 19 Feb 2005 20:27:35 +1100 From: NormW User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tomcat Developers List Subject: Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_ajp_common.c jk_connect.c References: <20050219091335.68089.qmail@minotaur.apache.org> In-Reply-To: <20050219091335.68089.qmail@minotaur.apache.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Greetings, Will see... :-) N. mturk@apache.org wrote: > mturk 2005/02/19 01:13:35 > > Modified: jk/native/common jk_ajp_common.c jk_connect.c > Log: > Use alternative is_socket_connected implementation using > select with 1 microsecond timeout. It should be both faster and > usable on netware too. > > Revision Changes Path > 1.91 +7 -9 jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c > > Index: jk_ajp_common.c > =================================================================== > RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_ajp_common.c,v > retrieving revision 1.90 > retrieving revision 1.91 > diff -u -r1.90 -r1.91 > --- jk_ajp_common.c 18 Feb 2005 08:27:21 -0000 1.90 > +++ jk_ajp_common.c 19 Feb 2005 09:13:35 -0000 1.91 > @@ -847,10 +847,9 @@ > if (ae->worker->cache_timeout > 0 || ae->worker->recycle_timeout > 0) > ae->last_access = time(NULL); > if (ae->worker->socket_timeout > 0) { > - int rc = 0; > - if ((rc = jk_is_socket_connected(ae->sd, ae->worker->socket_timeout)) != 1) { > - jk_log(l, JK_LOG_INFO, > - "Socket is not connected any more (status=%d)", rc); > + if (!jk_is_socket_connected(ae->sd, ae->worker->socket_timeout)) { > + jk_log(l, JK_LOG_INFO, > + "Socket is not connected any more (errno=%d)", errno); > jk_close_socket(ae->sd); > ae->sd = -1; > JK_TRACE_EXIT(l); > @@ -1161,10 +1160,9 @@ > while ((ae->sd > 0)) { > err = 0; > if (ae->worker->socket_timeout) { > - int rc = 0; > - if ((rc = jk_is_socket_connected(ae->sd, ae->worker->socket_timeout)) != 1) { > - jk_log(l, JK_LOG_INFO, > - "Socket is not connected any more (status=%d)", rc); > + if (!jk_is_socket_connected(ae->sd, ae->worker->socket_timeout)) { > + jk_log(l, JK_LOG_INFO, > + "Socket is not connected any more (errno=%d)", errno); > jk_close_socket(ae->sd); > ae->sd = -1; > err++; > > > > 1.43 +48 -2 jakarta-tomcat-connectors/jk/native/common/jk_connect.c > > Index: jk_connect.c > =================================================================== > RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_connect.c,v > retrieving revision 1.42 > retrieving revision 1.43 > diff -u -r1.42 -r1.43 > --- jk_connect.c 17 Feb 2005 08:26:42 -0000 1.42 > +++ jk_connect.c 19 Feb 2005 09:13:35 -0000 1.43 > @@ -194,18 +194,36 @@ > sock_buf); > } > > -#ifdef WIN32 > if (timeout > 0) { > +#ifdef WIN32 > timeout = timeout * 1000; > setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, > (char *) &timeout, sizeof(int)); > setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, > (char *) &timeout, sizeof(int)); > +#else > + /* TODO: How to set the timeout for other platforms? */ > +#endif > if (JK_IS_DEBUG_LEVEL(l)) > jk_log(l, JK_LOG_DEBUG, > "timeout %d set for socket=%d", > timeout, sock); > } > +#ifdef SO_NOSIGPIPE > + /* The preferred method on Mac OS X (10.2 and later) to prevent SIGPIPEs when > + * sending data to a dead peer. Possibly also existing and in use on other BSD > + * systems? > + */ > + set = 1; > + if (setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (const char *)&set, > + sizeof(int))) { > + JK_GET_SOCKET_ERRNO(); > + jk_log(l, JK_LOG_ERROR, > + "failed setting SO_NOSIGPIPE with errno=%d", errno); > + jk_close_socket(sock); > + JK_TRACE_EXIT(l); > + return -1; > + } > #endif > /* Tries to connect to Tomcat (continues trying while error is EINTR) */ > do { > @@ -405,6 +423,32 @@ > return 0; > } > > +#if 1 > +int jk_is_socket_connected(int sd, int timeout) > +{ > + fd_set fd; > + struct timeval tv; > + > + FD_ZERO(&fd); > + FD_SET(sd, &fd); > + > + /* Wait one microsecond */ > + tv.tv_sec = 0; > + tv.tv_usec = 1; > + > + /* If we get a timeout, then we are still connected */ > + if (select(1, &fd, NULL, NULL, &tv) == 0) > + return 1; > + else { > +#if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__)) > + errno = WSAGetLastError() - WSABASEERR; > +#endif > + return 0; > + } > +} > + > +#else > + > #if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__)) > #define EWOULDBLOCK (WSAEWOULDBLOCK - WSABASEERR) > #endif > @@ -434,3 +478,5 @@ > else > return rc; > } > + > +#endif > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org > > > . > --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org