@@ -1421,6 +1421,18 @@ WEAVE_ERROR NotificationEngine::BuildSingleNotifyRequestDataList(SubscriptionHan
14211421
14221422 // Ensure we're in the DataList element. May allocate memory.
14231423 err = aNotifyRequest.MoveToState (kNotifyRequestBuilder_BuildDataList );
1424+
1425+ #if WEAVE_CONFIG_ENABLE_OFFLOAD_EVENTS_FIRST
1426+ // if we did not have enough space for data list at all,
1427+ // squash the error and exit immediately. This check is necessary here
1428+ // when we are loading from the datalist after having loaded the event
1429+ // list into the buffer already.
1430+ if ((err == WEAVE_ERROR_NO_MEMORY) || (err == WEAVE_ERROR_BUFFER_TOO_SMALL))
1431+ {
1432+ err = WEAVE_NO_ERROR;
1433+ ExitNow ();
1434+ }
1435+ #endif // WEAVE_CONFIG_ENABLE_OFFLOAD_EVENTS_FIRST
14241436 SuccessOrExit (err);
14251437
14261438 // Make a back-up of the writer so that we can rewind back if the next retrieval fails due to the packet getting full.
@@ -1550,6 +1562,20 @@ WEAVE_ERROR NotificationEngine::BuildSingleNotifyRequest(SubscriptionHandler * a
15501562 // Fill in the DataList. Allocation may take place
15511563 subClean = true ;
15521564
1565+ #if WEAVE_CONFIG_ENABLE_OFFLOAD_EVENTS_FIRST
1566+
1567+ #if WEAVE_CONFIG_EVENT_LOGGING_WDM_OFFLOAD
1568+ // Fill in the EventList. Allocation may take place
1569+ err = BuildSingleNotifyRequestEventList (aSubHandler, notifyRequest, subClean, neWriteInProgress);
1570+ SuccessOrExit (err);
1571+ #endif
1572+
1573+ aIsSubscriptionClean &= subClean;
1574+ subClean = true ;
1575+
1576+ err = BuildSingleNotifyRequestDataList (aSubHandler, notifyRequest, subClean, neWriteInProgress);
1577+ SuccessOrExit (err);
1578+ #else
15531579 err = BuildSingleNotifyRequestDataList (aSubHandler, notifyRequest, subClean, neWriteInProgress);
15541580 SuccessOrExit (err);
15551581
@@ -1561,6 +1587,7 @@ WEAVE_ERROR NotificationEngine::BuildSingleNotifyRequest(SubscriptionHandler * a
15611587 err = BuildSingleNotifyRequestEventList (aSubHandler, notifyRequest, subClean, neWriteInProgress);
15621588 SuccessOrExit (err);
15631589#endif
1590+ #endif // WEAVE_CONFIG_ENABLE_OFFLOAD_EVENTS_FIRST
15641591
15651592 aIsSubscriptionClean &= subClean;
15661593
0 commit comments