network: Handle B_SELECT_DISCONNECTED in socket notifications.
TCPEndpoint::_NotifyReader() calls notify(READ, _AvailableData()), which after a close will be negative, so this will set DISCONNECTED in that case. Drop the unnecessary duplication from TCPEndpoint::_HandleReset: the net_socket layer sends READ|WRITE notifications in this case. Fixes #19969. Change-Id: I0e10c0280f3c84276b486b0375000153a117246d Reviewed-on: https://review.haiku-os.org/c/haiku/+/10581 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
3e5cbad497
commit
99a4c6e757
@@ -1311,10 +1311,8 @@ TCPEndpoint::_Close()
|
|||||||
void
|
void
|
||||||
TCPEndpoint::_HandleReset(status_t error)
|
TCPEndpoint::_HandleReset(status_t error)
|
||||||
{
|
{
|
||||||
socket->error = error;
|
|
||||||
_Close();
|
_Close();
|
||||||
|
|
||||||
gSocketModule->notify(socket, B_SELECT_WRITE, error);
|
|
||||||
gSocketModule->notify(socket, B_SELECT_ERROR, error);
|
gSocketModule->notify(socket, B_SELECT_ERROR, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -849,6 +849,13 @@ socket_request_notification(net_socket* _socket, uint8 event, selectsync* sync)
|
|||||||
if (socket->error != B_OK)
|
if (socket->error != B_OK)
|
||||||
notify_select_event(sync, event);
|
notify_select_event(sync, event);
|
||||||
break;
|
break;
|
||||||
|
case B_SELECT_DISCONNECTED:
|
||||||
|
{
|
||||||
|
ssize_t available = socket_read_avail(socket);
|
||||||
|
if (available < 0)
|
||||||
|
notify_select_event(sync, event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -875,14 +882,14 @@ socket_notify(net_socket* _socket, uint8 event, int32 value)
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
case B_SELECT_READ:
|
case B_SELECT_READ:
|
||||||
if ((ssize_t)socket->receive.low_water_mark > value
|
if ((ssize_t)socket->receive.low_water_mark > value
|
||||||
&& value >= B_OK && !atomic) {
|
&& value >= B_OK && !atomic) {
|
||||||
notify = false;
|
notify = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_SELECT_WRITE:
|
case B_SELECT_WRITE:
|
||||||
if ((ssize_t)socket->send.low_water_mark > value
|
if ((ssize_t)socket->send.low_water_mark > value
|
||||||
&& value >= B_OK && !atomic) {
|
&& value >= B_OK && !atomic) {
|
||||||
notify = false;
|
notify = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -897,6 +904,8 @@ socket_notify(net_socket* _socket, uint8 event, int32 value)
|
|||||||
if (notify && socket->select_pool != NULL) {
|
if (notify && socket->select_pool != NULL) {
|
||||||
notify_select_event_pool(socket->select_pool, event);
|
notify_select_event_pool(socket->select_pool, event);
|
||||||
|
|
||||||
|
if (event == B_SELECT_READ && value < 0)
|
||||||
|
notify_select_event_pool(socket->select_pool, B_SELECT_DISCONNECTED);
|
||||||
if (event == B_SELECT_ERROR) {
|
if (event == B_SELECT_ERROR) {
|
||||||
// always notify read/write on error
|
// always notify read/write on error
|
||||||
notify_select_event_pool(socket->select_pool, B_SELECT_READ);
|
notify_select_event_pool(socket->select_pool, B_SELECT_READ);
|
||||||
@@ -1731,4 +1740,3 @@ net_socket_module_info gNetSocketModule = {
|
|||||||
socket_shutdown,
|
socket_shutdown,
|
||||||
socket_socketpair
|
socket_socketpair
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user