Skip to content

Commit

Permalink
misc bugfixes (concurrency, memory protection)
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Oct 8, 2014
1 parent 9b1958e commit ee27be3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions source/net/yacy/cora/protocol/ConnectionInfo.java
Expand Up @@ -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;
Expand Down Expand Up @@ -294,12 +295,12 @@ public static void cleanUp() {

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) {}
}
}

Expand Down
12 changes: 8 additions & 4 deletions source/net/yacy/gui/Audio.java
Expand Up @@ -35,6 +35,8 @@
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;

import net.yacy.kelondro.util.MemoryControl;


/**
* wrapper class for audio tools
Expand Down Expand Up @@ -130,10 +132,12 @@ public void play(float gain) {
Clip clip;
if ((clip = getClip()) == null) return;
if (clip.isActive()) {
Clip onetimeclip = getFreshClip();
FloatControl gainControl = (FloatControl) onetimeclip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(gain);
onetimeclip.start();
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);
Expand Down
4 changes: 2 additions & 2 deletions source/net/yacy/kelondro/table/Table.java
Expand Up @@ -825,7 +825,7 @@ public synchronized Entry remove(final byte[] key) throws IOException {

@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();
Expand All @@ -845,7 +845,7 @@ public synchronized Entry removeOne() throws IOException {
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;
}
Expand Down

0 comments on commit ee27be3

Please sign in to comment.