Skip to content

Commit 7e61daf

Browse files
Roman Shakhmanaevfacebook-github-bot
authored andcommitted
Revert D60186847: Run prepare() for BackupSoSource to cleanup previous state
Differential Revision: D60186847 Original commit changeset: e029b9c31ac9 Original Phabricator Diff: D60186847 fbshipit-source-id: dd35f2c01d1716ff2a35dd81ef5d5e07e7a2d720
1 parent a5ebc83 commit 7e61daf

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

java/com/facebook/soloader/BackupSoSource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ public int loadLibrary(String soName, int loadFlags, StrictMode.ThreadPolicy thr
100100

101101
@Override
102102
public void prepare(int flags) throws IOException {
103-
if ((flags & SoSource.PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE) != 0) {
104-
super.prepare(flags | SoSource.PREPARE_FLAG_NO_UNPACKING);
103+
if ((flags & SoSource.PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE) != 0) {
105104
return;
106105
}
107106
super.prepare(flags);

java/com/facebook/soloader/SoLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ private static int makePrepareFlags() {
534534
prepareFlags |= SoSource.PREPARE_FLAG_DISABLE_FS_SYNC_JOB;
535535
}
536536
if ((sFlags & SOLOADER_EXPLICITLY_ENABLE_BACKUP_SOSOURCE) == 0) {
537-
prepareFlags |= SoSource.PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE;
537+
prepareFlags |= SoSource.PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE;
538538
}
539539
return prepareFlags;
540540
} finally {

java/com/facebook/soloader/SoSource.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public abstract class SoSource {
5959
public static final int PREPARE_FLAG_DISABLE_FS_SYNC_JOB = (1 << 2);
6060

6161
/** Skip preparing backup so source. */
62-
public static final int PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE = (1 << 3);
63-
64-
public static final int PREPARE_FLAG_NO_UNPACKING = (1 << 4);
62+
public static final int PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE = (1 << 3);
6563

6664
/** Prepare to install this SoSource in SoLoader. */
6765
protected void prepare(int flags) throws IOException {

java/com/facebook/soloader/UnpackingSoSource.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -338,23 +338,18 @@ private boolean refreshLocked(final FileLocker lock, final int flags) throws IOE
338338
LogUtil.v(TAG, "so store dirty: regenerating");
339339
writeState(stateFileName, STATE_DIRTY, runFsync);
340340
deleteSoFiles();
341+
try (Unpacker u = makeUnpacker()) {
342+
u.unpack(soDirectory);
343+
}
341344

342-
final boolean noUnpacking = (flags & PREPARE_FLAG_NO_UNPACKING) != 0;
343-
if (!noUnpacking) {
344-
try (Unpacker u = makeUnpacker()) {
345-
u.unpack(soDirectory);
346-
}
347-
348-
// N.B. We can afford to write the deps file without fsyncs because we've marked the DSO
349-
// store STATE_DIRTY, which will cause us to ignore all intermediate state when regenerating
350-
// it.
351-
// That is, it's okay for the depsFile blocks to hit the disk before the actual DSO data file
352-
// blocks as long as both hit the disk before we reset STATE_CLEAN.
353-
final File depsFileName = new File(soDirectory, DEPS_FILE_NAME);
354-
try (RandomAccessFile depsFile = new RandomAccessFile(depsFileName, "rw")) {
355-
depsFile.write(recomputedDeps);
356-
depsFile.setLength(depsFile.getFilePointer());
357-
}
345+
// N.B. We can afford to write the deps file without fsyncs because we've marked the DSO
346+
// store STATE_DIRTY, which will cause us to ignore all intermediate state when regenerating it.
347+
// That is, it's okay for the depsFile blocks to hit the disk before the actual DSO data file
348+
// blocks as long as both hit the disk before we reset STATE_CLEAN.
349+
final File depsFileName = new File(soDirectory, DEPS_FILE_NAME);
350+
try (RandomAccessFile depsFile = new RandomAccessFile(depsFileName, "rw")) {
351+
depsFile.write(recomputedDeps);
352+
depsFile.setLength(depsFile.getFilePointer());
358353
}
359354

360355
// Task to dump the buffer cache to disk to guard against battery outages. The default is to run

0 commit comments

Comments
 (0)