mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
tun: don't look at current when non-blocking
We play with a wait queue even if socket is non blocking. This is an obvious waste. Besides, it will prevent calling the non blocking variant when current is not valid. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
66e358a847
commit
5c0c52c910
1 changed files with 5 additions and 3 deletions
|
@ -1293,7 +1293,8 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
|
||||||
if (unlikely(!noblock))
|
if (unlikely(!noblock))
|
||||||
add_wait_queue(&tfile->wq.wait, &wait);
|
add_wait_queue(&tfile->wq.wait, &wait);
|
||||||
while (len) {
|
while (len) {
|
||||||
current->state = TASK_INTERRUPTIBLE;
|
if (unlikely(!noblock))
|
||||||
|
current->state = TASK_INTERRUPTIBLE;
|
||||||
|
|
||||||
/* Read frames from the queue */
|
/* Read frames from the queue */
|
||||||
if (!(skb = skb_dequeue(&tfile->socket.sk->sk_receive_queue))) {
|
if (!(skb = skb_dequeue(&tfile->socket.sk->sk_receive_queue))) {
|
||||||
|
@ -1320,9 +1321,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
current->state = TASK_RUNNING;
|
if (unlikely(!noblock)) {
|
||||||
if (unlikely(!noblock))
|
current->state = TASK_RUNNING;
|
||||||
remove_wait_queue(&tfile->wq.wait, &wait);
|
remove_wait_queue(&tfile->wq.wait, &wait);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue