axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r804873 - in /webservices/axis2/trunk/c/src/core/transport: http/receiver/http_receiver.c http/receiver/http_svr_thread.c http/server/simple_axis2_server/http_server_main.c transport_receiver.c
Date Mon, 17 Aug 2009 06:31:02 GMT
Author: shankar
Date: Mon Aug 17 06:31:01 2009
New Revision: 804873

URL: http://svn.apache.org/viewvc?rev=804873&view=rev
Log:
code formatting

Modified:
    webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c
    webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c
    webservices/axis2/trunk/c/src/core/transport/http/server/simple_axis2_server/http_server_main.c
    webservices/axis2/trunk/c/src/core/transport/transport_receiver.c

Modified: webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c?rev=804873&r1=804872&r2=804873&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/receiver/http_receiver.c Mon Aug 17
06:31:01 2009
@@ -1,4 +1,3 @@
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -17,7 +16,6 @@
  */
 
 #include <axis2_http_server.h>
-
 #include <axis2_http_transport.h>
 #include <axis2_http_svr_thread.h>
 #include <axis2_transport_in_desc.h>
@@ -26,9 +24,10 @@
 #include <axis2_conf_init.h>
 #include <stdlib.h>
 
+
 /**
  * @brief HTTP Client struct impl
- *   Axis2 HTTP Client impl
+ * Axis2 HTTP Client impl
  */
 
 typedef struct axis2_http_server_impl
@@ -38,42 +37,48 @@
     int port;
     axis2_conf_ctx_t *conf_ctx;
     axis2_conf_ctx_t *conf_ctx_private;
-}
-axis2_http_server_impl_t;
+} axis2_http_server_impl_t;
 
 #define AXIS2_INTF_TO_IMPL(http_server) \
-                ((axis2_http_server_impl_t *)(http_server))
+    ((axis2_http_server_impl_t *)(http_server))
 
 /***************************** Function headers *******************************/
 
