Questions about multi-threading
haypo at inl.fr
haypo at inl.fr
Thu Jul 6 00:19:52 CEST 2006
Hi,
I'm working on the firewall NuFW [1]. I used gprof to find functions which
takes a lot of time. I'm not sure, but I think that gcrypt really uses too
much mutexes lock() and unlock(). I read gcrypt source code, and used gdb
on server to catch lock() calls.
I didn't understood everything, but I have some questions.
(a) Why do ath_mutex_lock() and ath_mutex_unlock() call mutex_init()? It
looks very weird for me, since this function use another mutex!
(b) Why do ath_mutex_destroy() call mutex_init()??? It's stupid to create
a mutex if it doesn't exist ... to destroy it just after its creation!?
(c) Can a mutex lock() or unlock() fails? (or: it is necessary to check
error code?)
(d) Would it be possible to make random() functions (eg.
gcry_random_bytes() and gcry_create_nonce()) really thread safe? (can be
called in two different threads at the same time and not block one the
call until the first ends)
(e) Why using REGISTER_(...); macro and not simply call them in a function
like "gcrypt_global_init();"? Eg. "REGISTER_DEFAULT_DIGESTS" in
cipher/md.c, it uses a mutex to check if digests are already registred or
not. "REGISTER_DEFAULT_DIGESTS" is called in 7 different functions, but is
it really needed?
[1] Firewall NuFW
http://www.nufw.org/
Victor Stinner
More information about the Gcrypt-devel
mailing list