Logo Search packages:      
Sourcecode: pan version File versions

void TaskArticle::on_nntp_done ( NNTP nntp,
Health  health,
const StringView response 
) [private, virtual]

Called at the end of an NNTP command. If the command was one that produced a list, on_nntp_line() may have been called before this.

When this is called, the listener can safely clean up anything associated with processing the command.

Parameters:
health if OK, the command was successful. if RETRY, the command couldn't be processed now but might be successful later -- perhaps there was a bad connection. if FAIL, there's no point in retrying -- perhaps the article has expired.

Reimplemented from pan::NNTP::Listener.

Definition at line 237 of file task-article.cc.

References pan::NNTP::_server, pan::ArticleCache::add(), pan::FAIL, pan::Article::message_id, pan::OK, pan::RETRY, and pan::Task::State::set_health().

{
  // find the Needed using this nntp...
  needed_t::iterator it;
  for (it=_needed.begin(); it!=_needed.end(); ++it)
    if (it->nntp == nntp)
      break;
  g_assert (it != _needed.end());

  //std::cerr << LINE_ID << ' ' << it->part.message_id << " from " << nntp->_server << ": " << (health==OK ? "yes" : "no") << std::endl;

  if (health == OK) { // if download succeeded, save it in the cache
    const StringView view (&it->buf.front(), it->buf.size());
    _cache.add (it->part.get_message_id(_article.message_id), view);
    ++_stats[nntp->_server];
  }

  if (health == FAIL) // if server doesn't have that article...
    it->xref.remove_server (nntp->_server);

  // if we got it or still have other options, we're okay
  _state.set_health (health==FAIL && it->xref.empty() ? FAIL : OK);

  if (health==OK)
    _needed.erase (it);
  else {
    Needed::buf_t tmp;
    it->buf.swap (tmp); // deallocates the space...
    it->nntp = 0;
  }

  update_work ();
  check_in (nntp, health!=RETRY);
}


Generated by  Doxygen 1.6.0   Back to index