static char * ngx_dso_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *rv; ngx_conf_t pcf; ngx_dso_conf_ctx_t *ctx; ctx = (ngx_dso_conf_ctx_t *) ngx_get_conf(cf->cycle->conf_ctx, ngx_dso_module); if (ctx->modules != NULL) { return "is duplicate"; } ctx->modules = ngx_array_create(cf->pool, 50, sizeof(ngx_dso_module_t)); if (ctx->modules == NULL) { return NGX_CONF_ERROR; } ctx->stubs = ngx_array_create(cf->pool, 50, sizeof(ngx_str_t)); if (ctx->stubs == NULL) { return NGX_CONF_ERROR; } ctx->flag_postion = ngx_dso_get_position(&module_flagpole[0].entry); if (ctx->flag_postion == NGX_ERROR) { return NGX_CONF_ERROR; } *(ngx_dso_conf_ctx_t **) conf = ctx; ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "dso flag postion (%i)", ctx->flag_postion); pcf = *cf; cf->ctx = ctx; cf->module_type = NGX_CORE_MODULE; cf->handler = ngx_dso_parse; cf->handler_conf = conf; rv = ngx_conf_parse(cf, NULL); if (rv != NGX_CONF_OK) { goto failed; } rv = ngx_dso_load(cf); if (rv == NGX_CONF_ERROR) { goto failed; } *cf = pcf; return NGX_CONF_OK; failed: *cf = pcf; return rv; }
static char * ngx_dso_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *rv; ngx_conf_t pcf; ngx_dso_conf_ctx_t *ctx; ngx_pool_cleanup_t *cln; ctx = ((void **) cf->ctx)[ngx_dso_module.index]; if (ctx != NULL) { return "is duplicate"; } ctx = ngx_pcalloc(cf->pool, sizeof(ngx_dso_conf_ctx_t)); if (ctx == NULL) { return NGX_CONF_ERROR; } *(ngx_dso_conf_ctx_t **) conf = ctx; ctx->modules = ngx_array_create(cf->pool, 50, sizeof(ngx_dso_module_t)); if (ctx->modules == NULL) { return NGX_CONF_ERROR; } ctx->flag_postion = ngx_dso_get_position(&module_flagpole[0].entry); if (ctx->flag_postion == NGX_ERROR) { return NGX_CONF_ERROR; } ctx->stubs = ngx_array_create(cf->pool, 50, sizeof(ngx_str_t)); if (ctx->stubs == NULL) { return NGX_CONF_ERROR; } if (ngx_is_init_cycle(cf->cycle->old_cycle)) { ngx_memcpy(ngx_static_modules, ngx_modules, sizeof(ngx_module_t *) * ngx_max_module); } else { ngx_memcpy(ngx_old_modules, ngx_modules, sizeof(ngx_module_t *) * NGX_DSO_MAX); ngx_memcpy(ngx_modules, ngx_static_modules, sizeof(ngx_module_t *) * NGX_DSO_MAX); } pcf = *cf; cf->ctx = ctx; cf->module_type = NGX_CORE_MODULE; cf->handler = ngx_dso_parse; cf->handler_conf = conf; cln = ngx_pool_cleanup_add(cf->pool, 0); if (cln == NULL) { rv = NGX_CONF_ERROR; goto failed; } cln->handler = ngx_dso_cleanup; cln->data = cf->cycle; rv = ngx_conf_parse(cf, NULL); if (rv != NGX_CONF_OK) { goto failed; } rv = ngx_dso_load(cf); if (rv == NGX_CONF_ERROR) { goto failed; } *cf = pcf; return NGX_CONF_OK; failed: *cf = pcf; return rv; }