-axis2_status_t AXIS2_CALL axis2_http_server_init(
+static axis2_status_t AXIS2_CALL
+axis2_http_server_init(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env,
     axis2_conf_ctx_t * conf_ctx,
     axis2_transport_in_desc_t * in_desc);
 
-axis2_status_t AXIS2_CALL axis2_http_server_start(
+static axis2_status_t AXIS2_CALL
+axis2_http_server_start(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env);
 
-axis2_status_t AXIS2_CALL axis2_http_server_stop(
+static axis2_status_t AXIS2_CALL
+axis2_http_server_stop(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env);
 
-axis2_conf_ctx_t *AXIS2_CALL axis2_http_server_get_conf_ctx(
+static axis2_conf_ctx_t *AXIS2_CALL
+axis2_http_server_get_conf_ctx(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env);
 
-axis2_endpoint_ref_t *AXIS2_CALL axis2_http_server_get_reply_to_epr(
+static axis2_endpoint_ref_t *AXIS2_CALL
+axis2_http_server_get_reply_to_epr(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env,
     const axis2_char_t * svc_name);
 
-axis2_bool_t AXIS2_CALL axis2_http_server_is_running(
+static axis2_bool_t AXIS2_CALL
+axis2_http_server_is_running(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env);
 
-void AXIS2_CALL axis2_http_server_free(
+static void AXIS2_CALL
+axis2_http_server_free(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env);
 
@@ -84,8 +89,7 @@
     axis2_http_server_get_conf_ctx,
     axis2_http_server_is_running,
     axis2_http_server_stop,
-    axis2_http_server_free
-};
+    axis2_http_server_free };
 
 AXIS2_EXTERN axis2_transport_receiver_t *AXIS2_CALL
 axis2_http_server_create(
@@ -95,10 +99,10 @@
 {
     axis2_http_server_impl_t *server_impl = NULL;
 
-    server_impl = (axis2_http_server_impl_t *) AXIS2_MALLOC
-        (env->allocator, sizeof(axis2_http_server_impl_t));
+    server_impl = (axis2_http_server_impl_t *)AXIS2_MALLOC(env->allocator,
+        sizeof(axis2_http_server_impl_t));
 
-    if (!server_impl)
+    if(!server_impl)
     {
         AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
@@ -111,7 +115,7 @@
 
     server_impl->http_server.ops = &http_transport_receiver_ops_var;
 
-    if (repo)
+    if(repo)
     {
 
         /**
@@ -121,13 +125,11 @@
          * may lead to double free
          */
         server_impl->conf_ctx_private = axis2_build_conf_ctx(env, repo);
-        if (!server_impl->conf_ctx_private)
+        if(!server_impl->conf_ctx_private)
         {
-            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, 
-                             "unable to create private configuration context\
-for repo path %s", repo);
-            axis2_http_server_free((axis2_transport_receiver_t *) server_impl,
-                                   env);
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                "unable to create private configuration context for repo path %s", repo);
+            axis2_http_server_free((axis2_transport_receiver_t *)server_impl, env);
             return NULL;
         }
         server_impl->conf_ctx = server_impl->conf_ctx_private;
@@ -136,7 +138,6 @@
     return &(server_impl->http_server);
 }
 
-
 AXIS2_EXTERN axis2_transport_receiver_t *AXIS2_CALL
 axis2_http_server_create_with_file(
     const axutil_env_t * env,
@@ -145,10 +146,10 @@
 {
     axis2_http_server_impl_t *server_impl = NULL;
 
-    server_impl = (axis2_http_server_impl_t *) AXIS2_MALLOC
-        (env->allocator, sizeof(axis2_http_server_impl_t));
+    server_impl = (axis2_http_server_impl_t *)AXIS2_MALLOC(env->allocator,
+        sizeof(axis2_http_server_impl_t));
 
-    if (!server_impl)
+    if(!server_impl)
     {
         AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
@@ -161,7 +162,7 @@
 
     server_impl->http_server.ops = &http_transport_receiver_ops_var;
 
-    if (file)
+    if(file)
     {
 
         /**
@@ -170,15 +171,13 @@
          * server_impl->conf_ctx because it may own to any other object which
          * may lead to double free
          */
-        server_impl->conf_ctx_private = 
-			axis2_build_conf_ctx_with_file (env, file);
-		
-        if (!server_impl->conf_ctx_private)
+        server_impl->conf_ctx_private = axis2_build_conf_ctx_with_file(env, file);
+
+        if(!server_impl->conf_ctx_private)
         {
-            axis2_http_server_free((axis2_transport_receiver_t *) server_impl,
-                                   env);
-            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "unable to create\
-configuration context for file %s", file);
+            axis2_http_server_free((axis2_transport_receiver_t *)server_impl, env);
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                "unable to create configuration context for file %s", file);
             return NULL;
         }
         server_impl->conf_ctx = server_impl->conf_ctx_private;
@@ -187,30 +186,28 @@
     return &(server_impl->http_server);
 }
 
-
-void AXIS2_CALL
+static void AXIS2_CALL
 axis2_http_server_free(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env)
 {
     axis2_http_server_impl_t *server_impl = NULL;
 
-    if (!server)
+    if(!server)
     {
-        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, 
-                         "failure, server value is null , nothing to free");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failure, server value is null , nothing
to free");
         return;
     }
 
     server_impl = AXIS2_INTF_TO_IMPL(server);
-    if (server_impl->svr_thread)
+    if(server_impl->svr_thread)
     {
         axis2_http_svr_thread_destroy(server_impl->svr_thread, env);
         axis2_http_svr_thread_free(server_impl->svr_thread, env);
         server_impl->svr_thread = NULL;
     }
 
-    if (server_impl->conf_ctx_private)
+    if(server_impl->conf_ctx_private)
     {
         axis2_conf_ctx_free(server_impl->conf_ctx_private, env);
         server_impl->conf_ctx_private = NULL;
@@ -222,11 +219,9 @@
     server_impl->conf_ctx = NULL;
 
     AXIS2_FREE(env->allocator, server_impl);
-    return;
 }
 
-
-axis2_status_t AXIS2_CALL
+static axis2_status_t AXIS2_CALL
 axis2_http_server_init(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env,
@@ -237,30 +232,28 @@
     axis2_char_t *port_str = NULL;
     axutil_param_t *param = NULL;
 
-    AXIS2_PARAM_CHECK (env->error, server, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK (env->error, conf_ctx, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK (env->error, in_desc, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, server, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, in_desc, AXIS2_FAILURE);
 
     server_impl = AXIS2_INTF_TO_IMPL(server);
 
     server_impl->conf_ctx = conf_ctx;
-    param =
-        (axutil_param_t *)
-        axutil_param_container_get_param(axis2_transport_in_desc_param_container
-                                         (in_desc, env), env, AXIS2_PORT_STRING);
-    if (param)
+    param = (axutil_param_t *)axutil_param_container_get_param(
+        axis2_transport_in_desc_param_container(in_desc, env), env, AXIS2_PORT_STRING);
+    if(param)
     {
         port_str = axutil_param_get_value(param, env);
     }
 
-    if (port_str)
+    if(port_str)
     {
         server_impl->port = atoi(port_str);
     }
     return AXIS2_SUCCESS;
 }
 
-axis2_status_t AXIS2_CALL
+static axis2_status_t AXIS2_CALL
 axis2_http_server_start(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env)
@@ -269,26 +262,19 @@
     axis2_http_server_impl_t *server_impl = NULL;
     axis2_http_worker_t *worker = NULL;
 
-    AXIS2_PARAM_CHECK (env->error, server, AXIS2_FAILURE);
-
     server_impl = AXIS2_INTF_TO_IMPL(server);
-    server_impl->svr_thread = axis2_http_svr_thread_create(env,
-                                                           server_impl->port);
-    if (!server_impl->svr_thread)
-    {
-        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
-                         "unable to create server thread for port %d",
-                         server_impl->port);
-
+    server_impl->svr_thread = axis2_http_svr_thread_create(env, server_impl->port);
+    if(!server_impl->svr_thread)
+    {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "unable to create server thread for port
%d",
+            server_impl->port);
         return AXIS2_FAILURE;
     }
 
     worker = axis2_http_worker_create(env, server_impl->conf_ctx);
-    if (!worker)
+    if(!worker)
     {
-        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
-                         "axis2 http worker creation failed");
-
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "axis2 http worker creation failed");
         axis2_http_svr_thread_free(server_impl->svr_thread, env);
         return AXIS2_FAILURE;
     }
@@ -299,33 +285,29 @@
     return AXIS2_SUCCESS;
 }
 
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
+static AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_server_stop(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env)
 {
-
-    AXIS2_PARAM_CHECK (env->error, server, AXIS2_FAILURE);
     AXIS2_LOG_INFO(env->log, "Terminating HTTP server thread");
-    if (AXIS2_INTF_TO_IMPL(server)->svr_thread)
+    if(AXIS2_INTF_TO_IMPL(server)->svr_thread)
     {
-        axis2_http_svr_thread_destroy(AXIS2_INTF_TO_IMPL(server)->svr_thread,
-                                      env);
+        axis2_http_svr_thread_destroy(AXIS2_INTF_TO_IMPL(server)->svr_thread, env);
     }
-    AXIS2_LOG_INFO(env->log, "Successfully terminated  HTTP server" " thread");
+    AXIS2_LOG_INFO(env->log, "Successfully terminated  HTTP server thread");
     return AXIS2_SUCCESS;
 }
 
-axis2_conf_ctx_t *AXIS2_CALL
+static axis2_conf_ctx_t *AXIS2_CALL
 axis2_http_server_get_conf_ctx(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env)
 {
-    AXIS2_PARAM_CHECK (env->error, server, NULL);
     return AXIS2_INTF_TO_IMPL(server)->conf_ctx;
 }
 
-axis2_endpoint_ref_t *AXIS2_CALL
+static axis2_endpoint_ref_t *AXIS2_CALL
 axis2_http_server_get_reply_to_epr(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env,
@@ -336,16 +318,15 @@
     axis2_char_t *svc_path = NULL;
     axutil_url_t *url = NULL;
 
-    AXIS2_PARAM_CHECK(env->error, svc_name, NULL);
-    AXIS2_PARAM_CHECK(env->error, server, NULL);
-
     host_address = AXIS2_DEFAULT_HOST_ADDRESS; /* TODO : get from axis2.xml */
     svc_path = axutil_stracat(env, AXIS2_DEFAULT_SVC_PATH, svc_name);
     url = axutil_url_create(env, AXIS2_HTTP_PROTOCOL, host_address,
-                            AXIS2_INTF_TO_IMPL(server)->port, svc_path);
+        AXIS2_INTF_TO_IMPL(server)->port, svc_path);
     AXIS2_FREE(env->allocator, svc_path);
-    if (!url)
+    if(!url)
     {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+            "Cannot create reply to epr for service %s.", svc_name);
         return NULL;
     }
     epr = axis2_endpoint_ref_create(env, axutil_url_to_external_form(url, env));
@@ -353,16 +334,14 @@
     return epr;
 }
 
-
-axis2_bool_t AXIS2_CALL
+static axis2_bool_t AXIS2_CALL
 axis2_http_server_is_running(
     axis2_transport_receiver_t * server,
     const axutil_env_t * env)
 {
     axis2_http_server_impl_t *server_impl = NULL;
-    AXIS2_PARAM_CHECK (env->error, server, AXIS2_FALSE);
     server_impl = AXIS2_INTF_TO_IMPL(server);
-    if (server_impl->svr_thread)
+    if(server_impl->svr_thread)
     {
         return axis2_http_svr_thread_is_running(server_impl->svr_thread, env);
     }
@@ -378,7 +357,7 @@
     const axutil_env_t * env)
 {
     *inst = axis2_http_server_create(env, NULL, -1);
-    if (!(*inst))
+    if(!(*inst))
     {
         return AXIS2_FAILURE;
     }
@@ -391,7 +370,7 @@
     axis2_transport_receiver_t * inst,
     const axutil_env_t * env)
 {
-    if (inst)
+    if(inst)
     {
         axis2_transport_receiver_free(inst, env);
     }

Modified: webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c?rev=804873&r1=804872&r2=804873&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/receiver/http_svr_thread.c Mon Aug 17
06:31:01 2009
@@ -1,4 +1,3 @@
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -47,10 +46,8 @@
     axutil_thread_t *thread;
 } axis2_http_svr_thd_args_t;
 
-AXIS2_EXTERN const axutil_env_t *AXIS2_CALL init_thread_env(
-    const axutil_env_t ** system_env);
-
-void *AXIS2_THREAD_FUNC axis2_svr_thread_worker_func(
+static void *AXIS2_THREAD_FUNC
+axis2_svr_thread_worker_func(
     axutil_thread_t * thd,
     void *data);
 
@@ -61,25 +58,24 @@
 {
     axis2_http_svr_thread_t *svr_thread = NULL;
 
-    svr_thread = (axis2_http_svr_thread_t *) AXIS2_MALLOC
-        (env->allocator, sizeof(axis2_http_svr_thread_t));
+    svr_thread = (axis2_http_svr_thread_t *)AXIS2_MALLOC(env->allocator,
+        sizeof(axis2_http_svr_thread_t));
 
-    if (!svr_thread)
+    if(!svr_thread)
     {
         AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
 
-    memset ((void *)svr_thread, 0, sizeof (axis2_http_svr_thread_t));
-    svr_thread->worker = NULL;
-    svr_thread->stopped = AXIS2_FALSE;
-    svr_thread->port = port;
+    memset((void *)svr_thread, 0, sizeof(axis2_http_svr_thread_t));
 
-    svr_thread->listen_socket = (int)
-        axutil_network_handler_create_server_socket (env, svr_thread->port);
-    if (-1 == svr_thread->listen_socket)
+    svr_thread->port = port;
+    svr_thread->listen_socket = (int)axutil_network_handler_create_server_socket(env,
+        svr_thread->port);
+    if(-1 == svr_thread->listen_socket)
     {
-        axis2_http_svr_thread_free((axis2_http_svr_thread_t *) svr_thread, env);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Http server thread socket creation failed.");
+        axis2_http_svr_thread_free((axis2_http_svr_thread_t *)svr_thread, env);
         return NULL;
     }
 
@@ -91,18 +87,17 @@
     axis2_http_svr_thread_t * svr_thread,
     const axutil_env_t * env)
 {
-
-    if (!svr_thread)
+    if(!svr_thread)
     {
         return;
     }
 
-    if (svr_thread->worker)
+    if(svr_thread->worker)
     {
         axis2_http_worker_free(svr_thread->worker, env);
         svr_thread->worker = NULL;
     }
-    if (-1 != svr_thread->listen_socket)
+    if(-1 != svr_thread->listen_socket)
     {
         axutil_network_handler_close_socket(env, svr_thread->listen_socket);
         svr_thread->listen_socket = -1;
@@ -110,7 +105,6 @@
     svr_thread->stopped = AXIS2_TRUE;
 
     AXIS2_FREE(env->allocator, svr_thread);
-    return;
 }
 
 axis2_status_t AXIS2_CALL
@@ -118,69 +112,61 @@
     axis2_http_svr_thread_t * svr_thread,
     const axutil_env_t * env)
 {
-
-    while (AXIS2_FALSE == svr_thread->stopped)
+    while(AXIS2_FALSE == svr_thread->stopped)
     {
         int socket = -1;
         axis2_http_svr_thd_args_t *arg_list = NULL;
         axutil_thread_t *worker_thread = NULL;
 
-        socket = (int)axutil_network_handler_svr_socket_accept(env,
-                                                          svr_thread->
-                                                          listen_socket);
-        if (!svr_thread->worker)
+        socket = (int)axutil_network_handler_svr_socket_accept(env, svr_thread-> listen_socket);
+        if(!svr_thread->worker)
         {
-            AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "Worker not ready yet."
-                              " Cannot serve the request");
+            AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI,
+                "Worker not ready yet. Cannot serve the request");
             axutil_network_handler_close_socket(env, socket);
             continue;
         }
 
-        arg_list = AXIS2_MALLOC(env->allocator,
-                                sizeof(axis2_http_svr_thd_args_t));
-        if (!arg_list)
+        arg_list = AXIS2_MALLOC(env->allocator, sizeof(axis2_http_svr_thd_args_t));
+        if(!arg_list)
         {
             AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                            "Memory allocation error in the svr thread loop");
+                "Memory allocation error in the svr thread loop");
             continue;
         }
-        arg_list->env = (axutil_env_t *) env;
+
+        arg_list->env = (axutil_env_t *)env;
         arg_list->socket = socket;
         arg_list->worker = svr_thread->worker;
 #ifdef AXIS2_SVR_MULTI_THREADED
         worker_thread = axutil_thread_pool_get_thread(env->thread_pool,
-                                                      axis2_svr_thread_worker_func,
-                                                      (void *) arg_list);
+            axis2_svr_thread_worker_func, (void *) arg_list);
         if (!worker_thread)
         {
-            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed"
-                            "server thread loop");
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed server thread
loop");
             continue;
         }
         axutil_thread_pool_thread_detach(env->thread_pool, worker_thread);
 #else
-        axis2_svr_thread_worker_func(NULL, (void *) arg_list);
+        axis2_svr_thread_worker_func(NULL, (void *)arg_list);
 #endif
     }
     return AXIS2_SUCCESS;
 }
 
