apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luoyi <luoyi...@gmail.com>
Subject is SDBM threadsafe ?
Date Fri, 11 Jan 2008 15:50:44 GMT
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

Mime
View raw message