1
0
mirror of https://github.com/fumiama/water.git synced 2026-06-05 02:00:29 +08:00
This commit is contained in:
fumiama
2021-12-31 17:47:34 +08:00
parent 8a0b0fd8ed
commit 2f9b072abd

View File

@@ -359,6 +359,9 @@ func (w *wintunRWC) Write(b []byte) (int, error) {
} }
func (w *wintunRWC) Read(b []byte) (int, error) { func (w *wintunRWC) Read(b []byte) (int, error) {
w.mu.Lock()
defer w.mu.Unlock()
n := 0 n := 0
if w.readbuf != nil { if w.readbuf != nil {
@@ -380,8 +383,6 @@ RETRY:
} }
start := nanotime() start := nanotime()
shouldSpin := atomic.LoadUint64(&w.rate.current) >= spinloopRateThreshold && uint64(start-atomic.LoadInt64(&w.rate.nextStartTime)) <= rateMeasurementGranularity*2 shouldSpin := atomic.LoadUint64(&w.rate.current) >= spinloopRateThreshold && uint64(start-atomic.LoadInt64(&w.rate.nextStartTime)) <= rateMeasurementGranularity*2
w.mu.Lock()
defer w.mu.Unlock()
for { for {
packet, err := w.s.ReceivePacket() packet, err := w.s.ReceivePacket()
switch err { switch err {