All pastes #199060 Raw Edit

Untitled

public text v1 · immutable
#199060 ·published 2006-10-12 10:01 UTC
rendered paste body
static void register_hooks(apr_pool_t *p) {
    ap_hook_post_config(spread_init, NULL, NULL, APR_HOOK_MIDDLE);
}


non detachable thread works, if I do a join: 

static int spread_init (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s){
    apr_status_t rv;
    apr_thread_t *thd;
    apr_threadattr_t *thd_attr;
   
    rv = apr_thread_create(&thd, NULL, doit, s, p);
    rv = apr_thread_join(&rv, thd); */
  return DECLINED;
}


detached thread results in segfault: 

static int spread_init (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s){
    apr_status_t rv;
    apr_thread_t *thd;
    apr_threadattr_t *thd_attr;
  
    apr_threadattr_create(&thd_attr, p);
    
    apr_threadattr_detach_set(thd_attr, APR_PROC_DETACH_DAEMONIZE);
  
    rv = apr_thread_create(&thd, threadattr, doit, s, p);
  return DECLINED;
}