src/ngx_url_async_fetcher.cc
// It's called in the rewrite thread. All the fetches are started at
// this function. It will notify the main thread to start the fetch job.
It's called in the rewrite thread. All the fetches are started at
this function. It will notify the main thread to start the fetch job.
It ' s called in the rewrite thread . All the fetches are started at this function . It will notify the main thread to start the fetch job .
void NgxUrlAsyncFetcher::Fetch(const GoogleString& url,
                                 MessageHandler* message_handler,
                                 AsyncFetch* async_fetch) {
    if (shutdown_) {
      async_fetch->Done(false);
      return;
    }
    async_fetch = EnableInflation(async_fetch);
    NgxFetch* fetch = new NgxFetch(url, async_fetch,
          message_handler, log_);
    ScopedMutex lock(mutex_);
    pending_fetches_.Add(fetch);
    bool written = event_connection_->WriteEvent(this);
    CHECK(written || shutdown_) << "NgxUrlAsyncFetcher: event write failure";
  }
void NgxUrlAsyncFetcher :: Fetch ( const GoogleString & url , MessageHandler * message_handler , AsyncFetch * async_fetch ) { if ( shutdown_ ) { async_fetch -> Done ( false ) ; return ; } async_fetch = EnableInflation ( async_fetch ) ; NgxFetch * fetch = new NgxFetch ( url , async_fetch , message_handler , log_ ) ; ScopedMutex lock ( mutex_ ) ; pending_fetches_ . Add ( fetch ) ; bool written = event_connection_ -> WriteEvent ( this ) ; CHECK ( written || shutdown_ ) << " " ; }
It's called in the rewrite thread.
It ' s called in the rewrite thread .
// Don't accept new fetches when shut down. This flow is also entered when // we did not initialize properly in ::Init(). // TODO(oschaaf): thread safety on written vs shutdown. // It is possible that shutdown() is called after writing an event? In that // case, this could (rarely) fail when it shouldn't.