mirror of
https://github.com/fumiama/water.git
synced 2026-06-05 02:00:29 +08:00
add lock
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user