release_sock函数
来源:互联网 发布:淘宝网我的实名认证 编辑:程序博客网 时间:2024/05/14 19:04
void release_sock(struct sock *sk) 释放backlog { unsigned long flags; #ifdef CONFIG_INET struct sk_buff *skb; #endif if (!sk->prot) return; /* * Make the backlog atomic. If we don't do this there is a tiny * window where a packet may arrive between the sk->blog being * tested and then set with sk->inuse still 0 causing an extra * unwanted re-entry into release_sock(). */ save_flags(flags); cli(); if (sk->blog) { restore_flags(flags); return; } sk->blog=1; sk->inuse = 1; restore_flags(flags); #ifdef CONFIG_INET /* See if we have any packets built up. */ while((skb = skb_dequeue(&sk->back_log)) != NULL) { sk->blog = 1; if (sk->prot->rcv) sk->prot->rcv(skb, skb->dev, sk->opt, skb->saddr, skb->len, skb->daddr, 1, /* Only used for/by raw sockets. */ (struct inet_protocol *)sk->pair); } #endif sk->blog = 0;blog为1时表示正在处理backlog队列。4 sk->inuse = 0; #ifdef CONFIG_INET if (sk->dead && sk->state == TCP_CLOSE) { /* Should be about 2 rtt's */ reset_timer(sk, TIME_DONE, min(sk->rtt * 2, TCP_DONE_TIME)); } #endif }