-
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_svr_thread_destroy(
     axis2_http_svr_thread_t * svr_thread,
     const axutil_env_t * env)
 {
-
-    if (AXIS2_TRUE == svr_thread->stopped)
+    if(AXIS2_TRUE == svr_thread->stopped)
     {
         return AXIS2_SUCCESS;
     }
- 
+
     svr_thread->stopped = AXIS2_TRUE;
-    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Terminating HTTP server "
-                    "thread.");
-    if (svr_thread->listen_socket)
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Terminating HTTP server thread.");
+    if(svr_thread->listen_socket)
     {
         axutil_network_handler_close_socket(env, svr_thread->listen_socket);
         svr_thread->listen_socket = -1;
@@ -188,7 +174,7 @@
     return AXIS2_SUCCESS;
 }
 
-int AXIS2_CALL
+AXIS2_EXTERN int AXIS2_CALL
 axis2_http_svr_thread_get_local_port(
     const axis2_http_svr_thread_t * svr_thread,
     const axutil_env_t * env)
@@ -196,7 +182,7 @@
     return svr_thread->port;
 }
 
-axis2_bool_t AXIS2_CALL
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
 axis2_http_svr_thread_is_running(
     axis2_http_svr_thread_t * svr_thread,
     const axutil_env_t * env)
