void rstwdlist () { register struct tcb *tcbp; int cnt = 0; while (cnt < 20) { if (thewdlist[cnt]) { tcbp = thewdlist[cnt]; if (tcpval (tcbp) && watched (tcbp)) { log (/* gettcbsocket (tcbp) */ -1, "tcp reset %s:%d", inet_ntoa (tcbp->conn.remote.address), tcbp->conn.remote.port); reset_tcp (tcbp); } // thewdlist[cnt] = 0L; /* make available for someone else */ thewdlist[cnt] = (struct tcb*)0; } cnt++; } }
int so_tcp_shut(struct usock *up,int how) { switch(how){ case 0: /* No more receives -- replace upcall */ up->cb.tcb->r_upcall = trdiscard; break; case 1: /* Send EOF */ close_tcp(up->cb.tcb); break; case 2: /* Blow away TCB */ reset_tcp(up->cb.tcb); up->cb.tcb = NULL; break; } return 0; }
// 处理tcp断开,重启两个线程 void handler(int signo) { if(SIGPIPE == signo) { reset_tcp(); } }