Permalink
Browse files

fix a lock bug when creating queue

  • Loading branch information...
1 parent 78625cc commit 6b5e71f5ec3040ad0c05738eab59d3162727a19b @stvchu committed Aug 12, 2010
Showing with 22 additions and 22 deletions.
  1. +4 −1 ChangeLog
  2. +2 −5 bdb.c
  3. +10 −10 configure
  4. +1 −1 configure.ac
  5. +5 −5 tools/Makefile
View
@@ -1,4 +1,7 @@
-2008-11-25 Steve Chu <stvchu@gmail.com>
+2010-08-12 Steve Chu <stvchu@gmail.com>
+* fix a lock bug when creating queue
+
+2009-12-09 Steve Chu <stvchu@gmail.com>
* version 0.2.0 is released.
2009-12-09 Steve Chu <stvchu@gmail.com>
View
7 bdb.c
@@ -264,8 +264,6 @@ void bdb_qlist_db_close(void){
}
int bdb_create_queue(char *queue_name) {
- pthread_rwlock_wrlock(&qlist_ht_lock);
-
char *k = strdup(queue_name);
assert(k != NULL);
queue_t *q = (queue_t *)calloc(1, sizeof(queue_t));
@@ -309,14 +307,12 @@ int bdb_create_queue(char *queue_name) {
CHECK_DB_RET(ret);
int result = hashtable_insert(qlist_htp, (void *)k, (void *)q);
assert(result != 0);
- pthread_rwlock_unlock(&qlist_ht_lock);
return 0;
dberr:
if (txnp != NULL){
txnp->abort(txnp);
}
fprintf(stderr, "bdb_create_queue: %s %s\n", queue_name, db_strerror(ret));
- pthread_rwlock_unlock(&qlist_ht_lock);
return -1;
}
@@ -554,12 +550,13 @@ int bdb_set(char *key, item *it){
if (NULL == q) {
pthread_rwlock_unlock(&qlist_ht_lock);
+ /* switch to write lock */
+ pthread_rwlock_wrlock(&qlist_ht_lock);
ret = bdb_create_queue(key);
if (0 != ret){
return -1;
}
/* search again */
- pthread_rwlock_rdlock(&qlist_ht_lock);
q = (queue_t *)hashtable_search(qlist_htp, (void *)key);
}
View
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for memcacheq 0.2.0.
+# Generated by GNU Autoconf 2.61 for memcacheq 0.2.1.
#
# Report bugs to <stvchu@gmail.com>.
#
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='memcacheq'
PACKAGE_TARNAME='memcacheq'
-PACKAGE_VERSION='0.2.0'
-PACKAGE_STRING='memcacheq 0.2.0'
+PACKAGE_VERSION='0.2.1'
+PACKAGE_STRING='memcacheq 0.2.1'
PACKAGE_BUGREPORT='stvchu@gmail.com'
# Factoring default headers for most tests.
@@ -1206,7 +1206,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures memcacheq 0.2.0 to adapt to many kinds of systems.
+\`configure' configures memcacheq 0.2.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1272,7 +1272,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of memcacheq 0.2.0:";;
+ short | recursive ) echo "Configuration of memcacheq 0.2.1:";;
esac
cat <<\_ACEOF
@@ -1363,7 +1363,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-memcacheq configure 0.2.0
+memcacheq configure 0.2.1
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1377,7 +1377,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by memcacheq $as_me 0.2.0, which was
+It was created by memcacheq $as_me 0.2.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -2067,7 +2067,7 @@ fi
# Define the identity of the package.
PACKAGE='memcacheq'
- VERSION='0.2.0'
+ VERSION='0.2.1'
cat >>confdefs.h <<_ACEOF
@@ -6011,7 +6011,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by memcacheq $as_me 0.2.0, which was
+This file was extended by memcacheq $as_me 0.2.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6064,7 +6064,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-memcacheq config.status 0.2.0
+memcacheq config.status 0.2.1
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
View
@@ -1,5 +1,5 @@
AC_PREREQ(2.61)
-AC_INIT([memcacheq], [0.2.0], [stvchu@gmail.com])
+AC_INIT([memcacheq], [0.2.1], [stvchu@gmail.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AM_PROG_CC_C_O
View
@@ -51,7 +51,7 @@ CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2
CPP = gcc -E
-CPPFLAGS = -I/usr/local/BerkeleyDB.4.7/include
+CPPFLAGS = -I/usr/local/BerkeleyDB.5.0/include
CYGPATH_W = echo
DEFS = -DHAVE_CONFIG_H
DEPDIR = .deps
@@ -66,7 +66,7 @@ INSTALL_DATA = ${INSTALL} -m 644
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-LDFLAGS = -L/usr/local/BerkeleyDB.4.7/lib
+LDFLAGS = -L/usr/local/BerkeleyDB.5.0/lib
LIBOBJS =
LIBS = -ldb -levent
LTLIBOBJS =
@@ -76,14 +76,14 @@ OBJEXT = o
PACKAGE = memcacheq
PACKAGE_BUGREPORT = stvchu@gmail.com
PACKAGE_NAME = memcacheq
-PACKAGE_STRING = memcacheq 0.2.0
+PACKAGE_STRING = memcacheq 0.2.1
PACKAGE_TARNAME = memcacheq
-PACKAGE_VERSION = 0.2.0
+PACKAGE_VERSION = 0.2.1
PATH_SEPARATOR = :
SET_MAKE =
SHELL = /bin/sh
STRIP =
-VERSION = 0.2.0
+VERSION = 0.2.1
abs_builddir = /Users/stvchu/Workspace/memcacheq/tools
abs_srcdir = /Users/stvchu/Workspace/memcacheq/tools
abs_top_builddir = /Users/stvchu/Workspace/memcacheq

0 comments on commit 6b5e71f

Please sign in to comment.