You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by luoyi <lu...@gmail.com> on 2008/01/11 16:50:44 UTC

is SDBM threadsafe ?

as far as I know, apr-util's sdbm is threadsafe ,but I've some demo
code doesn't look right.

the code:

https://opensvn.csie.org/lylib/trunk/demo/apr/source/dbm_demo.c

it create 10 thread, each insert 100 key-value pair to the dbm file.
and then dbm_dump the file.

my test script is:

https://opensvn.csie.org/lylib/trunk/demo/apr/test.sh

if the sdbm is threadsafe, the script will give me 10 lines of 100.
but if I run it many times, then I can get some num other than 100:

when it's right:
luoyi@skyking apr$ ./test.sh
100
100
100
100
100
100
100
100
100
100

then run many times:

luoyi@skyking apr$ for ii in `seq 0 20`; do ./test.sh |grep -v 100; done
59
108
68
80
90
105
112
115
113
101
62
71
79
92
106
113
115
114
27
24
194
19
17
16
17
19
193
191
27
24
194
19
17
16
17
19
193
191

my apr-version:

luoyi@skyking apr$ apr-1-config --version
1.2.8
luoyi@skyking apr$ apu-1-config --version
1.2.8