Add missing locks 33/9533/1
authorelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 8 Nov 2022 13:57:58 +0000 (14:57 +0100)
committerelinuxhenrik <henrik.b.andersson@est.tech>
Tue, 8 Nov 2022 13:58:03 +0000 (14:58 +0100)
Issue-ID: NONRTRIC-814
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: I8e637dd5356923ddc6dfe7a4c0401c46da5e2a6e

capifcore/internal/providermanagement/providermanagement.go
capifcore/internal/publishservice/publishservice.go

index 82d833f..b957961 100644 (file)
@@ -121,6 +121,9 @@ func (pm *ProviderManager) PutRegistrationsRegistrationId(ctx echo.Context, regi
                return sendCoreError(ctx, http.StatusBadRequest, "Invalid format for provider")
        }
 
+       pm.lock.Lock()
+       defer pm.lock.Unlock()
+
        for _, function := range *updatedProvider.ApiProvFuncs {
                if function.ApiProvFuncId == nil {
                        function.ApiProvFuncId = pm.getFuncId(function.ApiProvFuncRole, function.ApiProvFuncInfo)
index eda6af2..43cdb8d 100644 (file)
@@ -182,6 +182,8 @@ func (ps *PublishService) DeleteApfIdServiceApisServiceApiId(ctx echo.Context, a
                        ps.helmManager.UninstallHelmChart(info[1], info[3])
                        log.Info("Deleted service: ", serviceApiId)
                }
+               ps.lock.Lock()
+               defer ps.lock.Unlock()
                delete(ps.publishedServices, string(serviceApiId))
        }
        return ctx.NoContent(http.StatusNoContent)