Skip to content
Snippets Groups Projects
Unverified Commit 060ba4a7 authored by Richard Cordovano's avatar Richard Cordovano Committed by GitHub
Browse files

Merge pull request #2129 from APriestman/7189_removeSyncFromContent

7189 Removing some synchronization to prevent deadlocks.
parents 47e91a65 0d9b62ff
No related branches found
No related tags found
No related merge requests found
...@@ -39,8 +39,8 @@ public abstract class AbstractContent implements Content { ...@@ -39,8 +39,8 @@ public abstract class AbstractContent implements Content {
private final SleuthkitCase db; private final SleuthkitCase db;
private final long objId; private final long objId;
private final String name; private final String name;
private Content parent; private volatile Content parent;
private String uniquePath; private volatile String uniquePath;
protected long parentId; protected long parentId;
private volatile boolean hasChildren; private volatile boolean hasChildren;
private volatile boolean checkedHasChildren; private volatile boolean checkedHasChildren;
...@@ -69,17 +69,22 @@ public String getName() { ...@@ -69,17 +69,22 @@ public String getName() {
* interleaving forward slashes). * interleaving forward slashes).
*/ */
@Override @Override
public synchronized String getUniquePath() throws TskCoreException { public String getUniquePath() throws TskCoreException {
// It is possible that multiple threads could be doing this calculation
// simultaneously, but it's worth the potential extra processing to prevent deadlocks.
if (uniquePath == null) { if (uniquePath == null) {
uniquePath = ""; String tempUniquePath = "";
if (!name.isEmpty()) { if (!name.isEmpty()) {
uniquePath = "/" + getName(); tempUniquePath = "/" + getName();
} }
Content myParent = getParent(); Content myParent = getParent();
if (myParent != null) { if (myParent != null) {
uniquePath = myParent.getUniquePath() + uniquePath; tempUniquePath = myParent.getUniquePath() + tempUniquePath;
} }
// Don't update uniquePath until it is complete.
uniquePath = tempUniquePath;
} }
return uniquePath; return uniquePath;
} }
...@@ -111,7 +116,9 @@ public int getChildrenCount() throws TskCoreException { ...@@ -111,7 +116,9 @@ public int getChildrenCount() throws TskCoreException {
} }
@Override @Override
public synchronized Content getParent() throws TskCoreException { public Content getParent() throws TskCoreException {
// It is possible that multiple threads could be doing this calculation
// simultaneously, but it's worth the potential extra processing to prevent deadlocks.
if (parent == null) { if (parent == null) {
ObjectInfo parentInfo; ObjectInfo parentInfo;
parentInfo = db.getParentInfo(this); parentInfo = db.getParentInfo(this);
......
...@@ -59,8 +59,8 @@ public class BlackboardArtifact implements Content { ...@@ -59,8 +59,8 @@ public class BlackboardArtifact implements Content {
private final SleuthkitCase sleuthkitCase; private final SleuthkitCase sleuthkitCase;
private final List<BlackboardAttribute> attrsCache = new ArrayList<BlackboardAttribute>(); private final List<BlackboardAttribute> attrsCache = new ArrayList<BlackboardAttribute>();
private boolean loadedCacheFromDb = false; private boolean loadedCacheFromDb = false;
private Content parent; private volatile Content parent;
private String uniquePath; private volatile String uniquePath;
private byte[] contentBytes = null; private byte[] contentBytes = null;
...@@ -391,21 +391,27 @@ public void addAttributes(Collection<BlackboardAttribute> attributes) throws Tsk ...@@ -391,21 +391,27 @@ public void addAttributes(Collection<BlackboardAttribute> attributes) throws Tsk
* @throws org.sleuthkit.datamodel.TskCoreException * @throws org.sleuthkit.datamodel.TskCoreException
*/ */
@Override @Override
public synchronized String getUniquePath() throws TskCoreException { public String getUniquePath() throws TskCoreException {
// Return the path of the parent file
// Return the path of the parrent file // It is possible that multiple threads could be doing this calculation
// simultaneously, but it's worth the potential extra processing to prevent deadlocks.
if (uniquePath == null) { if (uniquePath == null) {
uniquePath = ""; String tempUniquePath = "";
Content myParent = getParent(); Content myParent = getParent();
if (myParent != null) { if (myParent != null) {
uniquePath = myParent.getUniquePath(); tempUniquePath = myParent.getUniquePath();
} }
// Don't update uniquePath until it is complete.
uniquePath = tempUniquePath;
} }
return uniquePath; return uniquePath;
} }
@Override @Override
public synchronized Content getParent() throws TskCoreException { public Content getParent() throws TskCoreException {
// It is possible that multiple threads could be doing this calculation
// simultaneously, but it's worth the potential extra processing to prevent deadlocks.
if (parent == null) { if (parent == null) {
ObjectInfo parentInfo; ObjectInfo parentInfo;
parentInfo = getSleuthkitCase().getParentInfo(this); parentInfo = getSleuthkitCase().getParentInfo(this);
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
public abstract class FsContent extends AbstractFile { public abstract class FsContent extends AbstractFile {
private static final Logger logger = Logger.getLogger(FsContent.class.getName()); private static final Logger logger = Logger.getLogger(FsContent.class.getName());
private String uniquePath; private volatile String uniquePath;
private List<String> metaDataText = null; private List<String> metaDataText = null;
private volatile FileSystem parentFileSystem; private volatile FileSystem parentFileSystem;
...@@ -259,7 +259,9 @@ public Content getDataSource() throws TskCoreException { ...@@ -259,7 +259,9 @@ public Content getDataSource() throws TskCoreException {
* @throws TskCoreException if there is an error querying the case database. * @throws TskCoreException if there is an error querying the case database.
*/ */
@Override @Override
public synchronized String getUniquePath() throws TskCoreException { public String getUniquePath() throws TskCoreException {
// It is possible that multiple threads could be doing this calculation
// simultaneously, but it's worth the potential extra processing to prevent deadlocks.
if (uniquePath == null) { if (uniquePath == null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(getFileSystem().getUniquePath()); sb.append(getFileSystem().getUniquePath());
......
...@@ -34,7 +34,7 @@ public class Volume extends AbstractContent { ...@@ -34,7 +34,7 @@ public class Volume extends AbstractContent {
private long flags; private long flags;
private String desc; private String desc;
private volatile long volumeHandle = 0; private volatile long volumeHandle = 0;
private String uniquePath; private volatile String uniquePath;
private static ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle"); private static ResourceBundle bundle = ResourceBundle.getBundle("org.sleuthkit.datamodel.Bundle");
/** /**
...@@ -107,18 +107,23 @@ public long getSize() { ...@@ -107,18 +107,23 @@ public long getSize() {
} }
@Override @Override
public synchronized String getUniquePath() throws TskCoreException { public String getUniquePath() throws TskCoreException {
// It is possible that multiple threads could be doing this calculation
// simultaneously, but it's worth the potential extra processing to prevent deadlocks.
if(uniquePath == null) { if(uniquePath == null) {
uniquePath = ""; String tempUniquePath = "";
String name = getName(); String name = getName();
if (!name.isEmpty()) { if (!name.isEmpty()) {
uniquePath = "/vol_" + name; //NON-NLS tempUniquePath = "/vol_" + name; //NON-NLS
} }
Content myParent = getParent(); Content myParent = getParent();
if (myParent != null) { if (myParent != null) {
uniquePath = myParent.getUniquePath() + uniquePath; tempUniquePath = myParent.getUniquePath() + tempUniquePath;
} }
// Don't update uniquePath until it is complete.
uniquePath = tempUniquePath;
} }
return uniquePath; return uniquePath;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment