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

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

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

Loading…
Cancel
Save