Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c0c52c9 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin Committed by David S. Miller
Browse files

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: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 66e358a8
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1293,6 +1293,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
	if (unlikely(!noblock))
		add_wait_queue(&tfile->wq.wait, &wait);
	while (len) {
		if (unlikely(!noblock))
			current->state = TASK_INTERRUPTIBLE;

		/* Read frames from the queue */
@@ -1320,9 +1321,10 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
		break;
	}

	if (unlikely(!noblock)) {
		current->state = TASK_RUNNING;
	if (unlikely(!noblock))
		remove_wait_queue(&tfile->wq.wait, &wait);
	}

	return ret;
}