Re: Bug in log.c
Stipe Tolj <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Organization | Wapme Systems AG |
| Message-ID | <[email protected]> |
Stipe Tolj wrote: > > ok, I just commited this: > > 2003-06-19 Stipe Tolj <[email protected]> > * gwlib/gwthread.h, gwlib/gwthread-pthread.c: added function > gwthread_table_slot() to provide the slot integer of threadtable > the thread is using. > * gwlib/log.c: fixed Michael's reported bug for the logging > functions. > > please update your trees and check. > > It implements the module access to the thread[] mapping table inside > the logging module to ensure we don't access over the array limit. > > Because gwthread_self() is unique and assigned to a free slot when the > thread is registered, also (gwthread_self() % THREADTABLE_SIZE) is > unique and provides us with the correct slot the thread belongs to. bounced back the revision of the gwthread files. In order to have them not changed I simply #define'ed things inside log.c directly: /* * Ensure we use the real threadtable slot number to map the thread id * instead of the thread id reported by gwthread_self() */ #define thread_slot() (gwthread_self() % THREADTABLE_SIZE) and hence: void error(int e, const char *fmt, ...) { if ((e = thread_to[thread_slot()])) { FUNCTION_GUTS_EXCL(GW_ERROR, ""); } else { FUNCTION_GUTS(GW_ERROR, ""); } } that's it. Stipe [email protected] ------------------------------------------------------------------- Wapme Systems AG Vogelsanger Weg 80 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [email protected] Internet: http://www.wapme-systems.de ------------------------------------------------------------------- wapme.net - wherever you are