Here it is, the new thread interface.
authorDave West <davew@uncensored.citadel.org>
Sun, 25 Nov 2007 22:15:18 +0000 (22:15 +0000)
committerDave West <davew@uncensored.citadel.org>
Sun, 25 Nov 2007 22:15:18 +0000 (22:15 +0000)
commit84a0666848ccbea920f0bd398baf149c1a12ea74
tree44c8c7d470fcdb2c4b0352682e59549e5deb95b2
parent77ed8082379b4c2c9ebfc6d4b85656fc7f4782bf
Here it is, the new thread interface.
The code to handle threads is in sysdep.c
This new thread interface has caused a change to the way modules are
initialised. A modules init function is now called twice. First time
threading==0, second time threading==1. threading is a parameter passed
to the init function.
You should not create a thread until your init function has been called
with threading==1. See serv_fulltext.c as an example.
All of the modules init functions have been updated for this change.
The old RegisterThread stuff has gone away.
time_to_die has gone as it was used to tell threads to exit, we now use
CtdlThreadCheckStop() instead which return non zero if the thread should
exit.
The server will exit when all threads have stopped.
CtdlThreadCreate() handles creation of threads in a safe manner.
CtdlThreadSleep() is used to do a sleep in a thread.
CtdlThreadStop() is used to stop a thread.
CtdlThreadStopAll() stops all threads and thus causes the server to
exit.
Threads are cleanup when they die by the main server process (every 10
seconds) which originally did nothing useful.
CtdlThreadGC() will force a garbage collection now.
CtdlThreadGetCount() return the number of threads in the system not just
the number of workers.
CtdlThreadSelf() returns a pointer to this threads thread structure.
CtdlThreadName() returns a strdup'd string that is the threads name, you
need to free this. It also allows you to change a threads name.
CtdlThreadCancel() does the same as pthread_cancel except it also
informs our thread system. Don't use this if you can help it.

There are a lot of debug messages at the moment, they will go away once
stability is proven.
43 files changed:
citadel/citserver.c
citadel/database.h
citadel/database_sleepycat.c
citadel/housekeeping.c
citadel/include/ctdl_module.h
citadel/mk_module_init.sh
citadel/modules/autocompletion/serv_autocompletion.c
citadel/modules/bio/serv_bio.c
citadel/modules/calendar/serv_calendar.c
citadel/modules/chat/serv_chat.c
citadel/modules/checkpoint/serv_checkpoint.c [new file with mode: 0644]
citadel/modules/expire/serv_expire.c
citadel/modules/fulltext/serv_fulltext.c
citadel/modules/funambol/serv_funambol.c
citadel/modules/imap/serv_imap.c
citadel/modules/inetcfg/serv_inetcfg.c
citadel/modules/ldap/serv_ldap.c
citadel/modules/listsub/serv_listsub.c
citadel/modules/managesieve/serv_managesieve.c
citadel/modules/mrtg/serv_mrtg.c
citadel/modules/netfilter/serv_netfilter.c
citadel/modules/network/serv_network.c
citadel/modules/newuser/serv_newuser.c
citadel/modules/notes/serv_notes.c
citadel/modules/pager/serv_pager.c
citadel/modules/pas2/serv_pas2.c
citadel/modules/pop3/serv_pop3.c
citadel/modules/pop3client/serv_pop3client.c
citadel/modules/rssclient/serv_rssclient.c
citadel/modules/rwho/serv_rwho.c
citadel/modules/sieve/serv_sieve.c
citadel/modules/smtp/serv_smtp.c
citadel/modules/spam/serv_spam.c
citadel/modules/test/serv_test.c
citadel/modules/upgrade/serv_upgrade.c
citadel/modules/vandelay/serv_vandelay.c
citadel/modules/vcard/serv_vcard.c
citadel/serv_extensions.c
citadel/serv_extensions.h
citadel/server_main.c
citadel/sysconfig.h
citadel/sysdep.c
citadel/sysdep_decls.h