prevent multiple calls to disconnect for serial and tcp (#137)
* prevent multiple calls to disconnect for serial and tcp
This commit is contained in:

committed by
Stefan Wahren

parent
de4a899b9d
commit
027f6fb689
@ -191,7 +191,13 @@ mbus_serial_disconnect(mbus_handle *handle)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (handle->fd < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(handle->fd);
|
||||
handle->fd = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -374,4 +380,3 @@ mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame)
|
||||
|
||||
return MBUS_RECV_RESULT_OK;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,13 @@ mbus_tcp_disconnect(mbus_handle *handle)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (handle->fd < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(handle->fd);
|
||||
handle->fd = -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -262,4 +268,3 @@ mbus_tcp_set_timeout_set(double seconds)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user