mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-26 15:06:04 +03:00
Eliminate extra 'ping' message when server sends data to client which generates a reply
This commit is contained in:
parent
b1bab9c3dc
commit
a07187a629
@ -12,6 +12,8 @@ CHANGES:
|
|||||||
- The server now replies to all received queries.
|
- The server now replies to all received queries.
|
||||||
- Fixed segfault in server when sending version reject.
|
- Fixed segfault in server when sending version reject.
|
||||||
- The interval between "pings" from clients is now 5 seconds.
|
- The interval between "pings" from clients is now 5 seconds.
|
||||||
|
- Eliminited extra "ping" messages from client to server when server
|
||||||
|
sends data and gets data back directly.
|
||||||
|
|
||||||
2008-08-06: 0.4.2 "Opened Zone"
|
2008-08-06: 0.4.2 "Opened Zone"
|
||||||
- Applied a few small patches from Maxim Bourmistrov and Gregor Herrmann
|
- Applied a few small patches from Maxim Bourmistrov and Gregor Herrmann
|
||||||
|
24
src/iodine.c
24
src/iodine.c
@ -233,10 +233,6 @@ tunnel_dns(int tun_fd, int dns_fd)
|
|||||||
|
|
||||||
write_tun(tun_fd, out, outlen);
|
write_tun(tun_fd, out, outlen);
|
||||||
|
|
||||||
/* Server may have more data to send me, ask for it */
|
|
||||||
if (!is_sending())
|
|
||||||
send_ping(dns_fd);
|
|
||||||
|
|
||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,12 +243,20 @@ tunnel(int tun_fd, int dns_fd)
|
|||||||
fd_set fds;
|
fd_set fds;
|
||||||
int rv;
|
int rv;
|
||||||
int i;
|
int i;
|
||||||
|
int short_ping;
|
||||||
|
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
short_ping = 0;
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
tv.tv_sec = 5;
|
if (short_ping) {
|
||||||
tv.tv_usec = 0;
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 5000;
|
||||||
|
short_ping = 0;
|
||||||
|
} else {
|
||||||
|
tv.tv_sec = 5;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
if (!is_sending())
|
if (!is_sending())
|
||||||
@ -267,9 +271,9 @@ tunnel(int tun_fd, int dns_fd)
|
|||||||
if (i < 0)
|
if (i < 0)
|
||||||
err(1, "select");
|
err(1, "select");
|
||||||
|
|
||||||
if (i == 0) /* timeout */
|
if (i == 0) { /* timeout */
|
||||||
send_ping(dns_fd);
|
send_ping(dns_fd);
|
||||||
else {
|
} else {
|
||||||
if (FD_ISSET(tun_fd, &fds)) {
|
if (FD_ISSET(tun_fd, &fds)) {
|
||||||
if (tunnel_tun(tun_fd, dns_fd) <= 0)
|
if (tunnel_tun(tun_fd, dns_fd) <= 0)
|
||||||
continue;
|
continue;
|
||||||
@ -277,6 +281,10 @@ tunnel(int tun_fd, int dns_fd)
|
|||||||
if (FD_ISSET(dns_fd, &fds)) {
|
if (FD_ISSET(dns_fd, &fds)) {
|
||||||
if (tunnel_dns(tun_fd, dns_fd) <= 0)
|
if (tunnel_dns(tun_fd, dns_fd) <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
/* If we have nothing to send within x ms, send a ping
|
||||||
|
* to get more data from server */
|
||||||
|
if (!is_sending())
|
||||||
|
short_ping = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user