Removed
Link Here
|
1 |
--- apr-util-1.2.7/dbd/apr_dbd_sqlite3.c.orig Wed Mar 15 01:04:54 2006 |
2 |
+++ apr-util-1.2.7/dbd/apr_dbd_sqlite3.c Mon May 29 09:08:08 2006 |
3 |
@@ -24,6 +24,7 @@ |
4 |
#include <sqlite3.h> |
5 |
|
6 |
#include "apr_strings.h" |
7 |
+#include "apr_thread_mutex.h" |
8 |
#include "apr_time.h" |
9 |
|
10 |
#include "apr_dbd_internal.h" |
11 |
@@ -39,7 +40,9 @@ |
12 |
struct apr_dbd_t { |
13 |
sqlite3 *conn; |
14 |
apr_dbd_transaction_t *trans; |
15 |
+#if APR_HAS_THREADS |
16 |
apr_thread_mutex_t *mutex; |
17 |
+#endif |
18 |
apr_pool_t *pool; |
19 |
}; |
20 |
|
21 |
@@ -93,11 +96,15 @@ |
22 |
return sql->trans->errnum; |
23 |
} |
24 |
|
25 |
+#if APR_HAS_THREADS |
26 |
apr_thread_mutex_lock(sql->mutex); |
27 |
+#endif |
28 |
|
29 |
ret = sqlite3_prepare(sql->conn, query, strlen(query), &stmt, &tail); |
30 |
if (!dbd_sqlite3_is_success(ret)) { |
31 |
+#if APR_HAS_THREADS |
32 |
apr_thread_mutex_unlock(sql->mutex); |
33 |
+#endif |
34 |
return ret; |
35 |
} else { |
36 |
int column_count; |
37 |
@@ -118,7 +125,9 @@ |
38 |
if (retry_count++ > MAX_RETRY_COUNT) { |
39 |
ret = SQLITE_ERROR; |
40 |
} else { |
41 |
+#if APR_HAS_THREADS |
42 |
apr_thread_mutex_unlock(sql->mutex); |
43 |
+#endif |
44 |
apr_sleep(MAX_RETRY_SLEEP); |
45 |
apr_thread_mutex_lock(sql->mutex); |
46 |
} |
47 |
@@ -179,7 +188,9 @@ |
48 |
} while (ret == SQLITE_ROW || ret == SQLITE_BUSY); |
49 |
} |
50 |
ret = sqlite3_finalize(stmt); |
51 |
+#if APR_HAS_THREADS |
52 |
apr_thread_mutex_unlock(sql->mutex); |
53 |
+#endif |
54 |
|
55 |
if (sql->trans) { |
56 |
sql->trans->errnum = ret; |
57 |
@@ -242,7 +253,9 @@ |
58 |
} |
59 |
|
60 |
length = strlen(query); |
61 |
+#if APR_HAS_THREADS |
62 |
apr_thread_mutex_lock(sql->mutex); |
63 |
+#endif |
64 |
|
65 |
do { |
66 |
ret = sqlite3_prepare(sql->conn, query, length, &stmt, &tail); |
67 |
@@ -260,7 +273,9 @@ |
68 |
if (dbd_sqlite3_is_success(ret)) { |
69 |
ret = 0; |
70 |
} |
71 |
+#if APR_HAS_THREADS |
72 |
apr_thread_mutex_unlock(sql->mutex); |
73 |
+#endif |
74 |
if (sql->trans) { |
75 |
sql->trans->errnum = ret; |
76 |
} |
77 |
@@ -366,12 +381,14 @@ |
78 |
sql->conn = conn; |
79 |
sql->pool = pool; |
80 |
sql->trans = NULL; |
81 |
+#if APR_HAS_THREADS |
82 |
/* Create a mutex */ |
83 |
res = apr_thread_mutex_create(&sql->mutex, APR_THREAD_MUTEX_DEFAULT, |
84 |
pool); |
85 |
if (res != APR_SUCCESS) { |
86 |
return NULL; |
87 |
} |
88 |
+#endif |
89 |
|
90 |
return sql; |
91 |
} |
92 |
@@ -379,7 +396,9 @@ |
93 |
static apr_status_t dbd_sqlite3_close(apr_dbd_t *handle) |
94 |
{ |
95 |
sqlite3_close(handle->conn); |
96 |
+#if APR_HAS_THREADS |
97 |
apr_thread_mutex_destroy(handle->mutex); |
98 |
+#endif |
99 |
return APR_SUCCESS; |
100 |
} |
101 |
|