--- connection.c.orig Thu Apr 13 05:06:26 2000 +++ connection.c Thu Apr 13 05:15:54 2000 @@ -310,6 +310,7 @@ static void processResponse436 (Connection cxn, char *response) ; static void processResponse437 (Connection cxn, char *response) ; static void processResponse480 (Connection cxn, char *response) ; +static void processResponse500 (Connection cxn, char *response) ; /* Misc functions */ @@ -1792,7 +1793,10 @@ case 480: /* Transfer permission denied. */ processResponse480 (cxn,response) ; break ; - + + case 500: /* command not recognized */ + processResponse500 (cxn, response) ; + break; default: syslog (LOG_ERR, UNKNOWN_RESPONSE, peerName, cxn->ident, @@ -3107,6 +3111,88 @@ } +static void processResponse500 (Connection cxn, char *response) +{ + ArtHolder artHolder ; + + if (!cxn->doesStreaming) + { + /* we got a 500 answer in response to IHAVE */ + if (!(cxn->state == cxnFlushingS || + cxn->state == cxnFeedingS || + cxn->state == cxnClosingS)) + { + syslog (LOG_ERR,CXN_BAD_STATE,hostPeerName (cxn->myHost), + cxn->ident,stateToString (cxn->state)) ; + cxnSleepOrDie (cxn) ; + return ; + } + + ASSERT (cxn->articleQTotal == 1) ; + ASSERT (cxn->checkRespHead != NULL) ; + VALIDATE_CONNECTION (cxn) ; + + cxn->articleQTotal-- ; + cxn->checksRefused++ ; + + artHolder = cxn->checkRespHead ; + cxn->checkRespHead = NULL ; + + if (cxn->articleQTotal == 0) + cxnIdle (cxn) ; + + hostArticleNotWanted (cxn->myHost, cxn, artHolder->article) ; + delArtHolder (artHolder) ; + return; + } + + /* We are streaming, so the 500 is either a reply to + CHECK or TAKETHIS */ + if (!(cxn->state == cxnFlushingS || + cxn->state == cxnFeedingS || + cxn->state == cxnClosingS)) + { + syslog (LOG_ERR,CXN_BAD_STATE,hostPeerName (cxn->myHost), + cxn->ident,stateToString (cxn->state)) ; + cxnSleepOrDie (cxn) ; + return ; + } + + VALIDATE_CONNECTION (cxn) ; + + /* CHECK */ + if (cxn->checkRespHead != NULL) + { + cxn->checksRefused++ ; + artHolder = cxn->checkRespHead ; + remArtHolder (artHolder, &cxn->checkRespHead, &cxn->articleQTotal) ; + if (cxn->articleQTotal == 0) + cxnIdle (cxn) ; + hostArticleNotWanted (cxn->myHost, cxn, artHolder->article); + delArtHolder (artHolder) ; + } + /* TAKETHIS */ + else if (cxn->takeRespHead != NULL) + { + cxn->takesRejected++ ; + artHolder = cxn->takeRespHead ; + remArtHolder (artHolder, &cxn->takeRespHead, &cxn->articleQTotal) ; + /* Some(?) hosts return the 500 response even before we're done + sending */ + if (cxn->articleQTotal == 0 && !writeIsPending(cxn->myEp)) + cxnIdle (cxn) ; + hostArticleRejected (cxn->myHost, cxn, artHolder->article) ; + delArtHolder (artHolder) ; + } + else + { + syslog (LOG_NOTICE,BAD_RESPONSE, + hostPeerName (cxn->myHost),cxn->ident,438) ; + cxnSleepOrDie (cxn) ; + return ; + } + +}