Added test for port double close

This commit is contained in:
Cristian Maglie
2020-04-19 00:47:22 +02:00
parent f0282e0b50
commit 66bfcede42
2 changed files with 17 additions and 1 deletions

View File

@@ -30,8 +30,9 @@ type unixPort struct {
func (port *unixPort) Close() error {
if !atomic.CompareAndSwapUint32(&port.opened, 1, 0) {
return &PortError{code: PortClosed}
return nil
}
// Close port
port.releaseExclusiveAccess()
if err := unix.Close(port.handle); err != nil {