diff --git a/accept.go b/accept.go index a5ca5ed..0f199d1 100644 --- a/accept.go +++ b/accept.go @@ -46,7 +46,7 @@ func (s SrtSocket) Accept() (*SrtSocket, *net.UDPAddr, error) { } } var addr syscall.RawSockaddrAny - sclen := C.int(syscall.SizeofSockaddrAny) + sclen := C.int(sizeofSockaddrAny) socket, err := srtAcceptImpl(s.socket, (*C.struct_sockaddr)(unsafe.Pointer(&addr)), &sclen) if err != nil { return nil, nil, err diff --git a/poll.go b/poll.go index 336f686..a0b5901 100644 --- a/poll.go +++ b/poll.go @@ -239,12 +239,12 @@ func (pd *pollDesc) unblock(mode PollMode, pollerr, ioready bool) { state = &pd.wrState unblockChan = pd.unblockWr } - pd.lock.Lock() - old := atomic.LoadInt32(state) + var old int32 if ioready { - atomic.StoreInt32(state, pollReady) + old = atomic.SwapInt32(state, pollReady) + } else { + old = atomic.LoadInt32(state) } - pd.lock.Unlock() if old == pollWait { //make sure we never block here select {