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 sa...@apache.org on 2006/02/15 07:56:31 UTC
svn commit: r377952 - in /webservices/axis2/trunk/c/modules/core/context:
conf_ctx.c op_ctx.c
Author: sahan
Date: Tue Feb 14 22:56:30 2006
New Revision: 377952
URL: http://svn.apache.org/viewcvs?rev=377952&view=rev
Log:
Synchronizing configuration context and operation context using mutextes
Modified:
webservices/axis2/trunk/c/modules/core/context/conf_ctx.c
webservices/axis2/trunk/c/modules/core/context/op_ctx.c
Modified: webservices/axis2/trunk/c/modules/core/context/conf_ctx.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/context/conf_ctx.c?rev=377952&r1=377951&r2=377952&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/context/conf_ctx.c (original)
+++ webservices/axis2/trunk/c/modules/core/context/conf_ctx.c Tue Feb 14 22:56:30 2006
@@ -38,7 +38,10 @@
axis2_hash_t *svc_ctx_map;
- axis2_hash_t *svc_grp_ctx_map;
+ axis2_hash_t *svc_grp_ctx_map;
+
+ /* Mutex to syncronize the read/write operations */
+ axis2_thread_mutex_t *mutex;
} axis2_conf_ctx_impl_t;
/** Interface to implementation conversion macro */
@@ -114,8 +117,15 @@
conf_ctx_impl->op_ctx_map = NULL;
conf_ctx_impl->svc_ctx_map = NULL;
conf_ctx_impl->svc_grp_ctx_map = NULL;
+ conf_ctx_impl->mutex = axis2_thread_mutex_create((*env)->allocator,
+ AXIS2_THREAD_MUTEX_DEFAULT);
+ if(NULL == conf_ctx_impl->mutex)
+ {
+ axis2_conf_ctx_free(&(conf_ctx_impl->conf_ctx), env);
+ return NULL;
+ }
- if (conf)
+ if (conf)
conf_ctx_impl->conf = conf;
conf_ctx_impl->base = axis2_ctx_create(env);
@@ -226,12 +236,12 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
if (conf_ctx_impl->op_ctx_map)
{
axis2_hash_set(conf_ctx_impl->op_ctx_map, message_id, AXIS2_HASH_KEY_STRING, op_ctx);
}
-
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return AXIS2_SUCCESS;
}
@@ -244,11 +254,16 @@
AXIS2_ENV_CHECK(env, NULL);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
if (conf_ctx_impl->op_ctx_map)
{
- return (axis2_op_ctx_t*)axis2_hash_get(conf_ctx_impl->op_ctx_map, message_id, AXIS2_HASH_KEY_STRING);
+ axis2_op_ctx_t *rv = NULL;
+ rv = (axis2_op_ctx_t*)axis2_hash_get(conf_ctx_impl->op_ctx_map,
+ message_id, AXIS2_HASH_KEY_STRING);
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
+ return rv;
}
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return NULL;
}
@@ -262,12 +277,12 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
if (conf_ctx_impl->svc_ctx_map)
{
axis2_hash_set(conf_ctx_impl->svc_ctx_map, svc_id, AXIS2_HASH_KEY_STRING, svc_ctx);
}
-
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return AXIS2_SUCCESS;
}
@@ -280,11 +295,16 @@
AXIS2_ENV_CHECK(env, NULL);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
if (conf_ctx_impl->svc_ctx_map)
{
- return (axis2_svc_ctx_t*)axis2_hash_get(conf_ctx_impl->svc_ctx_map, svc_id, AXIS2_HASH_KEY_STRING);
+ axis2_svc_ctx_t *rv = NULL;
+ rv = (axis2_svc_ctx_t*)axis2_hash_get(conf_ctx_impl->svc_ctx_map,
+ svc_id, AXIS2_HASH_KEY_STRING);
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
+ return rv;
}
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return NULL;
}
@@ -298,12 +318,12 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
if (conf_ctx_impl->svc_grp_ctx_map)
{
axis2_hash_set(conf_ctx_impl->svc_grp_ctx_map, svc_grp_id, AXIS2_HASH_KEY_STRING, svc_grp_ctx);
}
-
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return AXIS2_SUCCESS;
}
@@ -316,19 +336,30 @@
AXIS2_ENV_CHECK(env, NULL);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
if (conf_ctx_impl->svc_grp_ctx_map)
{
- return (axis2_svc_grp_ctx_t*)axis2_hash_get(conf_ctx_impl->svc_grp_ctx_map, svc_grp_id, AXIS2_HASH_KEY_STRING);
+ axis2_svc_grp_ctx_t *rv = NULL;
+ rv = (axis2_svc_grp_ctx_t*)axis2_hash_get(conf_ctx_impl->svc_grp_ctx_map
+ , svc_grp_id, AXIS2_HASH_KEY_STRING);
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
+ return rv;
}
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return NULL;
}
axis2_char_t* AXIS2_CALL axis2_conf_ctx_get_root_dir(struct axis2_conf_ctx *conf_ctx,
axis2_env_t **env)
{
- AXIS2_ENV_CHECK(env, NULL);
- return AXIS2_INTF_TO_IMPL(conf_ctx)->root_dir;
+ axis2_char_t *rv = NULL;
+ axis2_conf_ctx_impl_t *conf_ctx_impl = NULL;
+ AXIS2_ENV_CHECK(env, NULL);
+ conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
+ rv = AXIS2_INTF_TO_IMPL(conf_ctx)->root_dir;
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
+ return rv;
}
axis2_status_t AXIS2_CALL axis2_conf_ctx_set_root_dir(struct axis2_conf_ctx *conf_ctx,
@@ -340,7 +371,7 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
if (conf_ctx_impl->root_dir)
{
AXIS2_FREE((*env)->allocator, conf_ctx_impl->root_dir);
@@ -353,10 +384,11 @@
if (!(conf_ctx_impl->root_dir))
{
AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return AXIS2_FAILURE;
}
}
-
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return AXIS2_SUCCESS;
}
@@ -371,7 +403,7 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
conf_ctx_impl = AXIS2_INTF_TO_IMPL(conf_ctx);
-
+ axis2_thread_mutex_lock(conf_ctx_impl->mutex);
conf_ctx_impl->conf = conf;
for (hi = axis2_hash_first (conf_ctx_impl->op_ctx_map, env);
@@ -406,7 +438,7 @@
AXIS2_SVC_GRP_CTX_INIT(svc_grp_ctx, env, conf);
}
}
-
+ axis2_thread_mutex_unlock(conf_ctx_impl->mutex);
return AXIS2_SUCCESS;
}
Modified: webservices/axis2/trunk/c/modules/core/context/op_ctx.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/context/op_ctx.c?rev=377952&r1=377951&r2=377952&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/context/op_ctx.c (original)
+++ webservices/axis2/trunk/c/modules/core/context/op_ctx.c Tue Feb 14 22:56:30 2006
@@ -46,6 +46,8 @@
axis2_qname_t *op_qname;
/** service qname */
axis2_qname_t *svc_qname;
+ /* Mutex to syncronize the read/write operations */
+ axis2_thread_mutex_t *mutex;
} axis2_op_ctx_impl_t;
/** Interface to implementation conversion macro */
@@ -108,7 +110,15 @@
op_ctx_impl->op_ctx_map = NULL;
op_ctx_impl->op_qname = NULL;
op_ctx_impl->svc_qname = NULL;
-
+ op_ctx_impl->mutex = axis2_thread_mutex_create((*env)->allocator,
+ AXIS2_THREAD_MUTEX_DEFAULT);
+
+ if(NULL == op_ctx_impl->mutex)
+ {
+ axis2_op_ctx_free(&(op_ctx_impl->op_ctx), env);
+ return NULL;
+ }
+
op_ctx_impl->base = axis2_ctx_create(env);
if (!(op_ctx_impl->base))
{
@@ -286,7 +296,8 @@
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
op_ctx_impl = AXIS2_INTF_TO_IMPL(op_ctx);
-
+
+ axis2_thread_mutex_lock(op_ctx_impl->mutex);
if (op_ctx_impl->msg_ctx_map)
{
axis2_char_t *message_id = AXIS2_MSG_CTX_GET_MSG_ID(msg_ctx, env);
@@ -295,7 +306,7 @@
axis2_hash_set(op_ctx_impl->msg_ctx_map, message_id, AXIS2_HASH_KEY_STRING, msg_ctx);
}
}
-
+ axis2_thread_mutex_unlock(op_ctx_impl->mutex);
return AXIS2_SUCCESS;
}
@@ -314,11 +325,16 @@
op_ctx_impl = AXIS2_INTF_TO_IMPL(op_ctx);
+ axis2_thread_mutex_lock(op_ctx_impl->mutex);
if (op_ctx_impl->msg_ctx_map)
{
- return axis2_hash_get(op_ctx_impl->msg_ctx_map, message_id, AXIS2_HASH_KEY_STRING);
+ axis2_msg_ctx_t *rv = NULL;
+ rv = axis2_hash_get(op_ctx_impl->msg_ctx_map, message_id,
+ AXIS2_HASH_KEY_STRING);
+ axis2_thread_mutex_unlock(op_ctx_impl->mutex);
+ return rv;
}
-
+ axis2_thread_mutex_unlock(op_ctx_impl->mutex);
return NULL;
}