@@ -204,7 +190,7 @@
     return !(svr_thread->stopped);
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_svr_thread_set_worker(
     axis2_http_svr_thread_t * svr_thread,
     const axutil_env_t * env,
@@ -218,13 +204,12 @@
 /**
  * Thread worker function.
  */
-void *AXIS2_THREAD_FUNC
+static void *AXIS2_THREAD_FUNC
 axis2_svr_thread_worker_func(
     axutil_thread_t * thd,
     void *data)
 {
-    struct AXIS2_PLATFORM_TIMEB t1,
-     t2;
+    struct AXIS2_PLATFORM_TIMEB t1, t2;
     axis2_simple_http_svr_conn_t *svr_conn = NULL;
     axis2_http_simple_request_t *request = NULL;
     int millisecs = 0;
@@ -242,62 +227,63 @@
 #endif
 #endif
 
-    arg_list = (axis2_http_svr_thd_args_t *) data;
-    if (!arg_list)
+    if(!data)
     {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot get thread argument list");
         return NULL;
     }
-    AXIS2_PLATFORM_GET_TIME_IN_MILLIS(&t1);
+    arg_list = (axis2_http_svr_thd_args_t *)data;
+
+    IF_AXIS2_LOG_DEBUG_ENABLED(log)
+    {
+        AXIS2_PLATFORM_GET_TIME_IN_MILLIS(&t1);
+    }
+
     env = arg_list->env;
     thread_env = axutil_init_thread_env(env);
     socket = arg_list->socket;
     svr_conn = axis2_simple_http_svr_conn_create(thread_env, (int)socket);
-    axis2_simple_http_svr_conn_set_rcv_timeout(svr_conn, thread_env,
-                                               axis2_http_socket_read_timeout);
+    axis2_simple_http_svr_conn_set_rcv_timeout(svr_conn, thread_env, axis2_http_socket_read_timeout);
     request = axis2_simple_http_svr_conn_read_request(svr_conn, thread_env);
     tmp = arg_list->worker;
-    status = axis2_http_worker_process_request(tmp, thread_env, svr_conn,
-                                               request);
+    status = axis2_http_worker_process_request(tmp, thread_env, svr_conn, request);
     axis2_simple_http_svr_conn_free(svr_conn, thread_env);
-    if (request)
-        axis2_http_simple_request_free(request, thread_env);
-    AXIS2_PLATFORM_GET_TIME_IN_MILLIS(&t2);
-    millisecs = t2.millitm - t1.millitm;
-    secs = difftime(t2.time, t1.time);
-    if (millisecs < 0)
+    if(request)
     {
-        millisecs += 1000;
-        secs--;
+        axis2_http_simple_request_free(request, thread_env);
     }
-    secs += millisecs / 1000.0;
 
-    if (status == AXIS2_SUCCESS)
+    IF_AXIS2_LOG_DEBUG_ENABLED(log)
     {
+        AXIS2_PLATFORM_GET_TIME_IN_MILLIS(&t2);
+        millisecs = t2.millitm - t1.millitm;
+        secs = difftime(t2.time, t1.time);
+        if(millisecs < 0)
+        {
+            millisecs += 1000;
+            secs--;
+        }
+        secs += millisecs / 1000.0;
+
 #if defined(WIN32)
-        AXIS2_LOG_INFO(thread_env->log, "Request served successfully");
+        AXIS2_LOG_DEBUG(thread_env->log, AXIS2_LOG_SI, "Request processed...");
 #else
-        AXIS2_LOG_INFO(thread_env->log, "Request served in %.3f seconds", secs);
+        AXIS2_LOG_DEBUG(thread_env->log, AXIS2_LOG_SI, "Request processed in %.3f seconds",
secs);
 #endif
     }
+
+    if(status == AXIS2_SUCCESS)
+    {
+        AXIS2_LOG_DEBUG(thread_env->log, AXIS2_LOG_SI, "Request served successfully");
+    }
     else
     {
-#if defined(WIN32)
-        AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI,
-                          "Error occured in processing request ");
-#else
-        AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI,
-                          "Error occured in processing request (%.3f seconds)",
-                          secs);
-#endif
+        AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI, "Error occurred in processing
request ");
     }
 
     AXIS2_FREE(thread_env->allocator, arg_list);
