mirror of https://github.com/dswd/vpncloud.git
Fixed problem with interrupted poll after suspend to ram
This commit is contained in:
parent
023ef0e1d7
commit
b8fcd382d8
|
@ -9,7 +9,8 @@ This project follows [semantic versioning](http://semver.org).
|
||||||
- [changed] Configurable magic header is now used instead of Network-ID (**incompatible**)
|
- [changed] Configurable magic header is now used instead of Network-ID (**incompatible**)
|
||||||
- [changed] Clarified documentation on TUN netmasks
|
- [changed] Clarified documentation on TUN netmasks
|
||||||
- [fixed] Fixed documentation of listen parameter
|
- [fixed] Fixed documentation of listen parameter
|
||||||
- [fixed] Fixed problem with multiple subnets
|
- [fixed] Fixed problem with multiple
|
||||||
|
- [fixed] Fixed problem with interrupted poll after suspend to ram
|
||||||
|
|
||||||
### v0.7.0 (2016-08-05)
|
### v0.7.0 (2016-08-05)
|
||||||
|
|
||||||
|
|
19
src/cloud.rs
19
src/cloud.rs
|
@ -237,7 +237,7 @@ impl<P: Protocol> GenericCloud<P> {
|
||||||
Ok(written) if written == msg_data.len() => Ok(()),
|
Ok(written) if written == msg_data.len() => Ok(()),
|
||||||
Ok(_) => Err(Error::Socket("Sent out truncated packet", io::Error::new(io::ErrorKind::Other, "truncated"))),
|
Ok(_) => Err(Error::Socket("Sent out truncated packet", io::Error::new(io::ErrorKind::Other, "truncated"))),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to send via network {:?}", e);
|
error!("Failed to send via network {}", e);
|
||||||
Err(Error::Socket("IOError when sending", e))
|
Err(Error::Socket("IOError when sending", e))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -263,7 +263,7 @@ impl<P: Protocol> GenericCloud<P> {
|
||||||
Ok(written) if written == msg_data.len() => Ok(()),
|
Ok(written) if written == msg_data.len() => Ok(()),
|
||||||
Ok(_) => Err(Error::Socket("Sent out truncated packet", io::Error::new(io::ErrorKind::Other, "truncated"))),
|
Ok(_) => Err(Error::Socket("Sent out truncated packet", io::Error::new(io::ErrorKind::Other, "truncated"))),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to send via network {:?}", e);
|
error!("Failed to send via network {}", e);
|
||||||
Err(Error::Socket("IOError when sending", e))
|
Err(Error::Socket("IOError when sending", e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,8 +564,20 @@ impl<P: Protocol> GenericCloud<P> {
|
||||||
try_fail!(poll_handle.register(socket6_fd, poll::READ), "Failed to add ipv4 socket to poll handle: {}");
|
try_fail!(poll_handle.register(socket6_fd, poll::READ), "Failed to add ipv4 socket to poll handle: {}");
|
||||||
try_fail!(poll_handle.register(device_fd, poll::READ), "Failed to add ipv4 socket to poll handle: {}");
|
try_fail!(poll_handle.register(device_fd, poll::READ), "Failed to add ipv4 socket to poll handle: {}");
|
||||||
let mut buffer = [0; 64*1024];
|
let mut buffer = [0; 64*1024];
|
||||||
|
let mut poll_error = false;
|
||||||
loop {
|
loop {
|
||||||
for evt in try_fail!(poll_handle.wait(1000), "Poll wait failed: {}") {
|
let evts = match poll_handle.wait(1000) {
|
||||||
|
Ok(evts) => evts,
|
||||||
|
Err(err) => {
|
||||||
|
if poll_error {
|
||||||
|
fail!("Poll wait failed again: {}", err);
|
||||||
|
}
|
||||||
|
error!("Poll wait failed: {}, retrying...", err);
|
||||||
|
poll_error = true;
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for evt in evts {
|
||||||
match evt.fd() {
|
match evt.fd() {
|
||||||
fd if (fd == socket4_fd || fd == socket6_fd) => {
|
fd if (fd == socket4_fd || fd == socket6_fd) => {
|
||||||
let (size, src) = match evt.fd() {
|
let (size, src) = match evt.fd() {
|
||||||
|
@ -589,6 +601,7 @@ impl<P: Protocol> GenericCloud<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.next_housekeep < now() {
|
if self.next_housekeep < now() {
|
||||||
|
poll_error = false;
|
||||||
// Check for signals
|
// Check for signals
|
||||||
if trap.wait(dummy_time).is_some() {
|
if trap.wait(dummy_time).is_some() {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue