Author: samisa
Date: Tue Sep 11 19:06:08 2007
New Revision: 574767
URL: http://svn.apache.org/viewvc?rev=574767&view=rev
Log:
Fixed some loclking problems related to sqlite
Modified:
webservices/sandesha/trunk/c/samples/rm_echo_1_1/rm_echo_1_1.c
webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c
webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c
webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c
webservices/sandesha/trunk/c/src/storage/sqlite/permanent_transaction.c
webservices/sandesha/trunk/c/src/storage/sqlite/sandesha2_permanent_bean_mgr.h
Modified: webservices/sandesha/trunk/c/samples/rm_echo_1_1/rm_echo_1_1.c
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/rm_echo_1_1/rm_echo_1_1.c?rev=574767&r1=574766&r2=574767&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/samples/rm_echo_1_1/rm_echo_1_1.c (original)
+++ webservices/sandesha/trunk/c/samples/rm_echo_1_1/rm_echo_1_1.c Tue Sep 11
19:06:08 2007
@@ -299,13 +299,15 @@
{
/** Wait till callback is complete. Simply keep the parent thread running
until our on_complete or on_error is invoked */
- while(1)
+ int count = 3;
+ while(count-- > 0)
{
if (axis2_callback_get_complete(callback, env))
{
/* We are done with the callback */
break;
}
+ AXIS2_SLEEP(SANDESHA2_MAX_COUNT);
}
return;
}
Modified: webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c?rev=574767&r1=574766&r2=574767&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c (original)
+++ webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c Tue Sep
11 19:06:08 2007
@@ -261,7 +261,10 @@
if(!within_transaction && !rolled_back)
{
axutil_property_t *prop = NULL;
- sandesha2_transaction_commit(transaction, env);
+ if (transaction)
+ {
+ sandesha2_transaction_commit(transaction, env);
+ }
prop = axutil_property_create_with_args(env, 0, 0, 0,
AXIS2_VALUE_FALSE);
axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_WITHIN_TRANSACTION,
Modified: webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c?rev=574767&r1=574766&r2=574767&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c
(original)
+++ webservices/sandesha/trunk/c/src/storage/sqlite/permanent_bean_mgr.c Tue
Sep 11 19:06:08 2007
@@ -252,11 +252,14 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return AXIS2_FALSE;
+ }
rc = sqlite3_exec(dbconn, sql_stmt_insert, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_insert,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if( rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -292,7 +295,10 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return AXIS2_FALSE;
+ }
args = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_bean_mgr_args_t));
args->env = env;
args->data = NULL;
@@ -300,7 +306,7 @@
&error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_retrieve,
- retrieve_func, args, &error_msg, rc);
+ retrieve_func, args, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -327,7 +333,7 @@
rc = sqlite3_exec(dbconn, sql_stmt_remove, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_remove,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -362,7 +368,10 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return NULL;
+ }
args = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_bean_mgr_args_t));
args->env = (axutil_env_t*)env;
args->data = NULL;
@@ -370,7 +379,7 @@
&error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_retrieve,
- retrieve_func, args, &error_msg, rc);
+ retrieve_func, args, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -397,7 +406,7 @@
&error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_retrieve,
- retrieve_func, args, &error_msg, rc);
+ retrieve_func, args, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -438,11 +447,15 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return AXIS2_FALSE;
+ }
+
rc = sqlite3_exec(dbconn, sql_stmt_update, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_update,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -498,7 +511,7 @@
&error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn, sql_stmt_find,
- find_func, args, &error_msg, rc);
+ find_func, args, &error_msg, rc, bean_mgr_impl->mutex);
if(args->data)
data_array = (axutil_array_list_t *) args->data;
if(rc != SQLITE_OK )
@@ -561,7 +574,7 @@
&error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_count,
- count_func, &count, &error_msg, rc);
+ count_func, &count, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -635,7 +648,10 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return NULL;
+ }
args = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_bean_mgr_args_t));
args->env = (axutil_env_t*)env;
args->data = NULL;
@@ -648,7 +664,7 @@
sandesha2_msg_store_bean_retrieve_callback, args, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_retrieve,
- sandesha2_msg_store_bean_retrieve_callback, args, &error_msg, rc);
+ sandesha2_msg_store_bean_retrieve_callback, args, &error_msg, rc,
bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -757,7 +773,7 @@
sandesha2_msg_store_bean_retrieve_callback, args, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_retrieve,
- sandesha2_msg_store_bean_retrieve_callback, args, &error_msg, rc);
+ sandesha2_msg_store_bean_retrieve_callback, args, &error_msg, rc,
bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -788,7 +804,7 @@
rc = sqlite3_exec(dbconn, sql_stmt_update, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_update,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if( rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -819,7 +835,7 @@
rc = sqlite3_exec(dbconn, sql_stmt_insert, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_insert,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if( rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -857,12 +873,15 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return AXIS2_FALSE;
+ }
sprintf(sql_stmt_remove, "delete from msg where stored_key='%s'", key);
rc = sqlite3_exec(dbconn, sql_stmt_remove, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_remove,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -911,12 +930,15 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return AXIS2_FALSE;
+ }
rc = sqlite3_exec(dbconn, sql_stmt_count,
sandesha2_permanent_bean_mgr_count_callback, &count, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn, sql_stmt_count,
- sandesha2_permanent_bean_mgr_count_callback, &count, &error_msg,
rc);
+ sandesha2_permanent_bean_mgr_count_callback, &count, &error_msg,
rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -937,7 +959,7 @@
rc = sqlite3_exec(dbconn, sql_stmt_update, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_update,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if( rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -964,7 +986,7 @@
rc = sqlite3_exec(dbconn, sql_stmt_insert, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_insert,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if( rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -1004,13 +1026,16 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return AXIS2_FALSE;
+ }
sprintf(sql_stmt_remove,
"delete from response where seq_id='%s' and msg_no=%d", seq_id,
msg_no);
rc = sqlite3_exec(dbconn, sql_stmt_remove, 0, 0, &error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_remove,
- 0, 0, &error_msg, rc);
+ 0, 0, &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -1047,7 +1072,10 @@
dbconn = (sqlite3 *) sandesha2_permanent_storage_mgr_get_dbconn(
bean_mgr_impl->storage_mgr, env);
if(!dbconn)
+ {
+ axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
return NULL;
+ }
args = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_bean_mgr_args_t));
args->env = (axutil_env_t*)env;
args->data = NULL;
@@ -1058,7 +1086,7 @@
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(dbconn,
sql_stmt_retrieve,
sandesha2_permanent_bean_mgr_response_retrieve_callback, args,
- &error_msg, rc);
+ &error_msg, rc, bean_mgr_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(bean_mgr_impl->mutex);
@@ -1081,18 +1109,24 @@
int (*callback_func)(void *, int, char **, char **),
void *args,
char **error_msg,
- int rc)
+ int rc,
+ axutil_thread_mutex_t *mutex)
{
int counter = 0;
printf("in busy handler1\n");
- while(rc == SQLITE_BUSY && counter < 512)
+ while(rc == SQLITE_BUSY && counter < 5)
{
- printf("in busy handler\n");
+ printf("in busy handler %s\n", *error_msg);
if(*error_msg)
sqlite3_free(*error_msg);
counter++;
/*AXIS2_SLEEP(SANDESHA2_BUSY_WAIT_TIME);*/
- AXIS2_USLEEP(100000);
+ /* When this method is invoked, the mutex must have been locked,
+ so unlock before going to sleep */
+ axutil_thread_mutex_unlock(mutex);
+ AXIS2_USLEEP(1000000);
+ /* Sleeping is over, lock again */
+ axutil_thread_mutex_lock(mutex);
rc = sqlite3_exec(dbconn, sql_stmt, callback_func, args, error_msg);
}
printf("in busy handler2\n");
Modified:
webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c?rev=574767&r1=574766&r2=574767&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c
(original)
+++ webservices/sandesha/trunk/c/src/storage/sqlite/permanent_storage_mgr.c Tue
Sep 11 19:06:08 2007
@@ -404,8 +404,10 @@
if(!transaction)
{
+ axutil_thread_mutex_unlock(storage_mgr_impl->mutex);
transaction =
sandesha2_permanent_transaction_create(env, storage_mgr,
thread_id);
+ axutil_thread_mutex_lock(storage_mgr_impl->mutex);
axutil_hash_set(storage_mgr_impl->transactions, thread_id_key,
AXIS2_HASH_KEY_STRING, transaction);
}
Modified:
webservices/sandesha/trunk/c/src/storage/sqlite/permanent_transaction.c
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/sqlite/permanent_transaction.c?rev=574767&r1=574766&r2=574767&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/storage/sqlite/permanent_transaction.c
(original)
+++ webservices/sandesha/trunk/c/src/storage/sqlite/permanent_transaction.c Tue
Sep 11 19:06:08 2007
@@ -166,13 +166,15 @@
sqlite3_close(trans_impl->dbconn);
return NULL;
}
+ axutil_thread_mutex_lock(trans_impl->mutex);
rc = sqlite3_exec(trans_impl->dbconn, "BEGIN TRANSACTION;", 0, 0,
&error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(trans_impl->dbconn,
- "BEGIN TRANSACTION", 0, 0, &error_msg, rc);
+ "BEGIN TRANSACTION", 0, 0, &error_msg, rc, trans_impl->mutex);
if(rc != SQLITE_OK )
{
+ axutil_thread_mutex_unlock(trans_impl->mutex);
AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SQL_ERROR, AXIS2_FAILURE);
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SQL Error %s",
error_msg);
@@ -181,6 +183,8 @@
sandesha2_transaction_free(&(trans_impl->trans), env);
return NULL;
}
+
+ axutil_thread_mutex_unlock(trans_impl->mutex);
trans_impl->is_active = AXIS2_TRUE;
return &(trans_impl->trans);
}
@@ -254,7 +258,7 @@
if(rc == SQLITE_BUSY)
{
rc = sandesha2_permanent_bean_mgr_busy_handler(trans_impl->dbconn,
- "COMMIT TRANSACTION", 0, 0, &error_msg, rc);
+ "COMMIT TRANSACTION", 0, 0, &error_msg, rc, trans_impl->mutex);
}
if(rc != SQLITE_OK )
{
@@ -285,7 +289,7 @@
&error_msg);
if(rc == SQLITE_BUSY)
rc = sandesha2_permanent_bean_mgr_busy_handler(trans_impl->dbconn,
- "ROLLBACK TRANSACTION", 0, 0, &error_msg, rc);
+ "ROLLBACK TRANSACTION", 0, 0, &error_msg, rc, trans_impl->mutex);
if(rc != SQLITE_OK )
{
axutil_thread_mutex_unlock(trans_impl->mutex);
Modified:
webservices/sandesha/trunk/c/src/storage/sqlite/sandesha2_permanent_bean_mgr.h
URL:
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/sqlite/sandesha2_permanent_bean_mgr.h?rev=574767&r1=574766&r2=574767&view=diff
==============================================================================
---
webservices/sandesha/trunk/c/src/storage/sqlite/sandesha2_permanent_bean_mgr.h
(original)
+++
webservices/sandesha/trunk/c/src/storage/sqlite/sandesha2_permanent_bean_mgr.h
Tue Sep 11 19:06:08 2007
@@ -198,7 +198,8 @@
int (*callback_func)(void *, int, char **, char **),
void *arg,
char **error_msg,
- int rc);
+ int rc,
+ axutil_thread_mutex_t *mutex);
/** @} */
#ifdef __cplusplus
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]