You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2009/12/21 08:04:42 UTC
svn commit: r892708 - in /tomcat/jk/trunk: native/common/jk_connect.c
native/common/portable.h.sample native/configure.in
xdocs/miscellaneous/changelog.xml
Author: mturk
Date: Mon Dec 21 07:04:42 2009
New Revision: 892708
URL: http://svn.apache.org/viewvc?rev=892708&view=rev
Log:
Use poll instead select
Modified:
tomcat/jk/trunk/native/common/jk_connect.c
tomcat/jk/trunk/native/common/portable.h.sample
tomcat/jk/trunk/native/configure.in
tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
Modified: tomcat/jk/trunk/native/common/jk_connect.c
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_connect.c?rev=892708&r1=892707&r2=892708&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_connect.c (original)
+++ tomcat/jk/trunk/native/common/jk_connect.c Mon Dec 21 07:04:42 2009
@@ -42,6 +42,10 @@
/* FIONREAD on Solaris et al. */
#include <sys/filio.h>
#endif
+#ifdef HAVE_POLL_H
+/* Use poll instead select */
+#include <poll.h>
+#endif
#if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
#define JK_IS_SOCKET_ERROR(x) ((x) == SOCKET_ERROR)
@@ -864,6 +868,51 @@
* to allow for iterative waiting
* @remark Cares about errno
*/
+#ifdef HAVE_POLL
+int jk_is_input_event(jk_sock_t sd, int timeout, jk_logger_t *l)
+{
+ struct pollfd fds;
+ int rc;
+ int save_errno;
+
+ JK_TRACE_ENTER(l);
+
+ errno = 0;
+ fds.fd = sd;
+ fds.events = POLLIN;
+
+ do {
+ rc = poll(&fds, 1, timeout);
+ } while (rc < 0 && errno == EINTR);
+
+ if (rc == 0) {
+ /* Timeout. Set the errno to timeout */
+ errno = ETIMEDOUT;
+ JK_TRACE_EXIT(l);
+ return JK_FALSE;
+ }
+ else if (rc < 0) {
+ save_errno = errno;
+ jk_log(l, JK_LOG_WARNING,
+ "error during poll on socket sd = %d (errno=%d)", sd, errno);
+ errno = save_errno;
+ JK_TRACE_EXIT(l);
+ return JK_FALSE;
+ }
+ if ((fds.revents & (POLLERR | POLLHUP))) {
+ save_errno = fds.revents & (POLLERR | POLLHUP);
+ jk_log(l, JK_LOG_WARNING,
+ "error event during poll on socket sd = %d (event=%d)",
+ sd, save_errno);
+ errno = save_errno;
+ JK_TRACE_EXIT(l);
+ return JK_FALSE;
+ }
+ errno = 0;
+ JK_TRACE_EXIT(l);
+ return JK_TRUE;
+}
+#else
int jk_is_input_event(jk_sock_t sd, int timeout, jk_logger_t *l)
{
fd_set rset;
@@ -905,6 +954,7 @@
JK_TRACE_EXIT(l);
return JK_TRUE;
}
+#endif
/** Test if a socket is still connected
* @param sd socket to use
@@ -914,6 +964,46 @@
* @remark Always closes socket in case of error
* @remark Cares about errno
*/
+#ifdef HAVE_POLL
+int jk_is_socket_connected(jk_sock_t sd, jk_logger_t *l)
+{
+ struct pollfd fds;
+ int rc;
+
+ JK_TRACE_ENTER(l);
+
+ errno = 0;
+ fds.fd = sd;
+ fds.events = POLLIN;
+
+ do {
+ rc = poll(&fds, 1, 0);
+ } while (rc < 0 && errno == EINTR);
+
+ errno = 0;
+ if (rc == 0) {
+ /* If we get a timeout, then we are still connected */
+ JK_TRACE_EXIT(l);
+ return JK_TRUE;
+ }
+ else if (rc == 1 && fds.revents == POLLIN) {
+ char buf;
+ do {
+ rc = (int)recvfrom(sd, &buf, 1, MSG_PEEK, NULL, NULL);
+ } while (rc < 0 && errno == EINTR);
+ if (rc == 1) {
+ /* There is at least one byte to read. */
+ JK_TRACE_EXIT(l);
+ return JK_TRUE;
+ }
+ }
+ jk_shutdown_socket(sd, l);
+
+ JK_TRACE_EXIT(l);
+ return JK_FALSE;
+}
+
+#else
int jk_is_socket_connected(jk_sock_t sd, jk_logger_t *l)
{
fd_set fd;
@@ -970,3 +1060,5 @@
JK_TRACE_EXIT(l);
return JK_FALSE;
}
+#endif
+
Modified: tomcat/jk/trunk/native/common/portable.h.sample
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/portable.h.sample?rev=892708&r1=892707&r2=892708&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/portable.h.sample (original)
+++ tomcat/jk/trunk/native/common/portable.h.sample Mon Dec 21 07:04:42 2009
@@ -24,6 +24,12 @@
/* Have flock() */
#define HAVE_FLOCK 1
+/* Have poll() */
+#define HAVE_POLL 1
+
+/* Define to 1 if you have the <poll.h> header file. */
+#define HAVE_POLL_H 1
+
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -112,4 +118,5 @@
#define USE_SO_SNDTIMEO 1
/* Version number of package */
-#define VERSION "1.2.28"
+#define VERSION "1.2.29"
+
Modified: tomcat/jk/trunk/native/configure.in
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/configure.in?rev=892708&r1=892707&r2=892708&view=diff
==============================================================================
--- tomcat/jk/trunk/native/configure.in (original)
+++ tomcat/jk/trunk/native/configure.in Mon Dec 21 07:04:42 2009
@@ -319,6 +319,11 @@
JK_CHECK_SETSOCKOPT(SO_RCVTIMEO)
JK_CHECK_SETSOCKOPT(SO_SNDTIMEO)
+dnl check for poll.h header
+AC_CHECK_HEADERS(poll.h)
+dnl check for poll function
+AC_CHECK_FUNC(poll, AC_DEFINE(HAVE_POLL,1,[Have poll()]))
+
dnl Apache-2.0 needs the os subdirectory to include os.h
dnl this include is copy from os/config.m4
sinclude(../support/os_apache.m4)
Modified: tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml?rev=892708&r1=892707&r2=892708&view=diff
==============================================================================
--- tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/jk/trunk/xdocs/miscellaneous/changelog.xml Mon Dec 21 07:04:42 2009
@@ -44,6 +44,10 @@
<subsection name="Native">
<changelog>
<fix>
+ <bug>48410</bug>: Use poll instead select so we can work with more.
+ then 1024 sockets. (mturk)
+ </fix>
+ <fix>
<bug>47867</bug>: IIS: crash during startup, when compiled with VS2008
and workers.properties contains unsupported properties.
Patch provided by Indrek Juhani (rjung)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org