misc bugfixes (concurrency, memory protection)

pull/1/head
Michael Peter Christen 11 years ago
parent 9b1958e8ca
commit ee27be3399

@ -26,6 +26,7 @@
package net.yacy.cora.protocol;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@ -294,12 +295,12 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> {
private static void cleanup(final Iterator<ConnectionInfo> iter) {
synchronized (iter) {
while (iter.hasNext()) {
while (iter.hasNext()) try {
ConnectionInfo con = iter.next();
if(con.getLifetime() > staleAfterMillis) {
getAllConnections().remove(con);
}
}
} catch (ConcurrentModificationException e) {}
}
}

@ -35,6 +35,8 @@ import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
import net.yacy.kelondro.util.MemoryControl;
/**
* wrapper class for audio tools
@ -130,10 +132,12 @@ public class Audio {
Clip clip;
if ((clip = getClip()) == null) return;
if (clip.isActive()) {
if (!MemoryControl.shortStatus()) try {
Clip onetimeclip = getFreshClip();
FloatControl gainControl = (FloatControl) onetimeclip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(gain);
onetimeclip.start();
} catch (OutOfMemoryError e) {}
} else {
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(gain);

@ -825,7 +825,7 @@ public class Table implements Index, Iterable<Row.Entry> {
@Override
public synchronized Entry removeOne() throws IOException {
assert this.file.size() == this.index.size() : "file.size() = " + this.file.size() + ", index.size() = " + this.index.size();
//assert this.file.size() == this.index.size() : "file.size() = " + this.file.size() + ", index.size() = " + this.index.size();
assert this.table == null || this.table.size() == this.index.size() : "table.size() = " + this.table.size() + ", index.size() = " + this.index.size();
final byte[] le = new byte[this.rowdef.objectsize];
final long fsb = this.file.size();
@ -845,7 +845,7 @@ public class Table implements Index, Iterable<Row.Entry> {
this.table.removeOne();
assert this.table.size() < tsb : "table.size() = " + this.table.size() + ", tsb = " + tsb;
}
assert this.file.size() == this.index.size() : "file.size() = " + this.file.size() + ", index.size() = " + this.index.size();
//assert this.file.size() == this.index.size() : "file.size() = " + this.file.size() + ", index.size() = " + this.index.size();
assert this.table == null || this.table.size() == this.index.size() : "table.size() = " + this.table.size() + ", index.size() = " + this.index.size();
return lr;
}

Loading…
Cancel
Save