Ticket #26: innfeed-500-handler.patch

File innfeed-500-handler.patch, 3.2 KB (added by eagle, 14 years ago)

Patch from 2000

  • connection.c

    old new  
    310310static void processResponse436 (Connection cxn, char *response) ;
    311311static void processResponse437 (Connection cxn, char *response) ;
    312312static void processResponse480 (Connection cxn, char *response) ;
     313static void processResponse500 (Connection cxn, char *response) ;
    313314
    314315
    315316/* Misc functions */
     
    17921793          case 480:             /* Transfer permission denied. */
    17931794            processResponse480  (cxn,response) ;
    17941795            break ;
    1795            
     1796
     1797          case 500:             /* command not recognized */
     1798            processResponse500 (cxn, response) ;
     1799            break;
    17961800
    17971801          default:
    17981802            syslog (LOG_ERR, UNKNOWN_RESPONSE, peerName, cxn->ident,
     
    31073111}
    31083112
    31093113
     3114static void processResponse500 (Connection cxn, char *response)
     3115{
     3116  ArtHolder artHolder ;
     3117
     3118  if (!cxn->doesStreaming)
     3119    {
     3120        /* we got a 500 answer in response to IHAVE */
     3121        if (!(cxn->state == cxnFlushingS ||
     3122              cxn->state == cxnFeedingS ||
     3123              cxn->state == cxnClosingS))
     3124          {
     3125            syslog (LOG_ERR,CXN_BAD_STATE,hostPeerName (cxn->myHost),
     3126                    cxn->ident,stateToString (cxn->state)) ;
     3127            cxnSleepOrDie (cxn) ;
     3128            return ;
     3129          }
     3130
     3131        ASSERT (cxn->articleQTotal == 1) ;
     3132        ASSERT (cxn->checkRespHead != NULL) ;
     3133        VALIDATE_CONNECTION (cxn) ;
     3134
     3135        cxn->articleQTotal-- ;
     3136        cxn->checksRefused++ ;
     3137
     3138        artHolder = cxn->checkRespHead ;
     3139        cxn->checkRespHead = NULL ;
     3140
     3141        if (cxn->articleQTotal == 0)
     3142          cxnIdle (cxn) ;
     3143
     3144        hostArticleNotWanted (cxn->myHost, cxn, artHolder->article) ;
     3145        delArtHolder (artHolder) ;
     3146        return;
     3147    }
     3148
     3149  /* We are streaming, so the 500 is either a reply to
     3150     CHECK or TAKETHIS */ 
     3151  if (!(cxn->state == cxnFlushingS ||
     3152        cxn->state == cxnFeedingS ||
     3153        cxn->state == cxnClosingS))
     3154    {
     3155      syslog (LOG_ERR,CXN_BAD_STATE,hostPeerName (cxn->myHost),
     3156              cxn->ident,stateToString (cxn->state)) ;
     3157      cxnSleepOrDie (cxn) ;
     3158      return ;
     3159    }
     3160 
     3161  VALIDATE_CONNECTION (cxn) ;
     3162
     3163  /* CHECK */
     3164  if (cxn->checkRespHead != NULL)
     3165    {
     3166      cxn->checksRefused++ ;
     3167      artHolder = cxn->checkRespHead ;
     3168      remArtHolder (artHolder, &cxn->checkRespHead, &cxn->articleQTotal) ;
     3169      if (cxn->articleQTotal == 0)
     3170        cxnIdle (cxn) ;
     3171      hostArticleNotWanted (cxn->myHost, cxn, artHolder->article);
     3172      delArtHolder (artHolder) ;
     3173    }
     3174  /* TAKETHIS */
     3175  else if (cxn->takeRespHead != NULL)
     3176    {
     3177      cxn->takesRejected++ ;
     3178      artHolder = cxn->takeRespHead ;
     3179      remArtHolder (artHolder, &cxn->takeRespHead, &cxn->articleQTotal) ;
     3180      /* Some(?) hosts return the 500 response even before we're done
     3181          sending */
     3182      if (cxn->articleQTotal == 0 && !writeIsPending(cxn->myEp))
     3183        cxnIdle (cxn) ;
     3184      hostArticleRejected (cxn->myHost, cxn, artHolder->article) ;
     3185      delArtHolder (artHolder) ;
     3186    }
     3187  else
     3188    {
     3189      syslog (LOG_NOTICE,BAD_RESPONSE,
     3190              hostPeerName (cxn->myHost),cxn->ident,438) ;
     3191      cxnSleepOrDie (cxn) ;
     3192      return ;
     3193    }
     3194
     3195}