tcpsetstate()

tcpsetstate()

概要

引数

  • s -- Conv
  • newstate

実装

  386: void
  387: tcpsetstate(Conv *s, uchar newstate)
  388: {
  389:         Tcpctl *tcb;
  390:         uchar oldstate;
  391:         Tcppriv *tpriv;
  392: 
  393:         tpriv = s->p->priv;
  394: 
  395:         tcb = (Tcpctl*)s->ptcl;
  396: 
  397:         oldstate = tcb->state;
  398:         if(oldstate == newstate)
  399:                 return;
  • newstateとoldstateが,同じ状態であれば,何もしない.
  400: 
  401:         if(oldstate == Established)
  402:                 tpriv->stats[CurrEstab]--;
  403:         if(newstate == Established)
  404:                 tpriv->stats[CurrEstab]++;
  • Established状態のコネクション数が変わる場合は,tpriv->stats[]に反映させる.
  405: 
  406:         /**
  407:         print( "%d/%d %s->%s CurrEstab=%d\n", s->lport, s->rport,
  408:                 tcpstates[oldstate], tcpstates[newstate], tpriv->tstats.tcpCurrEstab );
  409:         **/
  410: 
  411:         switch(newstate) {
  412:         case Closed:
  413:                 qclose(s->rq);
  414:                 qclose(s->wq);
  415:                 qclose(s->eq);
  416:                 break;
  • Closed状態になったら,...
  • 詳細はqclose()を参照
  417: 
  418:         case Close_wait:               /* Remote closes */
  419:                 qhangup(s->rq, nil);
  420:                 break;
  • Close_wait状態になったら,...
  • 詳細はqhangup()を参照
  421:         }
  422: 
  423:         tcb->state = newstate;
  424: 
  425:         if(oldstate == Syn_sent && newstate != Closed)
  426:                 Fsconnected(s, nil);
  • 元の状態がSyn_sendで新しい状態がClosedでなければ,コネクションの確立処理を行うために,Fsconnected()を呼ぶ.
  • 詳細はFsconnected()を参照
  427: }