Skip to content

Commit

Permalink
Fix avcDaemon suspend/resume data corruption
Browse files Browse the repository at this point in the history
 - Fix corruption of packageDownloader workspace when a current FOTA
   job is aborted and a new job is queued.
 - Fix SOTA state machine corruption.
 - Remove stale SOTA/FOTA suspend/resume data in case of job abortion.
 - Fix package downloader global variable corruption when back to back
   SOTA/FOTA job is scheduled
 - Some minor code refactoring

Resolves: LE-13049
Change-Id: Ia9a1079621fdbe4a129d42efe839ecd4035775ae
  • Loading branch information
NshafiSWI committed Jul 31, 2019
1 parent d9bd901 commit 8f92edb
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions avcAppUpdate/avcAppUpdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,7 @@ static void UpdateProgressHandler
// Delete the SOTA resume info.
packageDownloader_DeleteResumeInfo();
#endif /* end LE_CONFIG_SOTA */
lwm2mcore_DeletePackageDownloaderResumeInfo();
// Check and resume install if necessary.
le_event_Report(InstallResumeEventId, NULL, 0);
break;
Expand Down Expand Up @@ -2774,6 +2775,7 @@ le_result_t avcApp_DeleteObj9Instance
#ifndef LE_CONFIG_CUSTOM_OS
packageDownloader_DeleteResumeInfo();
#endif
lwm2mcore_DeletePackageDownloaderResumeInfo();
DeletePackage();
avcServer_ResetQueryHandlers();
assetData_DeleteInstance(instanceRef);
Expand Down
34 changes: 34 additions & 0 deletions avcClient/osPortUpdate.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,40 @@ lwm2mcore_Sid_t lwm2mcore_LaunchUpdate
}


//--------------------------------------------------------------------------------------------------
/**
* Clean the stale workspace of aborted SOTA/FOTA job
*/
//--------------------------------------------------------------------------------------------------
void lwm2mcore_CleanStaleData
(
lwm2mcore_UpdateType_t type ///< [IN] Update type
)
{
// Delete all unfinished/aborted SOTA/FOTA job info
switch (type)
{
case LWM2MCORE_FW_UPDATE_TYPE:
// Delete old FOTA job info.
packageDownloader_DeleteFwUpdateInfo();
// Delete aborted/stale stored SOTA job info. Otherwise, they may create problem during
// FOTA suspend resume activity.
avcApp_DeletePackage();
break;

case LWM2MCORE_SW_UPDATE_TYPE:
// Delete stale FOTA job info only. No need to delete stale SOTA job info. Because for
// SOTA, delete command is explicitly sent from server.
packageDownloader_DeleteFwUpdateInfo();
break;

default:
LE_ERROR("Unknown download type");
break;
}

}

//--------------------------------------------------------------------------------------------------
/**
* The server requires the package name
Expand Down
32 changes: 32 additions & 0 deletions packageDownloader/packageDownloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,38 @@ void packageDownloader_FinalizeDownload
}
}
}
else if (LWM2MCORE_SW_UPDATE_TYPE == pkgDwlPtr->data.updateType)
{
if (downloader_CheckDownloadToSuspend())
{
le_avc_ErrorCode_t errorCode = LE_AVC_ERR_NONE;

if (LE_OK != downloadStatus)
{
switch (downloadStatus)
{
case LE_COMM_ERROR:
case LE_TERMINATED:
case LE_FAULT:
case LE_TIMEOUT:
errorCode = LE_AVC_ERR_NETWORK;
break;

case LE_NO_MEMORY:
errorCode = LE_AVC_ERR_RAM;
break;

default:
break;
}
}
ErrorCode = errorCode;
le_event_QueueFunctionToThread(dwlCtxPtr->mainRef,
ResumeDownloadRequest,
NULL,
NULL);
}
}

end:
SetDownloadStatus(DOWNLOAD_STATUS_IDLE);
Expand Down

0 comments on commit 8f92edb

Please sign in to comment.