removed double synchronization from kelondroRecords.USAGE to prevent thread locking.

The method synchronization should be sufficient

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3574 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 6186185775
commit b6a5f53020

@ -215,26 +215,26 @@ public class kelondroRecords {
} }
private synchronized void writefree() throws IOException { private synchronized void writefree() throws IOException {
synchronized (entryFile) { //synchronized (entryFile) {
entryFile.writeInt(POS_FREEC, FREEC); entryFile.writeInt(POS_FREEC, FREEC);
entryFile.writeInt(POS_FREEH, FREEH.index); entryFile.writeInt(POS_FREEH, FREEH.index);
entryFile.commit(); entryFile.commit();
checkConsistency(); checkConsistency();
} //}
} }
private synchronized void readused() throws IOException { private synchronized void readused() throws IOException {
synchronized (entryFile) { //synchronized (entryFile) {
this.USEDC = entryFile.readInt(POS_USEDC); this.USEDC = entryFile.readInt(POS_USEDC);
assert this.USEDC >= 0 : "this.USEDC = " + this.USEDC + ", filename = " + filename; assert this.USEDC >= 0 : "this.USEDC = " + this.USEDC + ", filename = " + filename;
} //}
} }
private synchronized void readfree() throws IOException { private synchronized void readfree() throws IOException {
synchronized (entryFile) { //synchronized (entryFile) {
this.FREEC = entryFile.readInt(POS_FREEC); this.FREEC = entryFile.readInt(POS_FREEC);
this.FREEH = new Handle(entryFile.readInt(POS_FREEH)); this.FREEH = new Handle(entryFile.readInt(POS_FREEH));
} //}
} }
private synchronized int allCount() { private synchronized int allCount() {
@ -253,8 +253,8 @@ public class kelondroRecords {
// re-used change counter // re-used change counter
assert (h.index >= 0); assert (h.index >= 0);
assert (h.index != NUL); assert (h.index != NUL);
synchronized (USAGE) { //synchronized (USAGE) {
synchronized (entryFile) { //synchronized (entryFile) {
assert (h.index < USEDC + FREEC) : "USEDC = " + USEDC + ", FREEC = " + FREEC + ", h.index = " + h.index; assert (h.index < USEDC + FREEC) : "USEDC = " + USEDC + ", FREEC = " + FREEC + ", h.index = " + h.index;
long sp = seekpos(h); long sp = seekpos(h);
assert (sp <= entryFile.length() + ROW.objectsize) : h.index + "/" + sp + " exceeds file size " + entryFile.length(); assert (sp <= entryFile.length() + ROW.objectsize) : h.index + "/" + sp + " exceeds file size " + entryFile.length();
@ -266,8 +266,8 @@ public class kelondroRecords {
FREEH = h; FREEH = h;
writefree(); writefree();
writeused(false); writeused(false);
} //}
} //}
} }
private synchronized int allocatePayload(byte[] chunk) throws IOException { private synchronized int allocatePayload(byte[] chunk) throws IOException {
@ -278,8 +278,8 @@ public class kelondroRecords {
chunk = spaceChunk; chunk = spaceChunk;
} }
assert (chunk.length == ROW.objectsize()) : "chunk.length = " + chunk.length + ", ROW.objectsize() = " + ROW.objectsize(); assert (chunk.length == ROW.objectsize()) : "chunk.length = " + chunk.length + ", ROW.objectsize() = " + ROW.objectsize();
synchronized (USAGE) { //synchronized (USAGE) {
synchronized (entryFile) { //synchronized (entryFile) {
if (USAGE.FREEC == 0) { if (USAGE.FREEC == 0) {
// generate new entry // generate new entry
int index = USAGE.allCount(); int index = USAGE.allCount();
@ -321,8 +321,8 @@ public class kelondroRecords {
entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize()); // overwrite space entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize()); // overwrite space
return index; return index;
} }
} //}
} //}
} }
private synchronized void allocateRecord(int index, byte[] bulkchunk, int offset) throws IOException { private synchronized void allocateRecord(int index, byte[] bulkchunk, int offset) throws IOException {
@ -334,8 +334,8 @@ public class kelondroRecords {
offset = 0; offset = 0;
} }
//assert (chunk.length == ROW.objectsize()) : "chunk.length = " + chunk.length + ", ROW.objectsize() = " + ROW.objectsize(); //assert (chunk.length == ROW.objectsize()) : "chunk.length = " + chunk.length + ", ROW.objectsize() = " + ROW.objectsize();
synchronized (USAGE) { //synchronized (USAGE) {
synchronized (entryFile) { //synchronized (entryFile) {
if (index < USAGE.allCount()) { if (index < USAGE.allCount()) {
// write within the file // write within the file
// this can be critical, if we simply overwrite fields that are marked // this can be critical, if we simply overwrite fields that are marked
@ -368,8 +368,8 @@ public class kelondroRecords {
entryFile.commit(); entryFile.commit();
} }
} }
} //}
} //}
} }
private synchronized void checkConsistency() { private synchronized void checkConsistency() {

Loading…
Cancel
Save