Added
Link Here
|
1 |
--- bdb.c.orig 2012-01-24 14:49:12.248201883 +0400 |
2 |
+++ bdb.c 2012-01-24 14:50:35.801194396 +0400 |
3 |
@@ -264,8 +264,6 @@ |
4 |
} |
5 |
|
6 |
int bdb_create_queue(char *queue_name) { |
7 |
- pthread_rwlock_wrlock(&qlist_ht_lock); |
8 |
- |
9 |
char *k = strdup(queue_name); |
10 |
assert(k != NULL); |
11 |
queue_t *q = (queue_t *)calloc(1, sizeof(queue_t)); |
12 |
@@ -309,14 +307,12 @@ |
13 |
CHECK_DB_RET(ret); |
14 |
int result = hashtable_insert(qlist_htp, (void *)k, (void *)q); |
15 |
assert(result != 0); |
16 |
- pthread_rwlock_unlock(&qlist_ht_lock); |
17 |
return 0; |
18 |
dberr: |
19 |
if (txnp != NULL){ |
20 |
txnp->abort(txnp); |
21 |
} |
22 |
fprintf(stderr, "bdb_create_queue: %s %s\n", queue_name, db_strerror(ret)); |
23 |
- pthread_rwlock_unlock(&qlist_ht_lock); |
24 |
return -1; |
25 |
} |
26 |
|
27 |
@@ -554,12 +550,13 @@ |
28 |
|
29 |
if (NULL == q) { |
30 |
pthread_rwlock_unlock(&qlist_ht_lock); |
31 |
+ /* switch to write lock */ |
32 |
+ pthread_rwlock_wrlock(&qlist_ht_lock); |
33 |
ret = bdb_create_queue(key); |
34 |
if (0 != ret){ |
35 |
return -1; |
36 |
} |
37 |
/* search again */ |
38 |
- pthread_rwlock_rdlock(&qlist_ht_lock); |
39 |
q = (queue_t *)hashtable_search(qlist_htp, (void *)key); |
40 |
} |
41 |
|