-
-    if (thread_env)
-    {
-        axutil_free_thread_env(thread_env);
-        thread_env = NULL;
-    }
+    axutil_free_thread_env(thread_env);
+    thread_env = NULL;
 
 #ifdef AXIS2_SVR_MULTI_THREADED
     axutil_thread_pool_exit_thread(env->thread_pool, thd);
@@ -306,4 +292,3 @@
     return NULL;
 }
 
-

Modified: webservices/axis2/trunk/c/src/core/transport/http/server/simple_axis2_server/http_server_main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/simple_axis2_server/http_server_main.c?rev=804873&r1=804872&r2=804873&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/simple_axis2_server/http_server_main.c
(original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/simple_axis2_server/http_server_main.c
Mon Aug 17 06:31:01 2009
@@ -62,14 +62,13 @@
     axutil_log_t *log = axutil_log_create(allocator, NULL, log_file);
     /* if (!log) */
 
-/* 		  log = axutil_log_create_default (allocator); */
+    /* 		  log = axutil_log_create_default (allocator); */
     axutil_thread_pool_t *thread_pool = axutil_thread_pool_init(allocator);
     /* We need to init the parser in main thread before spawning child
      * threads
      */
     axiom_xml_reader_init();
-    return axutil_env_create_with_error_log_thread_pool(allocator, error, log,
-                                                        thread_pool);
+    return axutil_env_create_with_error_log_thread_pool(allocator, error, log, thread_pool);
 }
 
 void
