Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset the write event before each call to WriteFile() #174

Merged
merged 1 commit into from Feb 1, 2018

Conversation

millert
Copy link
Contributor

@millert millert commented Feb 1, 2018

In device_issue_read() there is no need to reset Offset and OffsetHigh to 0; they are only used for seekable files (not sockets).

Reset the write event before the call to WriteFile(). This is consistent with how the read event is reset before ReadFile().

Clear device_write_packet.len() if WriteFile() fails with an error other than ERROR_IO_PENDING; otherwise write_packet() will call GetOverlappedResult() the next time it is run even though there is no write in progress.

to 0; they are only used for seekable files (not sockets).

Reset the write event before the call to WriteFile().  This is
consistent with how the read event is reset before ReadFile().

Clear device_write_packet.len() if WriteFile() fails with an error
other than ERROR_IO_PENDING; otherwise write_packet() will call
GetOverlappedResult() the next time it is run even though there is
no write in progress.
@gsliepen gsliepen merged commit 8145a33 into gsliepen:1.1 Feb 1, 2018
@dechamps
Copy link
Contributor

dechamps commented Feb 1, 2018

Thank you for fixing my code :)

I wonder if the potential bug you found on the write path for errors other than ERROR_IO_PENDING could explain why I've witnessed tinc sometimes getting stuck when the computer is waking up from sleep. It's difficult to confirm though, because reproducing the issue has proven difficult thus far.

@millert millert deleted the 1.1-wevent branch February 1, 2018 23:14
@dechamps
Copy link
Contributor

dechamps commented Feb 3, 2018

I did some more investigation, and I can indeed confirm that this specific commit fixes an issue where, if the computer is put to sleep while there there is traffic on the tinc interface, tinc will get stuck on wakeup with the following errors in the log:

Error while checking previous write to Windows tap device: (996) Overlapped I/O event is not in a signaled state.

I can reliably reproduce the issue by stressing the interface using iperf while putting the computer to sleep at the same time. I was unable to reproduce it again with your fix in place.

@gsliepen: you might want to mention that bugfix when writing the release notes for the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants