src/ngx_pagespeed.cc
// Called when nginx forks worker processes.  No threads should be started
// before this.
Called when nginx forks worker processes.  No threads should be started
before this.
Called when nginx forks worker processes . No threads should be started before this .
ngx_int_t ps_init_child_process(ngx_cycle_t* cycle) {
  ps_main_conf_t* cfg_m = static_cast<ps_main_conf_t*>(
      ngx_http_cycle_get_module_main_conf(cycle, ngx_pagespeed));
  if (cfg_m == NULL || cfg_m->driver_factory == NULL) {
    return NGX_OK;
  }
  if (!NgxBaseFetch::Initialize(cycle)) {
    return NGX_ERROR;
  }
  cfg_m->driver_factory->LoggingInit(cycle->log, true);
  cfg_m->driver_factory->ChildInit();
  ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>(
      ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module));
  ngx_http_core_srv_conf_t** cscfp = static_cast<ngx_http_core_srv_conf_t**>(
      cmcf->servers.elts);
  ngx_uint_t s;
  for (s = 0; s < cmcf->servers.nelts; s++) {
    ps_srv_conf_t* cfg_s = static_cast<ps_srv_conf_t*>(
        cscfp[s]->ctx->srv_conf[ngx_pagespeed.ctx_index]);
    if (cfg_s->server_context != NULL) {
      cfg_s->proxy_fetch_factory = new ProxyFetchFactory(cfg_s->server_context);
      ngx_http_core_loc_conf_t* clcf = static_cast<ngx_http_core_loc_conf_t*>(
          cscfp[s]->ctx->loc_conf[ngx_http_core_module.ctx_index]);
      cfg_m->driver_factory->SetServerContextMessageHandler(
          cfg_s->server_context, clcf->error_log);
    }
  }
  cfg_m->driver_factory->StartThreads();
  return NGX_OK;
}
ngx_int_t ps_init_child_process ( ngx_cycle_t * cycle ) { ps_main_conf_t * cfg_m = static_cast < ps_main_conf_t * > ( ngx_http_cycle_get_module_main_conf ( cycle , ngx_pagespeed ) ) ; if ( cfg_m == NULL || cfg_m -> driver_factory == NULL ) { return NGX_OK ; } if ( ! NgxBaseFetch :: Initialize ( cycle ) ) { return NGX_ERROR ; } cfg_m -> driver_factory -> LoggingInit ( cycle -> log , true ) ; cfg_m -> driver_factory -> ChildInit ( ) ; ngx_http_core_main_conf_t * cmcf = static_cast < ngx_http_core_main_conf_t * > ( ngx_http_cycle_get_module_main_conf ( cycle , ngx_http_core_module ) ) ; ngx_http_core_srv_conf_t * * cscfp = static_cast < ngx_http_core_srv_conf_t * * > ( cmcf -> servers . elts ) ; ngx_uint_t s ; for ( s = 0 ; s < cmcf -> servers . nelts ; s ++ ) { ps_srv_conf_t * cfg_s = static_cast < ps_srv_conf_t * > ( cscfp [ s ] -> ctx -> srv_conf [ ngx_pagespeed . ctx_index ] ) ; if ( cfg_s -> server_context != NULL ) { cfg_s -> proxy_fetch_factory = new ProxyFetchFactory ( cfg_s -> server_context ) ; ngx_http_core_loc_conf_t * clcf = static_cast < ngx_http_core_loc_conf_t * > ( cscfp [ s ] -> ctx -> loc_conf [ ngx_http_core_module . ctx_index ] ) ; cfg_m -> driver_factory -> SetServerContextMessageHandler ( cfg_s -> server_context , clcf -> error_log ) ; } } cfg_m -> driver_factory -> StartThreads ( ) ; return NGX_OK ; }
Called when nginx forks worker processes.
Called when nginx forks worker processes .
// ChildInit() will initialise all ServerContexts, which we need to // create ProxyFetchFactories below // Iterate over all configured server{} blocks, and find our context in it, // so we can create and set a ProxyFetchFactory for it. // Some server{} blocks may not have a ServerContext in that case we must // not instantiate a ProxyFetchFactory.