Skip to content

Commit

Permalink
Revert D60544645: Run prepare() for BackupSoSource to cleanup previou…
Browse files Browse the repository at this point in the history
…s state, take 2

Differential Revision:
D60544645

Original commit changeset: d108641155ee

Original Phabricator Diff: D60544645

fbshipit-source-id: 405534db96b0a9494ec6d71d16a31b7dff97fc87
  • Loading branch information
Dani Parés authored and facebook-github-bot committed Aug 4, 2024
1 parent 255513b commit 9496e4c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
3 changes: 1 addition & 2 deletions java/com/facebook/soloader/BackupSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public int loadLibrary(String soName, int loadFlags, StrictMode.ThreadPolicy thr

@Override
public void prepare(int flags) throws IOException {
if ((flags & SoSource.PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE) != 0) {
super.prepare(flags | SoSource.PREPARE_FLAG_NO_UNPACKING);
if ((flags & SoSource.PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE) != 0) {
return;
}
super.prepare(flags);
Expand Down
2 changes: 1 addition & 1 deletion java/com/facebook/soloader/SoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private static int makePrepareFlags() {
prepareFlags |= SoSource.PREPARE_FLAG_DISABLE_FS_SYNC_JOB;
}
if ((sFlags & SOLOADER_EXPLICITLY_ENABLE_BACKUP_SOSOURCE) == 0) {
prepareFlags |= SoSource.PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE;
prepareFlags |= SoSource.PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE;
}
return prepareFlags;
} finally {
Expand Down
4 changes: 1 addition & 3 deletions java/com/facebook/soloader/SoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public abstract class SoSource {
public static final int PREPARE_FLAG_DISABLE_FS_SYNC_JOB = (1 << 2);

/** Skip preparing backup so source. */
public static final int PREPARE_FLAG_NO_UNPACKING_BACKUP_SO_SOURCE = (1 << 3);

public static final int PREPARE_FLAG_NO_UNPACKING = (1 << 4);
public static final int PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE = (1 << 3);

/** Prepare to install this SoSource in SoLoader. */
protected void prepare(int flags) throws IOException {
Expand Down
27 changes: 11 additions & 16 deletions java/com/facebook/soloader/UnpackingSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,18 @@ private boolean refreshLocked(final FileLocker lock, final int flags) throws IOE
LogUtil.v(TAG, "so store dirty: regenerating");
writeState(stateFileName, STATE_DIRTY, runFsync);
deleteSoFiles();
try (Unpacker u = makeUnpacker()) {
u.unpack(soDirectory);
}

final boolean noUnpacking = (flags & PREPARE_FLAG_NO_UNPACKING) != 0;
if (!noUnpacking) {
try (Unpacker u = makeUnpacker()) {
u.unpack(soDirectory);
}

// N.B. We can afford to write the deps file without fsyncs because we've marked the DSO
// store STATE_DIRTY, which will cause us to ignore all intermediate state when regenerating
// it.
// That is, it's okay for the depsFile blocks to hit the disk before the actual DSO data file
// blocks as long as both hit the disk before we reset STATE_CLEAN.
final File depsFileName = new File(soDirectory, DEPS_FILE_NAME);
try (RandomAccessFile depsFile = new RandomAccessFile(depsFileName, "rw")) {
depsFile.write(recomputedDeps);
depsFile.setLength(depsFile.getFilePointer());
}
// N.B. We can afford to write the deps file without fsyncs because we've marked the DSO
// store STATE_DIRTY, which will cause us to ignore all intermediate state when regenerating it.
// That is, it's okay for the depsFile blocks to hit the disk before the actual DSO data file
// blocks as long as both hit the disk before we reset STATE_CLEAN.
final File depsFileName = new File(soDirectory, DEPS_FILE_NAME);
try (RandomAccessFile depsFile = new RandomAccessFile(depsFileName, "rw")) {
depsFile.write(recomputedDeps);
depsFile.setLength(depsFile.getFilePointer());
}

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

0 comments on commit 9496e4c

Please sign in to comment.