tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Whittington <tim.whitting...@orionhealth.com>
Subject Re: svn commit: r893452 - /tomcat/jk/trunk/native/common/jk_connect.c
Date Thu, 07 Jan 2010 09:41:02 GMT
This appears to have broken my build on Windows (VC 2005). 

SHUT_RD is SD_RECEIVE on Windows? 

cheers 
tim 
----- Original Message ----- 
From: mturk@apache.org 
To: dev@tomcat.apache.org 
Sent: Wednesday, 23 December, 2009 11:01:47 PM GMT +12:00 New Zealand 
Subject: svn commit: r893452 - /tomcat/jk/trunk/native/common/jk_connect.c 

Author: mturk 
Date: Wed Dec 23 10:01:47 2009 
New Revision: 893452 

URL: http://svn.apache.org/viewvc?rev=893452&view=rev 
Log: 
Use smarter shutdown. In case we don't receive the full buffer break from loop. This shoud
lower down the shutdown to 2 sec max 

Modified: 
tomcat/jk/trunk/native/common/jk_connect.c 

Modified: tomcat/jk/trunk/native/common/jk_connect.c 
URL: http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_connect.c?rev=893452&r1=893451&r2=893452&view=diff

============================================================================== 
--- tomcat/jk/trunk/native/common/jk_connect.c (original) 
+++ tomcat/jk/trunk/native/common/jk_connect.c Wed Dec 23 10:01:47 2009 
@@ -694,8 +694,8 @@ 
char dummy[512]; 
int rc = 0; 
int rd = 0; 
+ int rp = 0; 
int save_errno; 
- fd_set rs; 
struct timeval tv; 
time_t start = time(NULL); 

@@ -722,10 +722,16 @@ 
return rc; 
} 

- /* Set up to wait for readable data on socket... */ 
- FD_ZERO(&rs); 
- 
do { 
+#ifdef HAVE_POLL 
+ struct pollfd fds; 
+ 
+ fds.fd = sd; 
+ fds.events = POLLIN; 
+#else 
+ fd_set rs; 
+ 
+ FD_ZERO(&rs); 
/* Read all data from the peer until we reach "end-of-file" 
* (FIN from peer) or we've exceeded our overall timeout. If the 
* backend does not send us bytes within 2 seconds 
@@ -735,8 +741,14 @@ 
FD_SET(sd, &rs); 
tv.tv_sec = SECONDS_TO_LINGER; 
tv.tv_usec = 0; 
- 
- if (select((int)sd + 1, &rs, NULL, NULL, &tv) > 0) { 
+#endif 
+ rp = 0; 
+#ifdef HAVE_POLL 
+ if (poll(&fds, 1, SECONDS_TO_LINGER * 1000) > 0) 
+#else 
+ if (select((int)sd + 1, &rs, NULL, NULL, &tv) > 0) 
+#endif 
+ { 
do { 
#if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__)) 
rc = recv(sd, &dummy[0], sizeof(dummy), 0); 
@@ -746,7 +758,7 @@ 
rc = read(sd, &dummy[0], sizeof(dummy)); 
#endif 
if (rc > 0) 
- rd += rc; 
+ rp += rc; 
} while (JK_IS_SOCKET_ERROR(rc) && (errno == EINTR || errno == EAGAIN)); 

if (rc <= 0) 
@@ -754,7 +766,27 @@ 
} 
else 
break; 
- 
+ rd += rp; 
+ if (rp < sizeof(dummy)) { 
+ /* We have readed less then size of buffer 
+ * It's a good chance there will be no more data 
+ * to read. 
+ */ 
+ if ((rc = sononblock(sd))) { 
+ rc = jk_close_socket(sd, l); 
+ if (JK_IS_DEBUG_LEVEL(l)) 
+ jk_log(l, JK_LOG_DEBUG, 
+ "error setting socket %d to nonblocking", sd); 
+ errno = save_errno; 
+ JK_TRACE_EXIT(l); 
+ return rc; 
+ } 
+ if (JK_IS_DEBUG_LEVEL(l)) 
+ jk_log(l, JK_LOG_DEBUG, 
+ "shutting down the read side of socket %d", sd); 
+ shutdown(sd, SHUT_RD); 
+ break; 
+ } 
} while (difftime(time(NULL), start) < MAX_SECS_TO_LINGER); 

rc = jk_close_socket(sd, l); 



--------------------------------------------------------------------- 
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org 
For additional commands, e-mail: dev-help@tomcat.apache.org 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message