pnoltes commented on code in PR #751:
URL: https://github.com/apache/celix/pull/751#discussion_r1633567080


##########
libs/framework/src/framework.c:
##########
@@ -2345,61 +2362,73 @@ static bool 
celix_framework_updateBundleInternal(celix_framework_t *fw, long bnd
 }
 
 celix_status_t celix_framework_updateBundleEntry(celix_framework_t* framework,
-                                                 
celix_framework_bundle_entry_t* bndEntry,
+                                                 celix_bundle_entry_t* 
bndEntry,
                                                  const char* updatedBundleUrl) 
{
     celix_status_t status = CELIX_SUCCESS;
     long bundleId = bndEntry->bndId;
-    const char* errMsg;
     fw_log(framework->logger, CELIX_LOG_LEVEL_DEBUG, "Updating bundle %s", 
celix_bundle_getSymbolicName(bndEntry->bnd));
     celix_bundle_state_e bndState = celix_bundle_getState(bndEntry->bnd);
-    char *location = celix_bundle_getLocation(bndEntry->bnd);
-    do {
-        // lock to reuse the bundle id
-        celixThreadMutex_lock(&framework->installLock);
-        if (updatedBundleUrl == NULL) {
-            updatedBundleUrl = location;
-        } else if (strcmp(location, updatedBundleUrl) != 0) {
-            long alreadyExistingBndId = 
celix_bundleCache_findBundleIdForLocation(framework->cache, updatedBundleUrl);
-            if (alreadyExistingBndId != -1 && alreadyExistingBndId != 
bundleId) {
-                errMsg = "specified bundle location exists in cache with a 
different id";
-                celix_framework_bundleEntry_decreaseUseCount(bndEntry);
-                celixThreadMutex_unlock(&framework->installLock);
-                status = CELIX_ILLEGAL_STATE;
-                break;
-            }
-            
celix_bundleArchive_invalidateCache(celix_bundle_getArchive(bndEntry->bnd));
-        }
-        status = celix_framework_uninstallBundleEntryImpl(framework, bndEntry, 
false);
+    celix_autofree char* location = celix_bundle_getLocation(bndEntry->bnd);
+
+    // lock to reuse the bundle id
+    celix_auto(celix_mutex_lock_guard_t) lck = 
celixMutexLockGuard_init(&framework->installLock);
+    if (updatedBundleUrl == NULL) {
+        updatedBundleUrl = location;
+    } else if (strcmp(location, updatedBundleUrl) != 0) {
+        long existingBndId;
+        status = celix_bundleCache_findBundleIdForLocation(framework->cache, 
updatedBundleUrl, &existingBndId);
         if (status != CELIX_SUCCESS) {

Review Comment:
   This also has been addressed in 
https://github.com/apache/celix/pull/751/commits/17a5adac5014cb774860a99ccd01e2b4e85fbb7b



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to