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/25 15:35:30 UTC

svn commit: r372227 - in /webservices/axis2/trunk/c: include/ modules/core/transport/http/ modules/core/transport/http/receiver/ modules/core/transport/http/sender/ modules/core/transport/http/server/

Author: sahan
Date: Wed Jan 25 06:35:15 2006
New Revision: 372227

URL: http://svn.apache.org/viewcvs?rev=372227&view=rev
Log:
user can specify the timeout in command line. Fixed some crashes due to not checking null pointers

Modified:
    webservices/axis2/trunk/c/include/axis2_http_server.h
    webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h
    webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
    webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c
    webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c
    webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c

Modified: webservices/axis2/trunk/c/include/axis2_http_server.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_http_server.h?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_server.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_server.h Wed Jan 25 06:35:15 2006
@@ -38,7 +38,7 @@
  * @ingroup axis2_core_transport_http
  * @{
  */
-
+int axis2_http_socket_read_timeout = 0;
 AXIS2_DECLARE(axis2_transport_receiver_t *) 
 axis2_http_server_create (axis2_env_t **env, axis2_char_t *repo, int port);
 

Modified: webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h (original)
+++ webservices/axis2/trunk/c/include/axis2_simple_http_svr_conn.h Wed Jan 25 06:35:15 2006
@@ -37,7 +37,8 @@
     typedef struct axis2_simple_http_svr_conn_ops 
                     axis2_simple_http_svr_conn_ops_t;
     typedef struct axis2_simple_http_svr_conn axis2_simple_http_svr_conn_t;
-    
+  
+	extern int axis2_http_socket_read_timeout;	
 /**
  * @ingroup axis2_core_transport_http
  * @{

Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c Wed Jan 25 06:35:15 2006
@@ -149,6 +149,10 @@
 	xml_reader = axis2_xml_reader_create_for_memory(env, 
 						axis2_http_transport_utils_on_data_request, 
 						(void *)&callback_ctx, NULL);
+	if(NULL == xml_reader)
+	{
+		return AXIS2_FAILURE;
+	}
 	char_set = axis2_http_transport_utils_get_charset_enc(env,content_type);
 	/* TODO set the charset of the stream before (at least default)
 	 *	we read them
@@ -156,13 +160,35 @@
 	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_CHARACTER_SET_ENCODING,
 					char_set, AXIS2_TRUE);
 	om_builder = axis2_om_stax_builder_create(env, xml_reader);
+	if(NULL == om_builder)
+	{
+		AXIS2_XML_READER_FREE(xml_reader, env);
+		xml_reader = NULL;
+		return AXIS2_FAILURE;
+	}
 	if(NULL != strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP))
 	{
 		is_soap11 = AXIS2_FALSE;
 		soap_builder = axis2_soap_builder_create(env, om_builder, 
                     AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI);
+		if(NULL == soap_builder)
+		{
+			AXIS2_OM_STAX_BUILDER_FREE(om_builder, env);
+			om_builder = NULL;
+			xml_reader = NULL;
+			return AXIS2_FAILURE;
+		}
 		soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(soap_builder,
 					env);
+		if(NULL == soap_envelope)
+		{
+			AXIS2_OM_STAX_BUILDER_FREE(om_builder, env);
+			om_builder = NULL;
+			xml_reader = NULL;
+			AXIS2_SOAP_BUILDER_FREE(soap_builder, env);
+			soap_builder = NULL;
+			return AXIS2_FAILURE;
+		}
 	}
 	else if(NULL != strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML))
 	{
@@ -172,8 +198,24 @@
 		{
 			soap_builder = axis2_soap_builder_create(env, om_builder, 
 						AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI);
+			if(NULL == soap_builder)
+			{
+				AXIS2_OM_STAX_BUILDER_FREE(om_builder, env);
+				om_builder = NULL;
+				xml_reader = NULL;
+				return AXIS2_FAILURE;
+			}
 			soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(
 					soap_builder, env);
+			if(NULL == soap_envelope)
+			{
+				AXIS2_OM_STAX_BUILDER_FREE(om_builder, env);
+				om_builder = NULL;
+				xml_reader = NULL;
+				AXIS2_SOAP_BUILDER_FREE(soap_builder, env);
+				soap_builder = NULL;
+				return AXIS2_FAILURE;
+			}
 		}
 		/* REST support
 		 * else

Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_worker.c Wed Jan 25 06:35:15 2006
@@ -321,8 +321,11 @@
 	{
         axis2_ctx_t *ctx = AXIS2_OP_CTX_GET_BASE(AXIS2_MSG_CTX_GET_OP_CTX(
                                 msg_ctx, env), env);
-        if (ctx)
-    		ctx_written = AXIS2_CTX_GET_PROPERTY(ctx, env, AXIS2_RESPONSE_WRITTEN, AXIS2_FALSE);
+        if (NULL != ctx)
+		{
+    		ctx_written = AXIS2_CTX_GET_PROPERTY(ctx, env, 
+						AXIS2_RESPONSE_WRITTEN, AXIS2_FALSE);
+		}
 	}
 	if(NULL != ctx_written && AXIS2_STRCASECMP(ctx_written, "TRUE") == 0)
 	{
@@ -394,8 +397,9 @@
         }
         else
         {
-            if(AXIS2_HTTP_SIMPLE_RESPONSE_GET_HTTP_VERSION(simple_response, env) &&
-                    AXIS2_STRCASECMP(AXIS2_HTTP_SIMPLE_RESPONSE_GET_HTTP_VERSION(
+            if(AXIS2_HTTP_SIMPLE_RESPONSE_GET_HTTP_VERSION(simple_response, env)
+					&& AXIS2_STRCASECMP(
+					AXIS2_HTTP_SIMPLE_RESPONSE_GET_HTTP_VERSION(
                     simple_response, env), AXIS2_HTTP_HEADER_PROTOCOL_11))
             {
                 AXIS2_SIMPLE_HTTP_SVR_CONN_SET_KEEP_ALIVE(svr_conn, env, 
@@ -407,7 +411,7 @@
                     AXIS2_FALSE);
             }
         }
-        if(AXIS2_TRUE == AXIS2_HTTP_SIMPLE_RESPONSE_CONTAINS_HEADER(
+        if(AXIS2_FALSE == AXIS2_HTTP_SIMPLE_RESPONSE_CONTAINS_HEADER(
                     simple_response, env, AXIS2_HTTP_HEADER_TRANSFER_ENCODING))
         {
             if(0 != content_length)
@@ -415,7 +419,7 @@
                 axis2_char_t content_len_str[10];
 				axis2_http_header_t *content_len_hdr = NULL;
 				
-                sprintf(content_len_str, "%10d", content_length);
+                sprintf(content_len_str, "%d", content_length);
                 content_len_hdr = axis2_http_header_create(
                     env, AXIS2_HTTP_HEADER_CONTENT_LENGTH, content_len_str);
                 AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(simple_response, env,

Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/http_svr_thread.c Wed Jan 25 06:35:15 2006
@@ -159,6 +159,9 @@
 		axis2_simple_http_svr_conn_t *svr_conn = NULL;
 		axis2_http_simple_request_t *request = NULL;
 		char log_str[128];
+		int millisecs = 0;
+		double secs = 0;
+		axis2_http_worker_t *tmp = NULL;
 		
 		socket = axis2_network_handler_svr_socket_accept(env, 
 						svr_thread_impl->listen_socket);
@@ -169,13 +172,12 @@
 		AXIS2_PLATFORM_GET_TIME_IN_MILLIS(&t1);
 		svr_conn = axis2_simple_http_svr_conn_create(env, socket);
 		request = AXIS2_SIMPLE_HTTP_SVR_CONN_READ_REQUEST(svr_conn, env);
-		axis2_http_worker_t *tmp = svr_thread_impl->worker;        
 		tmp = svr_thread_impl->worker;
 		AXIS2_HTTP_WORKER_PROCESS_REQUEST(tmp, env, svr_conn, request);
 		AXIS2_SIMPLE_HTTP_SVR_CONN_FREE(svr_conn, env);
 		AXIS2_PLATFORM_GET_TIME_IN_MILLIS(&t2);
-		int millisecs = t2.millitm - t1.millitm;
-		double secs = difftime(t2.time, t1.time);
+		millisecs = t2.millitm - t1.millitm;
+		secs = difftime(t2.time, t1.time);
 		if(millisecs < 0)
 		{
 			millisecs += 1000;

Modified: webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/receiver/simple_http_svr_conn.c Wed Jan 25 06:35:15 2006
@@ -100,7 +100,8 @@
     svr_conn_impl->keep_alive = AXIS2_FALSE;
 	
 	/* set the socket timeout to 30 seconds */
-	axis2_network_handler_set_sock_option(env, sockfd, SO_RCVTIMEO, 30000);
+	axis2_network_handler_set_sock_option(env, sockfd, SO_RCVTIMEO, 
+						axis2_http_socket_read_timeout);
     
 	if(-1 != svr_conn_impl->socket)
 	{

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c Wed Jan 25 06:35:15 2006
@@ -216,10 +216,6 @@
 	 */
 	{
 		soap_data_out = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
-		if(NULL != soap_data_out)
-		{
-			data_out = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(soap_data_out, env);
-		}
 	}
 	if(NULL != epr)
 	{
@@ -258,7 +254,8 @@
 			/* AXIS2_OM_OUTPUT_SET_DO_OPTIMIZE(om_output, env, 
 			 *				AXIS2_MSG_CTX_GET_IS_DOING_MTOM(msg_ctx, env);
 			 */
-			AXIS2_OM_NODE_SERIALIZE (data_out, env, om_output);
+			AXIS2_SOAP_ENVELOPE_SERIALIZE (soap_data_out, env, om_output, 
+						AXIS2_FALSE);
 			buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
 			AXIS2_STREAM_WRITE(out_stream, env, buffer, AXIS2_STRLEN(buffer));				
 			AXIS2_FREE((*env)->allocator, buffer);

Modified: webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c?rev=372227&r1=372226&r2=372227&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c Wed Jan 25 06:35:15 2006
@@ -63,7 +63,14 @@
 	{
 	    repo = argv[2];
 	}
-    
+    if(argc > 3)
+	{
+		axis2_http_socket_read_timeout = atoi(argv[3]);
+	}
+	else
+	{
+		axis2_http_socket_read_timeout = AXIS2_HTTP_DEFAULT_SO_TIMEOUT;
+	}
 	allocator = axis2_allocator_init(NULL);
     
 	if(NULL == allocator)
@@ -81,10 +88,14 @@
 	AXIS2_LOG_WRITE(env->log, "[Axis2]Starting Axis2 HTTP server....\n", 
 						AXIS2_LOG_INFO);
 	sprintf(tmp_str, "[Axis2]Server port : %d", port);
-	printf(tmp_str);
+	printf("%s\n",tmp_str);
 	AXIS2_LOG_WRITE(env->log, tmp_str, AXIS2_LOG_INFO);
 	sprintf(tmp_str, "[Axis2]Repo location : %s", repo);
-	printf(tmp_str);
+	printf("%s\n",tmp_str);
+	AXIS2_LOG_WRITE(env->log, tmp_str, AXIS2_LOG_INFO);
+	sprintf(tmp_str, "[Axis2]Read Timeout : %d ms", 
+						axis2_http_socket_read_timeout);
+	printf("%s\n",tmp_str);
 	AXIS2_LOG_WRITE(env->log, tmp_str, AXIS2_LOG_INFO);
 	
 	server = axis2_http_server_create(&env, repo, port);
@@ -92,7 +103,7 @@
 	{
 		sprintf(tmp_str, "[Axis2]Server creation failed: Error code: %d", 
 						env->error->error_number);
-		printf(tmp_str);
+		printf("%s\n",tmp_str);
         printf("%s \n", AXIS2_ERROR_GET_MESSAGE(env->error));
 		AXIS2_LOG_WRITE(env->log, tmp_str, AXIS2_LOG_INFO);
 		system_exit(allocator, env, -1);