u35s / rudp

rudp 是在UDP上实现的可靠传输(rudp is a reliable transmission on UDP)
172 stars 36 forks source link

Race condition with read/write to 'corrupt' field #3

Open l0k18 opened 5 years ago

l0k18 commented 5 years ago

I have forked this repository, as I can see the original author has not made any commits for a year to here: https://git.parallelcoin.io/dev/rudp - just want to remark firstly that it is mostly very nice readable code.

The corrupt field is written to in multiple goroutines so in my fork I have changed the value to use go.uber.org/atomic int32 to store the error value and now the tests run without flagging a race condition. I have also taken the liberty of correcting the naming of method receivers to Go idiom.

This commit: https://git.parallelcoin.io/dev/rudp/commit/efb6fb9d1faeedab0dd550ba9f977100b1b8222d has all of these changes directly from your code and will only differ in the changes I made to redirect the imports of the example code.

Thank you for writing this, I was searching for a Go implementation of RUDP and this saves me writing a simpler, less powerful but (maybe) faster version, and because it can drop in where TCP connections are used, it can be used with HTTP for RPC (or any web service), while allowing potentially easy connectivity to any other language via its RUDP implementation. This is a more mature, simpler protocol than QUIC, with a lot of code existing already that knows how to use it.

u35s commented 5 years ago

你发现的问题已修复,非常感谢。