@@ -78,11 +77,11 @@
     int status)
 {
     axutil_allocator_t *allocator = NULL;
-    if (server)
+    if(server)
     {
         axis2_transport_receiver_free(server, system_env);
     }
-    if (env)
+    if(env)
     {
         allocator = env->allocator;
         axutil_env_free(env);
@@ -102,65 +101,64 @@
     extern char *optarg;
     extern int optopt;
     int c;
-	unsigned int len;
+    unsigned int len;
     int log_file_size = AXUTIL_LOG_FILE_SIZE;
-	unsigned int file_flag = 0;
+    unsigned int file_flag = 0;
     axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG;
     const axis2_char_t *log_file = "axis2.log";
     const axis2_char_t *repo_path = DEFAULT_REPO_PATH;
     int port = 9090;
-	axis2_status_t status;
-	
+    axis2_status_t status;
 
     /* Set the service URL prefix to be used. This could default to services if not 
-       set with AXIS2_REQUEST_URL_PREFIX macro at compile time */
+     set with AXIS2_REQUEST_URL_PREFIX macro at compile time */
     axis2_request_url_prefix = AXIS2_REQUEST_URL_PREFIX;
 
-    while ((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:s:f:")) != -1)
+    while((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:s:f:")) != -1)
     {
 
-        switch (c)
+        switch(c)
         {
-        case 'p':
-            port = AXIS2_ATOI(optarg);
-            break;
-        case 'r':
-            repo_path = optarg;
-            break;
-        case 't':
-            axis2_http_socket_read_timeout = AXIS2_ATOI(optarg) * 1000;
-            break;
-        case 'l':
-            log_level = AXIS2_ATOI(optarg);
-            if (log_level < AXIS2_LOG_LEVEL_CRITICAL)
-                log_level = AXIS2_LOG_LEVEL_CRITICAL;
-            if (log_level > AXIS2_LOG_LEVEL_TRACE)
-                log_level = AXIS2_LOG_LEVEL_TRACE;
-            break;
-        case 's':
-            log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg);
-            break;
-        case 'f':
-            log_file = optarg;
-            break;
-        case 'h':
-            usage(argv[0]);
-            return 0;
-        case ':':
-            fprintf(stderr, "\nOption -%c requires an operand\n", optopt);
-            usage(argv[0]);
-            return -1;
-        case '?':
-            if (isprint(optopt))
-                fprintf(stderr, "\nUnknown option `-%c'.\n", optopt);
-            usage(argv[0]);
-            return -1;
+            case 'p':
+                port = AXIS2_ATOI(optarg);
+                break;
+            case 'r':
+                repo_path = optarg;
+                break;
+            case 't':
+                axis2_http_socket_read_timeout = AXIS2_ATOI(optarg) * 1000;
+                break;
+            case 'l':
+                log_level = AXIS2_ATOI(optarg);
+                if(log_level < AXIS2_LOG_LEVEL_CRITICAL)
+                    log_level = AXIS2_LOG_LEVEL_CRITICAL;
+                if(log_level > AXIS2_LOG_LEVEL_TRACE)
+                    log_level = AXIS2_LOG_LEVEL_TRACE;
+                break;
+            case 's':
+                log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg);
+                break;
+            case 'f':
+                log_file = optarg;
+                break;
+            case 'h':
+                usage(argv[0]);
+                return 0;
+            case ':':
+                fprintf(stderr, "\nOption -%c requires an operand\n", optopt);
+                usage(argv[0]);
+                return -1;
+            case '?':
+                if(isprint(optopt))
+                    fprintf(stderr, "\nUnknown option `-%c'.\n", optopt);
+                usage(argv[0]);
+                return -1;
         }
     }
 
     allocator = axutil_allocator_init(NULL);
 
-    if (!allocator)
+    if(!allocator)
     {
         system_exit(NULL, -1);
     }
@@ -178,54 +176,46 @@
 #endif
 
     AXIS2_LOG_INFO(env->log, "Starting Axis2 HTTP server....");
-    AXIS2_LOG_INFO(env->log, "Apache Axis2/C version in use : %s",
-                   axis2_version_string());
+    AXIS2_LOG_INFO(env->log, "Apache Axis2/C version in use : %s", axis2_version_string());
     AXIS2_LOG_INFO(env->log, "Server port : %d", port);
     AXIS2_LOG_INFO(env->log, "Repo location : %s", repo_path);
-    AXIS2_LOG_INFO(env->log, "Read Timeout : %d ms",
-                   axis2_http_socket_read_timeout);
-	
-	status = axutil_file_handler_access (repo_path, AXIS2_R_OK);
-	if (status == AXIS2_SUCCESS)
-	{
-		len = (unsigned int)strlen (repo_path);
+    AXIS2_LOG_INFO(env->log, "Read Timeout : %d ms", axis2_http_socket_read_timeout);
+
+    status = axutil_file_handler_access(repo_path, AXIS2_R_OK);
+    if(status == AXIS2_SUCCESS)
+    {
+        len = (unsigned int)strlen(repo_path);
         /* We are sure that the difference lies within the unsigned int range */
-		if ((len >= 9) &&
-            !strcmp ((repo_path + (len - 9)), "axis2.xml"))
-		{
-			file_flag = 1;
-		}
-	}
-	else
-	{
-		AXIS2_LOG_WARNING (env->log, AXIS2_LOG_SI, "provided repo path %s does " 
-						   "not exist or no permissions to read, set "
-						   "repo_path to DEFAULT_REPO_PATH", repo_path);
-		repo_path = DEFAULT_REPO_PATH;
-	}
-	
-
-	if (!file_flag)
-    	server = axis2_http_server_create(env, repo_path, port);
-	else
-		server = axis2_http_server_create_with_file (env, repo_path, port);
-	
-    if (!server)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                        "Server creation failed: Error code:" " %d :: %s",
-                        env->error->error_number,
-                        AXIS2_ERROR_GET_MESSAGE(env->error));
+        if((len >= 9) && !strcmp((repo_path + (len - 9)), "axis2.xml"))
+        {
+            file_flag = 1;
+        }
+    }
+    else
+    {
+        AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "provided repo path %s does "
+            "not exist or no permissions to read, set "
+            "repo_path to DEFAULT_REPO_PATH", repo_path);
+        repo_path = DEFAULT_REPO_PATH;
+    }
+
+    if(!file_flag)
+        server = axis2_http_server_create(env, repo_path, port);
+    else
+        server = axis2_http_server_create_with_file(env, repo_path, port);
+
+    if(!server)
+    {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server creation failed: Error code:"
" %d :: %s",
+            env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));
         system_exit(env, -1);
 
     }
     printf("Started Simple Axis2 HTTP Server ...\n");
