apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r399635 - /apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c
Date Thu, 04 May 2006 09:40:29 GMT
Author: martin
Date: Thu May  4 02:40:28 2006
New Revision: 399635

URL: http://svn.apache.org/viewcvs?rev=399635&view=rev
Log:
On a non-threaded platform that has sqlite3, apr_dbd_sqlite3.c
does not compile because it invokes the mutex lock functions
unconditionally. (This ugly fix using #ifdef has already been solved
in a cleaner fashion in the httpd-2.3 version.)

Modified:
    apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c

Modified: apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c?rev=399635&r1=399634&r2=399635&view=diff
==============================================================================
--- apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c (original)
+++ apr/apr-util/branches/1.2.x/dbd/apr_dbd_sqlite3.c Thu May  4 02:40:28 2006
@@ -39,7 +39,9 @@
 struct apr_dbd_t {
     sqlite3 *conn;
     apr_dbd_transaction_t *trans;
+#if APR_HAS_THREADS
     apr_thread_mutex_t *mutex;
+#endif
     apr_pool_t *pool;
 };
 
@@ -93,11 +95,15 @@
         return sql->trans->errnum;
     }
 
+#if APR_HAS_THREADS
     apr_thread_mutex_lock(sql->mutex);
+#endif
 
     ret = sqlite3_prepare(sql->conn, query, strlen(query), &stmt, &tail);
     if (!dbd_sqlite3_is_success(ret)) {
+#if APR_HAS_THREADS
         apr_thread_mutex_unlock(sql->mutex);
+#endif
         return ret;
     } else {
         int column_count;
@@ -118,9 +124,13 @@
                 if (retry_count++ > MAX_RETRY_COUNT) {
                     ret = SQLITE_ERROR;
                 } else {
+#if APR_HAS_THREADS
                     apr_thread_mutex_unlock(sql->mutex);
+#endif
                     apr_sleep(MAX_RETRY_SLEEP);
+#if APR_HAS_THREADS
                     apr_thread_mutex_lock(sql->mutex);
+#endif
                 }
             } else if (ret == SQLITE_ROW) {
                 int length;
@@ -179,7 +189,9 @@
         } while (ret == SQLITE_ROW || ret == SQLITE_BUSY);
     }
     ret = sqlite3_finalize(stmt);
+#if APR_HAS_THREADS
     apr_thread_mutex_unlock(sql->mutex);
+#endif
 
     if (sql->trans) {
         sql->trans->errnum = ret;
@@ -242,7 +254,9 @@
     }
 
     length = strlen(query);
+#if APR_HAS_THREADS
     apr_thread_mutex_lock(sql->mutex);
+#endif
 
     do {
         int retry_count = 0;
@@ -258,9 +272,13 @@
             if (ret != SQLITE_BUSY)
                 break;
 
+#if APR_HAS_THREADS
             apr_thread_mutex_unlock(sql->mutex);
+#endif
             apr_sleep(MAX_RETRY_SLEEP);
+#if APR_HAS_THREADS
             apr_thread_mutex_lock(sql->mutex);
+#endif
         }
 
         *nrows = sqlite3_changes(sql->conn);
@@ -272,7 +290,9 @@
     if (dbd_sqlite3_is_success(ret)) {
         ret =  0;
     }
+#if APR_HAS_THREADS
     apr_thread_mutex_unlock(sql->mutex);
+#endif
     if (sql->trans) {
         sql->trans->errnum = ret;
     }
@@ -377,12 +397,14 @@
     sql->conn = conn;
     sql->pool = pool;
     sql->trans = NULL;
+#if APR_HAS_THREADS
     /* Create a mutex */
     res = apr_thread_mutex_create(&sql->mutex, APR_THREAD_MUTEX_DEFAULT,
                                   pool);
     if (res != APR_SUCCESS) {
         return NULL;
     }
+#endif
 
     return sql;
 }
@@ -390,7 +412,9 @@
 static apr_status_t dbd_sqlite3_close(apr_dbd_t *handle)
 {
     sqlite3_close(handle->conn);
+#if APR_HAS_THREADS
     apr_thread_mutex_destroy(handle->mutex);
+#endif
     return APR_SUCCESS;
 }
 



Mime
View raw message