Fixed problem with growing stats file

This commit is contained in:
Dennis Schwerdel 2019-12-29 13:03:48 +01:00
parent eb620781a8
commit 44ad73701b
2 changed files with 3 additions and 1 deletions

View File

@ -7,6 +7,7 @@ This project follows [semantic versioning](http://semver.org).
- [added] Added feature to disable special NAT support - [added] Added feature to disable special NAT support
- [changed] Improved port forwarding on quirky routers - [changed] Improved port forwarding on quirky routers
- [changed] Reduced peer timeout to 5min to work better with NAT - [changed] Reduced peer timeout to 5min to work better with NAT
- [fixed] Fixed problem with growing stats file
### v1.2.1 (2019-12-22) ### v1.2.1 (2019-12-22)

View File

@ -8,7 +8,7 @@ use std::{
fmt, fmt,
fs::{self, File}, fs::{self, File},
hash::BuildHasherDefault, hash::BuildHasherDefault,
io::{self, Write}, io::{self, Seek, SeekFrom, Write},
marker::PhantomData, marker::PhantomData,
net::{SocketAddr, ToSocketAddrs}, net::{SocketAddr, ToSocketAddrs},
path::Path path::Path
@ -585,6 +585,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
fn write_out_stats(&mut self) -> Result<(), io::Error> { fn write_out_stats(&mut self) -> Result<(), io::Error> {
if let Some(ref mut f) = self.stats_file { if let Some(ref mut f) = self.stats_file {
debug!("Writing out stats"); debug!("Writing out stats");
f.seek(SeekFrom::Start(0))?;
f.set_len(0)?; f.set_len(0)?;
self.peers.write_out(f)?; self.peers.write_out(f)?;
writeln!(f)?; writeln!(f)?;