tried to find the socket bug

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@300 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent 10781f36b7
commit 3be98f194d

@ -102,6 +102,16 @@ public final class httpc {
//Mo 06 Sep 2004 23:32
private static final HashMap reverseMappingCache = new HashMap();
// the dns cache
private static final HashMap nameCacheHit = new HashMap();
//private static HashSet nameCacheMiss = new HashSet();
/**
* A Object Pool containing all pooled httpc-objects.
* @see httpcPool
*/
private static final httpcPool theHttpcPool;
// class variables
private Socket socket = null; // client socket for commands
private String host = null;
@ -109,31 +119,19 @@ public final class httpc {
private long handle;
// output and input streams for client control connection
PushbackInputStream clientInput = null;
OutputStream clientOutput = null;
private PushbackInputStream clientInput = null;
private OutputStream clientOutput = null;
private boolean remoteProxyUse = false;
private String savedRemoteHost = null;
private String requestPath = null;
// the dns cache
private static final HashMap nameCacheHit = new HashMap();
//private static HashSet nameCacheMiss = new HashSet();
static {
// set time-out of InetAddress.getByName cache ttl
java.security.Security.setProperty("networkaddress.cache.ttl" , "60");
java.security.Security.setProperty("networkaddress.cache.negative.ttl" , "0");
}
/**
* A Object Pool containing all pooled httpc-objects.
* @see httpcPool
*/
private static final httpcPool theHttpcPool;
/**
* Indicates if the current object was removed from pool because the maximum limit
* was exceeded.
@ -225,14 +223,6 @@ public final class httpc {
}
}
protected void finalize() throws Throwable {
if (!this.removedFromPool) {
System.err.println("Httpc object was not returned to object pool.");
httpc.theHttpcPool.invalidateObject(this);
}
this.reset();
}
public static String dnsResolve(String host) {
// looks for the ip of host <host> and returns ip number as string
String ip = (String) nameCacheHit.get(host);
@ -270,37 +260,27 @@ public final class httpc {
}
}
void reset() {
try {
if (this.clientInput != null) {
this.clientInput.close();
this.clientInput = null;
}
if (this.clientOutput != null) {
this.clientOutput.close();
this.clientOutput = null;
}
if (this.socket != null) {
this.socket.close();
this.socket = null;
// provide HTTP date handling static methods
public static String dateString(Date date) {
if (date == null) return ""; else return HTTPGMTFormatter.format(date);
}
this.host = null;
this.timeout = 0;
this.handle = 0;
this.remoteProxyUse = false;
this.savedRemoteHost = null;
this.requestPath = null;
// shrink readlinebuffer if it is to large
this.readLineBuffer.reset(80);
} catch (Exception e) {
// we could ignore this ...
}
public static Date nowDate() {
return new GregorianCalendar(GMTTimeZone).getTime();
}
static {
// provide system information for client identification
String loc = System.getProperty("user.timezone", "nowhere");
int p = loc.indexOf("/");
if (p > 0) loc = loc.substring(0,p);
loc = loc + "/" + System.getProperty("user.language", "dumb");
systemOST =
System.getProperty("os.arch", "no-os-arch") + " " + System.getProperty("os.name", "no-os-arch") + " " +
System.getProperty("os.version", "no-os-version") + "; " +
"java " + System.getProperty("java.version", "no-java-version") + "; " + loc;
userAgent = "yacy (www.yacy.net; v" + vDATE + "; " + systemOST + ")";
}
// http client
@ -342,26 +322,43 @@ public final class httpc {
}
}
// provide HTTP date handling static methods
public static String dateString(Date date) {
if (date == null) return ""; else return HTTPGMTFormatter.format(date);
void reset() {
if (this.clientInput != null) {
try {this.clientInput.close();} catch (Exception e) {}
this.clientInput = null;
}
if (this.clientOutput != null) {
try {this.clientOutput.close();} catch (Exception e) {}
this.clientOutput = null;
}
if (this.socket != null) {
try {this.socket.close();} catch (Exception e) {}
this.socket = null;
}
public static Date nowDate() {
return new GregorianCalendar(GMTTimeZone).getTime();
this.host = null;
this.timeout = 0;
this.handle = 0;
this.remoteProxyUse = false;
this.savedRemoteHost = null;
this.requestPath = null;
// shrink readlinebuffer if it is to large
this.readLineBuffer.reset(80);
}
static {
// provide system information for client identification
String loc = System.getProperty("user.timezone", "nowhere");
int p = loc.indexOf("/");
if (p > 0) loc = loc.substring(0,p);
loc = loc + "/" + System.getProperty("user.language", "dumb");
systemOST =
System.getProperty("os.arch", "no-os-arch") + " " + System.getProperty("os.name", "no-os-arch") + " " +
System.getProperty("os.version", "no-os-version") + "; " +
"java " + System.getProperty("java.version", "no-java-version") + "; " + loc;
userAgent = "yacy (www.yacy.net; v" + vDATE + "; " + systemOST + ")";
public void close() {
reset();
}
protected void finalize() throws Throwable {
if (!(this.removedFromPool)) {
System.err.println("Httpc object was not returned to object pool.");
httpc.theHttpcPool.invalidateObject(this);
}
this.reset();
}
public final class response {
@ -551,15 +548,6 @@ public final class httpc {
}
public void close() {
// closes the connection
try {
this.clientInput.close();
this.clientOutput.close();
this.socket.close();
} catch (IOException e) {}
}
// method is either GET, HEAD or POST
private void send(String method, String path, httpHeader header, boolean zipped) throws IOException {
// scheduled request through request-response objects/threads
@ -1207,6 +1195,7 @@ final class httpcFactory implements org.apache.commons.pool.PoolableObjectFactor
public void destroyObject(Object obj) {
if (obj instanceof httpc) {
httpc theHttpc = (httpc) obj;
theHttpc.removedFromPool = true;
}
}
@ -1215,8 +1204,7 @@ final class httpcFactory implements org.apache.commons.pool.PoolableObjectFactor
* @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)
*/
public boolean validateObject(Object obj) {
if (obj instanceof httpc)
{
if (obj instanceof httpc) {
httpc theHttpc = (httpc) obj;
return true;
}

@ -125,7 +125,7 @@ public class kelondroTree extends kelondroRecords implements Comparator {
}
// Returns the value to which this map maps the specified key.
public byte[][] get(byte[] key) throws IOException {
public synchronized byte[][] get(byte[] key) throws IOException {
//System.out.println("kelondroTree.get " + new String(key) + " in " + filename);
Search search = new Search(key);
if (search.found()) {
@ -298,7 +298,7 @@ public class kelondroTree extends kelondroRecords implements Comparator {
}
// Associates the specified value with the specified key in this map
public byte[][] put(byte[][] newrow) throws IOException {
public synchronized byte[][] put(byte[][] newrow) throws IOException {
if (newrow.length != columns()) throw new IllegalArgumentException("put: wrong row length " + newrow.length + "; must be " + columns());
// first try to find the key element in the database
Search searchResult = new Search(newrow[0]);
@ -546,7 +546,7 @@ public class kelondroTree extends kelondroRecords implements Comparator {
}
// Associates the specified value with the specified key in this map
public synchronized byte[] put(byte[] key, byte[] value) throws IOException {
public byte[] put(byte[] key, byte[] value) throws IOException {
byte[][] row = new byte[2][];
row[0] = key;
row[1] = value;
@ -571,7 +571,7 @@ public class kelondroTree extends kelondroRecords implements Comparator {
while (size() > 0) remove(lastNode(), null);
}
public void remove(Node node, Node parentOfNode) throws IOException {
private void remove(Node node, Node parentOfNode) throws IOException {
// there are three cases when removing a node
// - the node is a leaf - it can be removed easily
// - the node has one child - the child replaces the node
@ -1214,7 +1214,7 @@ public class kelondroTree extends kelondroRecords implements Comparator {
// Returns -1, 0, or 1 as the first argument
// is less than, equal to, or greater than the second.
// two arrays are also equal if one array is a subset of the other's array with filled-up char(0)-values
public synchronized int compare(byte[] a, byte[] b) {
public int compare(byte[] a, byte[] b) {
int i = 0;
int al = a.length;
int bl = b.length;

@ -402,11 +402,11 @@ xpstopw=true
50_localcrawl_busysleep=200
61_globalcrawltrigger_idlesleep=10000
61_globalcrawltrigger_busysleep=200
62_remotetriggeredcrawl_idlesleep=20000
62_remotetriggeredcrawl_idlesleep=10000
62_remotetriggeredcrawl_busysleep=200
70_cachemanager_idlesleep=10000
70_cachemanager_idlesleep=1000
70_cachemanager_busysleep=0
80_indexing_idlesleep=10000
80_indexing_idlesleep=1000
80_indexing_busysleep=0
90_cleanup_idlesleep=300000
90_cleanup_busysleep=300000

Loading…
Cancel
Save