You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/01/22 05:51:43 UTC
svn commit: r371186 - /webservices/axis2/trunk/c/modules/util/stream.c
Author: samisa
Date: Sat Jan 21 20:51:39 2006
New Revision: 371186
URL: http://svn.apache.org/viewcvs?rev=371186&view=rev
Log:
Added timeout to socket read to make sure the SOAP builder callback does not block infinitely
Modified:
webservices/axis2/trunk/c/modules/util/stream.c
Modified: webservices/axis2/trunk/c/modules/util/stream.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/stream.c?rev=371186&r1=371185&r2=371186&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/stream.c (original)
+++ webservices/axis2/trunk/c/modules/util/stream.c Sat Jan 21 20:51:39 2006
@@ -556,7 +556,8 @@
stream_impl->stream_type = AXIS2_STREAM_SOCKET;
stream_impl->socket = socket;
- stream_impl->fp = fdopen(socket, "w+");
+ stream_impl->fp = NULL;
+ /*stream_impl->fp = fdopen(socket, "w+");*/
if(NULL == stream_impl->fp)
{
axis2_stream_free(def_stream, env);
@@ -574,7 +575,7 @@
void *buffer, size_t count)
{
FILE *fp = NULL;
-
+ int len = 0;
AXIS2_FUNC_PARAM_CHECK(stream, env, AXIS2_CRTICAL_FAILURE);
if(-1 == AXIS2_INTF_TO_IMPL(stream)->socket)
@@ -593,8 +594,24 @@
{
return -1;
}
- /*return fread(buffer, sizeof(axis2_char_t), count, fp); */
- return read(AXIS2_INTF_TO_IMPL(stream)->socket, buffer, count);
+ /*--- set timeout ---*/
+ fd_set set;
+ struct timeval timeout;
+
+ FD_ZERO( &set); /* initialize the file descriptor set.*/
+ FD_SET( AXIS2_INTF_TO_IMPL(stream)->socket, &set);
+
+ timeout.tv_sec = 5; /* initialize the timeout data structure. */
+ timeout.tv_usec = 0;
+
+
+ int ret = select( FD_SETSIZE, &set, NULL, NULL, &timeout); /* select returns 0 if timeout,
+ 1 if input available, -1 if error. */
+ /*--- end set timeout ---*/
+
+ if (ret > 0) /* read socket only if data available */
+ len = read(AXIS2_INTF_TO_IMPL(stream)->socket, buffer, count);
+ return len;
}
int AXIS2_CALL