You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by su...@apache.org on 2008/09/18 08:22:13 UTC
svn commit: r696570 - in /webservices/axis2/trunk/c/src/core:
clientapi/op_client.c clientapi/options.c clientapi/svc_client.c
description/svc.c receivers/msg_recv.c
Author: supun
Date: Wed Sep 17 23:22:12 2008
New Revision: 696570
URL: http://svn.apache.org/viewvc?rev=696570&view=rev
Log:
Fixing issues 1254 and 1266.
Modified:
webservices/axis2/trunk/c/src/core/clientapi/op_client.c
webservices/axis2/trunk/c/src/core/clientapi/options.c
webservices/axis2/trunk/c/src/core/clientapi/svc_client.c
webservices/axis2/trunk/c/src/core/description/svc.c
webservices/axis2/trunk/c/src/core/receivers/msg_recv.c
Modified: webservices/axis2/trunk/c/src/core/clientapi/op_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/clientapi/op_client.c?rev=696570&r1=696569&r2=696570&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/clientapi/op_client.c (original)
+++ webservices/axis2/trunk/c/src/core/clientapi/op_client.c Wed Sep 17 23:22:12 2008
@@ -375,7 +375,7 @@
/**
if the transport to use for sending is not specified, try to find it
- from the URL
+ from the URL or the client option.
*/
transport_out = axis2_options_get_transport_out(op_client->options, env);
if (!transport_out)
@@ -881,62 +881,68 @@
{
axis2_char_t *transport = NULL;
axis2_transport_out_desc_t *transport_out_desc = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_conf_t *conf = NULL;
+ AXIS2_TRANSPORT_ENUMS transport_enum = AXIS2_TRANSPORT_ENUM_MAX;
AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
- "Start:axis2_op_client_infer_transport");
- if (epr)
- {
- const axis2_char_t *to_url = axis2_endpoint_ref_get_address(epr, env);
-
- transport = axis2_op_client_get_transport_from_url(to_url, env);
- }
-
- if (transport)
- {
- axis2_conf_ctx_t *conf_ctx = NULL;
- axis2_conf_t *conf = NULL;
- AXIS2_TRANSPORT_ENUMS transport_enum = 0;
-
- if (!axutil_strcmp(transport, AXIS2_TRANSPORT_HTTP))
- {
- transport_enum = AXIS2_TRANSPORT_ENUM_HTTP;
- }
- else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_HTTPS))
- {
- transport_enum = AXIS2_TRANSPORT_ENUM_HTTPS;
- }
- else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_XMPP))
- {
- transport_enum = AXIS2_TRANSPORT_ENUM_XMPP;
- }
- else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_TCP))
- {
- transport_enum = AXIS2_TRANSPORT_ENUM_TCP;
- }
- else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_AMQP))
+ "Start:axis2_op_client_infer_transport");
+
+ /* We first try the client option */
+ transport_enum = axis2_options_get_sender_transport_protocol(op_client->options, env);
+ if (transport_enum == AXIS2_TRANSPORT_ENUM_MAX)
+ {
+ /* If we couldn't find the transport we default to HTTP */
+ transport_enum = AXIS2_TRANSPORT_ENUM_HTTP;
+ /* We try to infer transport from the url */
+ if (epr)
{
- transport_enum = AXIS2_TRANSPORT_ENUM_AMQP;
- }
- else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_UDP))
- {
- transport_enum = AXIS2_TRANSPORT_ENUM_UDP;
+ const axis2_char_t *to_url = axis2_endpoint_ref_get_address(epr, env);
+
+ transport = axis2_op_client_get_transport_from_url(to_url, env);
}
- conf_ctx = axis2_svc_ctx_get_conf_ctx(op_client->svc_ctx, env);
- if (conf_ctx)
+ if (transport)
+ {
+ if (!axutil_strcmp(transport, AXIS2_TRANSPORT_HTTP))
+ {
+ transport_enum = AXIS2_TRANSPORT_ENUM_HTTP;
+ }
+ else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_HTTPS))
+ {
+ transport_enum = AXIS2_TRANSPORT_ENUM_HTTPS;
+ }
+ else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_XMPP))
+ {
+ transport_enum = AXIS2_TRANSPORT_ENUM_XMPP;
+ }
+ else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_TCP))
+ {
+ transport_enum = AXIS2_TRANSPORT_ENUM_TCP;
+ }
+ else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_AMQP))
+ {
+ transport_enum = AXIS2_TRANSPORT_ENUM_AMQP;
+ }
+ else if (!axutil_strcmp(transport, AXIS2_TRANSPORT_UDP))
+ {
+ transport_enum = AXIS2_TRANSPORT_ENUM_UDP;
+ }
+
+ AXIS2_FREE(env->allocator, transport);
+ transport = NULL;
+ }
+ }
+ conf_ctx = axis2_svc_ctx_get_conf_ctx(op_client->svc_ctx, env);
+ if (conf_ctx)
+ {
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if (conf)
{
- conf = axis2_conf_ctx_get_conf(conf_ctx, env);
- if (conf)
- {
- transport_out_desc = axis2_conf_get_transport_out(conf,
- env,
- transport_enum);
- }
+ transport_out_desc = axis2_conf_get_transport_out(conf,
+ env,
+ transport_enum);
}
-
- AXIS2_FREE(env->allocator, transport);
- transport = NULL;
-
}
if (!transport_out_desc)
{
Modified: webservices/axis2/trunk/c/src/core/clientapi/options.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/clientapi/options.c?rev=696570&r1=696569&r2=696570&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/clientapi/options.c (original)
+++ webservices/axis2/trunk/c/src/core/clientapi/options.c Wed Sep 17 23:22:12 2008
@@ -82,9 +82,9 @@
options->use_separate_listener = -1;
options->receiver = NULL;
options->transport_in = NULL;
- options->transport_in_protocol = AXIS2_TRANSPORT_ENUM_HTTP;
+ options->transport_in_protocol = AXIS2_TRANSPORT_ENUM_MAX;
options->transport_out = NULL;
- options->sender_transport_protocol = AXIS2_TRANSPORT_ENUM_HTTP;
+ options->sender_transport_protocol = AXIS2_TRANSPORT_ENUM_MAX;
options->manage_session = -1;
options->soap_version = AXIOM_SOAP12;
options->enable_mtom = AXIS2_FALSE;
Modified: webservices/axis2/trunk/c/src/core/clientapi/svc_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/clientapi/svc_client.c?rev=696570&r1=696569&r2=696570&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/clientapi/svc_client.c (original)
+++ webservices/axis2/trunk/c/src/core/clientapi/svc_client.c Wed Sep 17 23:22:12 2008
@@ -994,9 +994,14 @@
if (axis2_options_get_use_separate_listener(svc_client->options, env))
{
axis2_op_t *op = NULL;
-
+
transport_in_protocol =
axis2_options_get_transport_in_protocol(svc_client->options, env);
+ if (transport_in_protocol == AXIS2_TRANSPORT_ENUM_MAX)
+ {
+ axis2_options_set_transport_in_protocol(svc_client->options, env, AXIS2_TRANSPORT_ENUM_HTTP);
+ transport_in_protocol = AXIS2_TRANSPORT_ENUM_HTTP;
+ }
axis2_listener_manager_make_sure_started(svc_client->listener_manager,
env, transport_in_protocol,
svc_client->conf_ctx);
Modified: webservices/axis2/trunk/c/src/core/description/svc.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/description/svc.c?rev=696570&r1=696569&r2=696570&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/description/svc.c (original)
+++ webservices/axis2/trunk/c/src/core/description/svc.c Wed Sep 17 23:22:12 2008
@@ -22,6 +22,7 @@
#include <axis2_module.h>
#include "../deployment/axis2_desc_builder.h"
#include <axis2_svc_skeleton.h>
+#include <axutil_thread.h>
struct axis2_svc
{
@@ -117,6 +118,9 @@
/** Base description struct */
axis2_desc_t *base;
+
+ /* Mutex to avoid loading the same service dll twice */
+ axutil_thread_mutex_t *mutex;
};
AXIS2_EXTERN axis2_svc_t *AXIS2_CALL
@@ -274,7 +278,13 @@
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service base creation failed");
return NULL;
}
-
+ svc->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT);
+ if (!svc->mutex)
+ {
+ axis2_svc_free(svc, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service mutex creation failed");
+ return NULL;
+ }
return svc;
}
@@ -490,13 +500,15 @@
{
axis2_desc_free(svc->base, env);
}
-
+ if (svc->mutex)
+ {
+ axutil_thread_mutex_destroy(svc->mutex);
+ }
if (svc)
{
AXIS2_FREE(env->allocator, svc);
svc = NULL;
}
-
return;
}
@@ -1582,3 +1594,10 @@
return svc->base;
}
+AXIS2_EXTERN axutil_thread_mutex_t * AXIS2_CALL
+axis2_svc_get_mutex(
+ const axis2_svc_t * svc,
+ const axutil_env_t * env)
+{
+ return svc->mutex;
+}
\ No newline at end of file
Modified: webservices/axis2/trunk/c/src/core/receivers/msg_recv.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/receivers/msg_recv.c?rev=696570&r1=696569&r2=696570&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/receivers/msg_recv.c (original)
+++ webservices/axis2/trunk/c/src/core/receivers/msg_recv.c Wed Sep 17 23:22:12 2008
@@ -25,6 +25,7 @@
#include <axutil_property.h>
#include <axiom_soap_envelope.h>
#include <axiom_soap_body.h>
+#include <axutil_thread.h>
struct axis2_msg_recv
{
@@ -145,30 +146,41 @@
{
return impl_class;
}
-
- impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
- if (!impl_info_param)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC,
- AXIS2_FAILURE);
- return NULL;
- }
-
- axutil_allocator_switch_to_global_pool(env->allocator);
-
- axutil_class_loader_init(env);
-
- impl_class = axutil_class_loader_create_dll(env, impl_info_param);
- axis2_svc_set_impl_class(svc, env, impl_class);
-
- if (impl_class)
- {
- AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *) impl_class, env);
- }
-
- axutil_allocator_switch_to_local_pool(env->allocator);
-
- return impl_class;
+ else
+ {
+ /* When we load the DLL we have to make sure that only one thread will load it */
+ axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
+ /* If more than one thread tries to acuire the lock, first thread loads the DLL.
+ Others should not load the DLL */
+ impl_class = axis2_svc_get_impl_class(svc, env);
+ if (impl_class)
+ {
+ return impl_class;
+ }
+ impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
+ if (!impl_info_param)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC,
+ AXIS2_FAILURE);
+ return NULL;
+ }
+
+ axutil_allocator_switch_to_global_pool(env->allocator);
+
+ axutil_class_loader_init(env);
+
+ impl_class = axutil_class_loader_create_dll(env, impl_info_param);
+ axis2_svc_set_impl_class(svc, env, impl_class);
+
+ if (impl_class)
+ {
+ AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *) impl_class, env);
+ }
+
+ axutil_allocator_switch_to_local_pool(env->allocator);
+ axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+ return impl_class;
+ }
}
AXIS2_EXPORT axis2_svc_skeleton_t *AXIS2_CALL