/*--------------------------------------------------------------------------*/ static void wd_child_init_hook(apr_pool_t *p, server_rec *s) { apr_status_t rv; const apr_array_header_t *wl; if (!wd_server_conf->child_workers) { /* We don't have anything configured, bail out. */ return; } if ((wl = ap_list_provider_names(p, AP_WATCHDOG_PGROUP, AP_WATCHDOG_CVERSION))) { const ap_list_provider_names_t *wn; int i; wn = (ap_list_provider_names_t *)wl->elts; for (i = 0; i < wl->nelts; i++) { ap_watchdog_t *w = ap_lookup_provider(AP_WATCHDOG_PGROUP, wn[i].provider_name, AP_WATCHDOG_CVERSION); if (w && w->active) { /* We have some callbacks registered. * Kick of the watchdog */ if ((rv = wd_startup(w, wd_server_conf->pool)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(01573) "Watchdog: Failed to create worker thread."); /* No point to continue */ return; } } } } }
int ml_list_provider(lua_State*L) { const request_rec* r = CHECK_REQUEST_OBJECT(1); const char*group = luaL_checkstring(L, 2); const char*version = luaL_optstring(L, 3, "0"); apr_array_header_t* arr = ap_list_provider_names(r->pool, group, version); lua_pushstring(L, apr_array_pstrcat(r->pool, arr, ',')); return 1; }
/*--------------------------------------------------------------------------*/ static int wd_post_config_hook(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { apr_status_t rv; const char *pk = "watchdog_init_module_tag"; apr_pool_t *pproc = s->process->pool; const apr_array_header_t *wl; if (ap_state_query(AP_SQ_MAIN_STATE) == AP_SQ_MS_CREATE_PRE_CONFIG) /* First time config phase -- skip. */ return OK; apr_pool_userdata_get((void *)&wd_server_conf, pk, pproc); if (!wd_server_conf) { if (!(wd_server_conf = apr_pcalloc(pproc, sizeof(wd_server_conf_t)))) return APR_ENOMEM; apr_pool_create(&wd_server_conf->pool, pproc); apr_pool_userdata_set(wd_server_conf, pk, apr_pool_cleanup_null, pproc); } wd_server_conf->s = s; if ((wl = ap_list_provider_names(pconf, AP_WATCHDOG_PGROUP, AP_WATCHDOG_PVERSION))) { const ap_list_provider_names_t *wn; int i; ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02974) "Watchdog: found parent providers."); wn = (ap_list_provider_names_t *)wl->elts; for (i = 0; i < wl->nelts; i++) { ap_watchdog_t *w = ap_lookup_provider(AP_WATCHDOG_PGROUP, wn[i].provider_name, AP_WATCHDOG_PVERSION); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02975) "Watchdog: Looking for parent (%s).", wn[i].provider_name); if (w) { if (!w->active) { int status = ap_run_watchdog_need(s, w->name, 1, w->singleton); if (status == OK) { /* One of the modules returned OK to this watchog. * Mark it as active */ w->active = 1; } } if (w->active) { /* We have active watchdog. * Create the watchdog thread */ if ((rv = wd_startup(w, wd_server_conf->pool)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(01571) "Watchdog: Failed to create parent worker thread."); return rv; } ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO(02976) "Watchdog: Created parent worker thread (%s).", w->name); wd_server_conf->parent_workers++; } } } } if (wd_server_conf->parent_workers) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01572) "Spawned %d parent worker threads.", wd_server_conf->parent_workers); } if ((wl = ap_list_provider_names(pconf, AP_WATCHDOG_PGROUP, AP_WATCHDOG_CVERSION))) { const ap_list_provider_names_t *wn; int i; ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02977) "Watchdog: found child providers."); wn = (ap_list_provider_names_t *)wl->elts; for (i = 0; i < wl->nelts; i++) { ap_watchdog_t *w = ap_lookup_provider(AP_WATCHDOG_PGROUP, wn[i].provider_name, AP_WATCHDOG_CVERSION); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(02978) "Watchdog: Looking for child (%s).", wn[i].provider_name); if (w) { if (!w->active) { int status = ap_run_watchdog_need(s, w->name, 0, w->singleton); if (status == OK) { /* One of the modules returned OK to this watchog. * Mark it as active */ w->active = 1; } } if (w->active) { /* We have some callbacks registered. * Create mutexes for singleton watchdogs */ if (w->singleton) { rv = ap_proc_mutex_create(&w->mutex, NULL, wd_proc_mutex_type, w->name, s, wd_server_conf->pool, 0); if (rv != APR_SUCCESS) { return rv; } } ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s, APLOGNO(02979) "Watchdog: Created child worker thread (%s).", w->name); wd_server_conf->child_workers++; } } } } return OK; }
static dav_prop_insert dav_core_insert_prop(const dav_resource *resource, int propid, dav_prop_insert what, apr_text_header *phdr) { const char *value = NULL; const char *s; apr_pool_t *p = resource->pool; const dav_liveprop_spec *info; long global_ns; switch (propid) { case DAV_PROPID_resourcetype: { /* additional type info provided by external modules ? */ int i; apr_array_header_t *extensions = ap_list_provider_names(p, DAV_RESOURCE_TYPE_GROUP, "0"); ap_list_provider_names_t *entry = (ap_list_provider_names_t *)extensions->elts; for (i = 0; i < extensions->nelts; i++, entry++) { const dav_resource_type_provider *res_hooks = dav_get_resource_type_providers(entry->provider_name); const char *name = NULL, *uri = NULL; if (!res_hooks || !res_hooks->get_resource_type) continue; if (!res_hooks->get_resource_type(resource, &name, &uri) && name) { if (!uri || !strcasecmp(uri, "DAV:")) value = apr_pstrcat(p, value ? value : "", "<D:", name, "/>", NULL); else value = apr_pstrcat(p, value ? value : "", "<x:", name, " xmlns:x=\"", uri, "\"/>", NULL); } } } switch (resource->type) { case DAV_RESOURCE_TYPE_VERSION: if (resource->baselined) { value = apr_pstrcat(p, value ? value : "", "<D:baseline/>", NULL); break; } /* fall through */ case DAV_RESOURCE_TYPE_REGULAR: case DAV_RESOURCE_TYPE_WORKING: if (resource->collection) { value = apr_pstrcat(p, value ? value : "", "<D:collection/>", NULL); } else { /* ### should we denote lock-null resources? */ if (value == NULL) { value = ""; /* becomes: <D:resourcetype/> */ } } break; case DAV_RESOURCE_TYPE_HISTORY: value = apr_pstrcat(p, value ? value : "", "<D:version-history/>", NULL); break; case DAV_RESOURCE_TYPE_WORKSPACE: value = apr_pstrcat(p, value ? value : "", "<D:collection/>", NULL); break; case DAV_RESOURCE_TYPE_ACTIVITY: value = apr_pstrcat(p, value ? value : "", "<D:activity/>", NULL); break; default: /* ### bad juju */ return DAV_PROP_INSERT_NOTDEF; } break; case DAV_PROPID_comment: case DAV_PROPID_creator_displayname: case DAV_PROPID_displayname: case DAV_PROPID_source: default: /* ** This property is known, but not defined as a liveprop. However, ** it may be a dead property. */ return DAV_PROP_INSERT_NOTDEF; } /* assert: value != NULL */ /* get the information and global NS index for the property */ global_ns = dav_get_liveprop_info(propid, &dav_core_liveprop_group, &info); /* assert: info != NULL && info->name != NULL */ if (what == DAV_PROP_INSERT_SUPPORTED) { s = apr_psprintf(p, "<D:supported-live-property D:name=\"%s\" " "D:namespace=\"%s\"/>" DEBUG_CR, info->name, dav_core_namespace_uris[info->ns]); } else if (what == DAV_PROP_INSERT_VALUE && *value != '\0') { s = apr_psprintf(p, "<lp%ld:%s>%s</lp%ld:%s>" DEBUG_CR, global_ns, info->name, value, global_ns, info->name); } else { s = apr_psprintf(p, "<lp%ld:%s/>" DEBUG_CR, global_ns, info->name); } apr_text_append(p, phdr, s); /* we inserted what was asked for */ return what; }