-    if (axis2_transport_receiver_start(server, env) == AXIS2_FAILURE)
+    if(axis2_transport_receiver_start(server, env) == AXIS2_FAILURE)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                        "Server start failed: Error code:" " %d :: %s",
-                        env->error->error_number,
-                        AXIS2_ERROR_GET_MESSAGE(env->error));
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server start failed: Error code:" " %d
:: %s",
+            env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));
         system_exit(env, -1);
     }
     return 0;
@@ -245,24 +235,21 @@
     fprintf(stdout, " Options :\n");
     fprintf(stdout, "\t-p PORT \t port number to use, default port is 9090\n");
     fprintf(stdout, "\t-r REPO_PATH \t repository path, default is ../\n");
-    fprintf(stdout,
-            "\t-t TIMEOUT\t socket read timeout, default is 30 seconds\n");
-    fprintf(stdout,
-            "\t-l LOG_LEVEL\t log level, available log levels:"
-            "\n\t\t\t 0 - critical    1 - errors 2 - warnings"
-            "\n\t\t\t 3 - information 4 - debug  5- user 6- trace"
-            "\n\t\t\t Default log level is 4(debug).\n");
+    fprintf(stdout, "\t-t TIMEOUT\t socket read timeout, default is 30 seconds\n");
+    fprintf(stdout, "\t-l LOG_LEVEL\t log level, available log levels:"
+        "\n\t\t\t 0 - critical    1 - errors 2 - warnings"
+        "\n\t\t\t 3 - information 4 - debug  5- user 6- trace"
+        "\n\t\t\t Default log level is 4(debug).\n");
 #ifndef WIN32
