axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billblo...@apache.org
Subject [axis-axis2-c-core] 06/08: Changes regarding the new thread pool
Date Sat, 04 Apr 2020 15:08:12 GMT
This is an automated email from the ASF dual-hosted git repository.

billblough pushed a commit to branch new_thread_pool-25march2009
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git

commit ae5ace6891486dfbf7579d2da9303b1ced8d98cb
Author: Damitha N.M. Kumarage <damitha@apache.org>
AuthorDate: Wed Mar 25 09:03:14 2009 +0000

    Changes regarding the new thread pool
---
 src/core/clientapi/listener_manager.c              | 18 +--------
 src/core/clientapi/op_client.c                     | 19 ++-------
 src/core/transport/http/receiver/http_svr_thread.c | 16 ++------
 src/core/transport/http/server/apache2/mod_axis2.c |  6 ++-
 .../server/simple_axis2_server/http_server_main.c  |  3 +-
 tools/tcpmon/src/session.c                         | 46 ++--------------------
 6 files changed, 18 insertions(+), 90 deletions(-)

diff --git a/src/core/clientapi/listener_manager.c b/src/core/clientapi/listener_manager.c
index 27090a6..c221478 100644
--- a/src/core/clientapi/listener_manager.c
+++ b/src/core/clientapi/listener_manager.c
@@ -127,7 +127,6 @@ axis2_listener_manager_make_sure_started(
                 listener = axis2_transport_in_desc_get_recv(transport_in, env);
                 if (listener)
                 {
-                    axutil_thread_t *worker_thread = NULL;
                     axis2_listener_manager_worker_func_args_t *arg_list = NULL;
                     arg_list = AXIS2_MALLOC(env->allocator,
                                             sizeof
@@ -144,21 +143,8 @@ axis2_listener_manager_make_sure_started(
 #ifdef AXIS2_SVR_MULTI_THREADED
                     if (env->thread_pool)
                     {
-                        worker_thread =
-                            axutil_thread_pool_get_thread(env->thread_pool,
-                                                          axis2_listener_manager_worker_func,
-                                                          (void *) arg_list);
-                        if (!worker_thread)
-                        {
-                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                                            "Thread creation failed"
-                                            "Invoke non blocking failed");
-                        }
-                        else
-                        {
-                            axutil_thread_pool_thread_detach(env->thread_pool,
-                                                             worker_thread);
-                        }
+                        axutil_thread_pool_dispatch(env->thread_pool, 
+                                axis2_listener_manager_worker_func, (void *) arg_list);
                     }
                     else
                     {
diff --git a/src/core/clientapi/op_client.c b/src/core/clientapi/op_client.c
index 60b384a..1ef6c91 100644
--- a/src/core/clientapi/op_client.c
+++ b/src/core/clientapi/op_client.c
@@ -531,7 +531,6 @@ axis2_op_client_execute(
         }
         else
         {
-            axutil_thread_t *worker_thread = NULL;
             axis2_op_client_worker_func_args_t *arg_list = NULL;
             arg_list = AXIS2_MALLOC(env->allocator,
                                     sizeof(axis2_op_client_worker_func_args_t));
@@ -549,20 +548,8 @@ axis2_op_client_execute(
 #ifdef AXIS2_SVR_MULTI_THREADED
             if (env->thread_pool)
             {
-                worker_thread = axutil_thread_pool_get_thread(env->thread_pool,
-                                                              axis2_op_client_worker_func,
-                                                              (void *)
-                                                              arg_list);
-                if (!worker_thread)
-                {
-                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                                    "Thread creation failed call invoke non blocking");
-                }
-                else
-                {
-                    axutil_thread_pool_thread_detach(env->thread_pool,
-                                                    worker_thread);
-                }
+                axutil_thread_pool_dispatch(env->thread_pool, axis2_op_client_worker_func,

+                    (void *) arg_list);
             }
             else
             {
@@ -726,7 +713,7 @@ axis2_op_client_worker_func(
         axutil_free_thread_env(th_env);
         th_env = NULL;
     }
-    axutil_thread_pool_exit_thread(th_pool, thd);
+    /*axutil_thread_pool_exit_thread(th_pool, thd);*/
     return NULL;
 }
 
diff --git a/src/core/transport/http/receiver/http_svr_thread.c b/src/core/transport/http/receiver/http_svr_thread.c
index d09bf55..be5fd10 100644
--- a/src/core/transport/http/receiver/http_svr_thread.c
+++ b/src/core/transport/http/receiver/http_svr_thread.c
@@ -28,6 +28,7 @@
 #include <axutil_error_default.h>
 #include <axiom_xml_reader.h>
 #include <signal.h>
+#include <stdio.h>
 
 AXIS2_EXPORT int axis2_http_socket_read_timeout = AXIS2_HTTP_DEFAULT_SO_TIMEOUT;
 
@@ -123,7 +124,6 @@ axis2_http_svr_thread_run(
     {
         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->
@@ -148,16 +148,8 @@ axis2_http_svr_thread_run(
         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);
-        if (!worker_thread)
-        {
-            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);
+        axutil_thread_pool_dispatch(env->thread_pool, axis2_svr_thread_worker_func, 
+                (void *) arg_list);
 #else
         axis2_svr_thread_worker_func(NULL, (void *) arg_list);
 #endif
@@ -300,7 +292,7 @@ axis2_svr_thread_worker_func(
     }
 
 #ifdef AXIS2_SVR_MULTI_THREADED
-    axutil_thread_pool_exit_thread(env->thread_pool, thd);
+    /*axutil_thread_pool_exit_thread(env->thread_pool, thd);*/
 #endif
 
     return NULL;
diff --git a/src/core/transport/http/server/apache2/mod_axis2.c b/src/core/transport/http/server/apache2/mod_axis2.c
index deb318c..0d84dc6 100644
--- a/src/core/transport/http/server/apache2/mod_axis2.c
+++ b/src/core/transport/http/server/apache2/mod_axis2.c
@@ -32,6 +32,8 @@
 #include <apr_shm.h>
 #include <axis2_http_transport.h>
 
+#define INIT_THREAD_POOL_SIZE 150
+
 /* Configuration structure populated by apache2.conf */
 typedef struct axis2_config_rec
 {
@@ -549,7 +551,7 @@ static int axis2_post_config(apr_pool_t *pconf, apr_pool_t *plog,
                          "[Axis2] Error creating mod_axis2 log structure");
             exit(APEXIT_CHILDFATAL);
         }
-        thread_pool = axutil_thread_pool_init(allocator);
+        thread_pool = axutil_thread_pool_init(allocator, INIT_THREAD_POOL_SIZE);
         if (!thread_pool)
         {
             ap_log_error(APLOG_MARK, APLOG_EMERG, APR_EGENERAL, svr_rec,
@@ -667,7 +669,7 @@ axis2_module_init(
                      "[Axis2] Error creating mod_axis2 log structure");
         exit(APEXIT_CHILDFATAL);
     }
-    thread_pool = axutil_thread_pool_init(allocator);
+    thread_pool = axutil_thread_pool_init(allocator, INIT_THREAD_POOL_SIZE);
     if (! thread_pool)
     {
         ap_log_error(APLOG_MARK, APLOG_EMERG, APR_EGENERAL, svr_rec,
diff --git a/src/core/transport/http/server/simple_axis2_server/http_server_main.c b/src/core/transport/http/server/simple_axis2_server/http_server_main.c
index 11314d5..ee353b4 100644
--- a/src/core/transport/http/server/simple_axis2_server/http_server_main.c
+++ b/src/core/transport/http/server/simple_axis2_server/http_server_main.c
@@ -36,6 +36,7 @@ AXIS2_IMPORT extern int axis2_http_socket_read_timeout;
 AXIS2_IMPORT extern axis2_char_t *axis2_request_url_prefix;
 
 #define DEFAULT_REPO_PATH "../"
+#define INIT_THREAD_POOL_SIZE 150
 
 /***************************** Function headers *******************************/
 axutil_env_t *init_syetem_env(
@@ -63,7 +64,7 @@ init_syetem_env(
     /* if (!log) */
 
 /* 		  log = axutil_log_create_default (allocator); */
-    axutil_thread_pool_t *thread_pool = axutil_thread_pool_init(allocator);
+    axutil_thread_pool_t *thread_pool = axutil_thread_pool_init(allocator, INIT_THREAD_POOL_SIZE);
     /* We need to init the parser in main thread before spawning child
      * threads
      */
diff --git a/tools/tcpmon/src/session.c b/tools/tcpmon/src/session.c
index 29d4c78..8996828 100644
--- a/tools/tcpmon/src/session.c
+++ b/tools/tcpmon/src/session.c
@@ -57,7 +57,6 @@ tcpmon_session_server_thread_data_t;
 
 #define AXIS2_INTF_TO_IMPL(session) \
     ((tcpmon_session_impl_t *) session)
-axutil_thread_t *server_thread = NULL;
 tcpmon_session_server_thread_data_t *thread_data = NULL;
 
 
@@ -410,21 +409,7 @@ tcpmon_session_start(
     thread_data->env = env;
 
     session_impl->is_running = AXIS2_TRUE;
-    server_thread = axutil_thread_pool_get_thread(env->thread_pool,
-                                                  server_funct,
-                                                  (void *) thread_data);
-    if (!server_thread)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed"
-                        "server thread");
-        if (session_impl->on_trans_fault_funct)
-        {
-            (session_impl->on_trans_fault_funct) (env,
-                                                  "error in creating the server thread");
-        }
-    }
-
-    axutil_thread_pool_thread_detach(env->thread_pool, server_thread);
+    axutil_thread_pool_dispatch(env->thread_pool, server_funct, (void *) thread_data);
     return AXIS2_SUCCESS;
 }
 
@@ -440,11 +425,6 @@ tcpmon_session_stop(
     session_impl = AXIS2_INTF_TO_IMPL(session);
     session_impl->is_running = AXIS2_FALSE;
 
-    if (server_thread)
-    {
-        AXIS2_FREE(env->allocator, server_thread);
-        server_thread = NULL;
-    }
     if (thread_data)
     {
         AXIS2_FREE(env->allocator, (tcpmon_session_server_thread_data_t *)thread_data);
@@ -498,7 +478,6 @@ server_funct(
     const axutil_env_t *env = NULL;
     int listen_socket = -1;
     int socket = -1;
-    axutil_thread_t *request_thread = NULL;
     tcpmon_entry_request_data_t *request_thread_data = NULL;
 
     session_impl = thread_data->session_impl;
@@ -519,8 +498,6 @@ server_funct(
         }
         if (thd)
         {
-            AXIS2_FREE(env->allocator, server_thread);
-            server_thread = NULL;
         }
         if (data)
         {
@@ -552,29 +529,12 @@ server_funct(
         request_thread_data->socket = socket;
         request_thread_data->session = (tcpmon_session_t *) session_impl;
 
-        request_thread = axutil_thread_pool_get_thread(env->thread_pool,
-                                                       tcpmon_entry_new_entry_funct,
-                                                       (void *)
-                                                       request_thread_data);
-        if (!request_thread)
-        {
-            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Thread creation failed"
-                            "request thread");
-            if (session_impl->on_trans_fault_funct)
-            {
-                (session_impl->on_trans_fault_funct) (env,
-                                                      "fail in creating the thread");
-            }
-            break;
-        }
-
-        axutil_thread_pool_thread_detach(env->thread_pool, request_thread);
+        axutil_thread_pool_dispatch(env->thread_pool, tcpmon_entry_new_entry_funct, 
+                (void *) request_thread_data);
     }
     axutil_network_handler_close_socket(env, listen_socket);
     if (thd)
     {
-        AXIS2_FREE(env->allocator, server_thread);
-        server_thread = NULL;
     }
     if (data)
     {


Mime
View raw message