stun

simple point to point tunnel
git clone git://git.2f30.org/stun
Log | Files | Refs | README

commit eec0592f5817ff4c6017e75e119f22f3fd6fc030
parent 5a5d8ecd6a4a52eabdc28616e455350e0a15da73
Author: sin <sin@2f30.org>
Date:   Mon, 21 Mar 2016 11:38:35 +0000

make poll processing order more intuitive

Diffstat:
Mstun.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/stun.c b/stun.c @@ -310,14 +310,14 @@ loop(int netfd, int tunfd) if (pfd[0].revents & (POLLERR | POLLNVAL) || pfd[1].revents & (POLLERR | POLLNVAL)) errx(1, "bad fd"); - if (pfd[1].revents & (POLLIN | POLLHUP)) - if ((n = readtun(tunfd, buf, MTU)) <= 0 || - (n = writenet(netfd, buf, n)) <= 0) - return 1; if (pfd[0].revents & (POLLIN | POLLHUP)) if ((n = readnet(netfd, buf, MTU)) <= 0 || (n = writetun(tunfd, buf, n)) <= 0) return 1; + if (pfd[1].revents & (POLLIN | POLLHUP)) + if ((n = readtun(tunfd, buf, MTU)) <= 0 || + (n = writenet(netfd, buf, n)) <= 0) + return 1; } return 0; }