OSDN Git Service

Ensure the profile descriptor gets closed after posting the result
authorCalin Juravle <calin@google.com>
Fri, 2 Mar 2018 03:42:45 +0000 (19:42 -0800)
committerCalin Juravle <calin@google.com>
Fri, 2 Mar 2018 07:59:44 +0000 (07:59 +0000)
We need to close the descriptor after posting the result on the
handler, otherwise we might risk sending in a close descriptor.

Bug: 73505439
Test: gts ArtManagerHostTest
Change-Id: I469683e323940ac88ea9e8c16e3df7a526ca77b3

services/core/java/com/android/server/pm/dex/ArtManagerService.java

index 2ece2b2..062a6b8 100644 (file)
@@ -203,8 +203,6 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
             Slog.w(TAG, "Could not open snapshot profile for " + packageName + ":"
                     + snapshotProfile, e);
             postError(callback, packageName, ArtManager.SNAPSHOT_FAILED_INTERNAL_ERROR);
-        } finally {
-            IoUtils.closeQuietly(fd);
         }
     }
 
@@ -283,6 +281,8 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
             } catch (RemoteException e) {
                 Slog.w(TAG,
                         "Failed to call onSuccess after profile snapshot for " + packageName, e);
+            } finally {
+                IoUtils.closeQuietly(fd);
             }
         });
     }