Changeset 142 for trunk/src/sh_pthread.c
- Timestamp:
- Oct 30, 2007, 12:17:00 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_pthread.c
r141 r142 40 40 41 41 /* MODULES: init() 42 * -- starts thread_run() function if threaded 43 * -- fallback on internal_init if threading fails 44 * -- and returns MODULE_INACTIVE/MODULE_ACTIVE/MODULE_THREADED 45 * 46 * int retval = MODULE_INACTIVE; 47 * if (0 != sh_pthread_create(thread_run, NULL)) 48 * return internal_init(); 49 * return MODULE_THREADED; 50 * 51 * thread_run() 42 * 43 * #ifdef HAVE_PTHREAD 44 * if (arg != NULL) 45 * { 46 * if (0 == sh_pthread_create(sh_threaded_module_run, (void *)arg)) 47 * return SH_MOD_THREAD; 48 * else 49 * return SH_MOD_FAILED; 50 * } 51 * #else 52 * return sh_utmp_init_internal(); 53 * #endif 54 * 55 * 56 * sh_threaded_module_run(module_struct) 52 57 * -- calls internal init, 53 58 * -- polls timer, … … 131 136 /* ---- Utility functions for modules ---- 132 137 */ 133 void sh_threaded_module_ reconf(void *arg)138 void sh_threaded_module_cleanup(void *arg) 134 139 { 135 140 sh_mtype * this_module = (sh_mtype *) arg; 136 this_module->mod_ reconf();141 this_module->mod_cleanup(); 137 142 return; 138 143 } 139 144 140 void sh_threaded_module_run(void *arg)145 void * sh_threaded_module_run(void *arg) 141 146 { 142 147 sh_mtype * this_module = (sh_mtype *) arg; … … 153 158 if (0 == this_module->mod_init(NULL)) 154 159 { 155 pthread_cleanup_push(sh_threaded_module_ reconf, arg);160 pthread_cleanup_push(sh_threaded_module_cleanup, arg); 156 161 157 162 while (1) … … 159 164 if (0 != this_module->mod_timer(time(NULL))) 160 165 { 161 this_module->mod_check(); 166 /* If module has been de-activated on reconfigure, 167 * mod_check() must return non-zero. 168 * The mod_cleanup() routine must then enable the 169 * module to be re-activated eventually. 170 */ 171 if (0 != this_module->mod_check()) 172 break; 162 173 pthread_testcancel(); 163 174 retry_msleep(1,0); … … 171 182 pthread_cleanup_pop(1); 172 183 173 return ;184 return NULL; 174 185 } 175 186
Note:
See TracChangeset
for help on using the changeset viewer.