-    fprintf(stdout,
-            "\t-f LOG_FILE\t log file, default is $AXIS2C_HOME/logs/axis2.log"
-            "\n\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
+    fprintf(stdout, "\t-f LOG_FILE\t log file, default is $AXIS2C_HOME/logs/axis2.log"
+        "\n\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
 #else
     fprintf(stdout,
-            "\t-f LOG_FILE\t log file, default is %%AXIS2C_HOME%%\\logs\\axis2.log"
-            "\n\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
+        "\t-f LOG_FILE\t log file, default is %%AXIS2C_HOME%%\\logs\\axis2.log"
+        "\n\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
 #endif
     fprintf(stdout,
-            "\t-s LOG_FILE_SIZE\t Maximum log file size in mega bytes, default maximum size
is 1MB.\n");
+        "\t-s LOG_FILE_SIZE\t Maximum log file size in mega bytes, default maximum size is
1MB.\n");
     fprintf(stdout, " Help :\n\t-h \t display this help screen.\n\n");
 }
 
@@ -274,24 +261,27 @@
     int signal)
 {
 
-    if (!system_env)
+    if(!system_env)
     {
-        AXIS2_LOG_ERROR(system_env->log, AXIS2_LOG_SI,
-                        "Received signal %d, unable to proceed system_env is NULL ,\
-                         system exit with -1", signal);
-        _exit (-1);
+        AXIS2_LOG_ERROR(
+            system_env->log,
+            AXIS2_LOG_SI,
+            "Received signal %d, unable to proceed system_env is NULL ,\
+                         system exit with -1",
+            signal);
+        _exit(-1);
     }
 
-    switch (signal)
+    switch(signal)
     {
-    case SIGINT:
+        case SIGINT:
         {
             /* Use of SIGINT in Windows is valid, since we have a console application
              * Thus, eventhough this may a single threaded application, it does work.
              */
             AXIS2_LOG_INFO(system_env->log, "Received signal SIGINT. Server "
-                           "shutting down");
-            if (server)
+                "shutting down");
+            if(server)
             {
                 axis2_http_server_stop(server, system_env);
             }
@@ -300,14 +290,14 @@
             system_exit(system_env, 0);
         }
 #ifndef WIN32
-    case SIGPIPE:
+        case SIGPIPE:
         {
             AXIS2_LOG_INFO(system_env->log, "Received signal SIGPIPE.  Client "
-                           "request serve aborted");
+                "request serve aborted");
             return;
         }
 #endif
-    case SIGSEGV:
+        case SIGSEGV:
         {
             fprintf(stderr, "Received deadly signal SIGSEGV. Terminating\n");
             _exit(-1);

Modified: webservices/axis2/trunk/c/src/core/transport/transport_receiver.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/transport_receiver.c?rev=804873&r1=804872&r2=804873&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/transport_receiver.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/transport_receiver.c Mon Aug 17 06:31:01
2009
@@ -1,4 +1,3 @@
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -33,8 +32,7 @@
     struct axis2_conf_ctx *conf_ctx,
     struct axis2_transport_in_desc *transport_in)
 {
-    return (transport_receiver->ops)->init(transport_receiver, env,
-                                           conf_ctx, transport_in);
+    return (transport_receiver->ops)->init(transport_receiver, env, conf_ctx, transport_in);
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -59,8 +57,7 @@
     const axutil_env_t * env,
     const axis2_char_t * svc_name)
 {
-    return (transport_receiver->ops)->get_reply_to_epr(transport_receiver, env,
-                                                       svc_name);
+    return (transport_receiver->ops)->get_reply_to_epr(transport_receiver, env, svc_name);
 }
 
 AXIS2_EXTERN struct axis2_conf_ctx *AXIS2_CALL



Mime
View raw message