Skip to content

Commit

Permalink
Better handling of timeouts in reception of responses to notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli committed Jun 13, 2024
1 parent 2c3d73c commit e9bd619
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Fixed a possible crash for TRoE and attributes of type Vocab/Json/Language
* Forbidden to DELETE the Core Context !!! (it can be reloaded)
* Bug fix: JSON NULL literal is no longer forwarded!
* Improved treatment of malfunctioning notification receivers, on timeout (for clients that don't respond to the notification)

## New Features:
* Support for attributes of type VocabularyProperty
Expand Down
13 changes: 8 additions & 5 deletions src/lib/orionld/notifications/orionldAlterationsTreat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ bool notificationResponseRead
// Initial read
//
bytesRead = readWithTimeout(npP->fd, buf, bufLen - 1, 0, 100000);

if (bytesRead <= 0)
{
notificationFailure(npP->subP, "Unable to read from notification endpoint", notificationTime);
Expand Down Expand Up @@ -681,12 +682,13 @@ void orionldAlterationsTreat(OrionldAlteration* altList)

npP = npP->next;
}
}

if (time(NULL) > startTime + 4)
{
timeout = true;
break;
}
time_t now = time(NULL);
if (now > startTime + 2)
{
timeout = true;
break;
}
}

Expand All @@ -703,6 +705,7 @@ void orionldAlterationsTreat(OrionldAlteration* altList)
{
notificationFailure(npP->subP, "Timeout awaiting response from notification endpoint", notificationTime);

LM_T(LmtNotificationSend, ("Closing fd %d after timeout", npP->fd));
close(npP->fd);

npP->fd = -1;
Expand Down

0 comments on commit e9bd619

Please sign in to comment.