Skip to content

Commit

Permalink
[Linux] Mark GLib source as removed when exiting callback
Browse files Browse the repository at this point in the history
Fixes #22840
  • Loading branch information
arkq committed Sep 23, 2022
1 parent efb8f2f commit 753630a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
15 changes: 12 additions & 3 deletions src/platform/Linux/bluez/Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ static gboolean BluezCharacteristicWriteFD(GIOChannel * aChannel, GIOCondition a
bool isSuccess = false;

BluezConnection * conn = static_cast<BluezConnection *>(apEndpoint);

VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "No CHIP Bluez connection in %s", __func__));
VerifyOrReturnError(conn != nullptr, (ChipLogError(DeviceLayer, "No CHIP Bluez connection in %s", __func__), FALSE));

VerifyOrExit(!(aCond & G_IO_HUP), ChipLogError(DeviceLayer, "INFO: socket disconnected in %s", __func__));
VerifyOrExit(!(aCond & (G_IO_ERR | G_IO_NVAL)), ChipLogError(DeviceLayer, "INFO: socket error in %s", __func__));
Expand All @@ -401,7 +400,17 @@ static gboolean BluezCharacteristicWriteFD(GIOChannel * aChannel, GIOCondition a
isSuccess = true;

exit:
return isSuccess ? TRUE : FALSE;
if (!isSuccess)
{
// Returning FALSE from the source callback removes the source object
// from the context. In order not to trigger GLib critical warning when
// manually removing the source in BluezOTConnectionDestroy() mark it
// as no longer active.
conn->mC1Channel.mWatch = 0;
return FALSE;
}

return TRUE;
}

static void Bluez_gatt_characteristic1_complete_acquire_write_with_fd(GDBusMethodInvocation * invocation, int fd, guint16 mtu)
Expand Down
2 changes: 1 addition & 1 deletion third_party/infineon/cyw30739_sdk/repos/30739A0
2 changes: 1 addition & 1 deletion third_party/infineon/psoc6/psoc6_sdk/libs/btstack
Submodule btstack updated 115 files
2 changes: 1 addition & 1 deletion third_party/infineon/psoc6/psoc6_sdk/libs/wifi-host-driver
Submodule wifi-host-driver updated 122 files
2 changes: 1 addition & 1 deletion third_party/mbedtls/repo
Submodule repo updated from 7c7a3e to 8bb9e4
2 changes: 1 addition & 1 deletion third_party/zap/repo
Submodule repo updated 125 files

0 comments on commit 753630a

Please sign in to comment.