Skip to content

Commit 6287f27

Browse files
committed
add hack to reap any leaking children
1 parent ccb7fb3 commit 6287f27

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/com/danga/MemCached/SockIOPool.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,5 +1858,25 @@ public int hashCode() {
18581858
public String toString() {
18591859
return ( sock == null ) ? "" : sock.toString();
18601860
}
1861+
1862+
/**
1863+
* Hack to reap any leaking children.
1864+
*/
1865+
protected void finalize() throws Throwable {
1866+
try {
1867+
if ( sock != null ) {
1868+
log.error( "++++ closing potentially leaked socket in finalize" );
1869+
sock.close();
1870+
sock = null;
1871+
}
1872+
}
1873+
catch ( Throwable t ) {
1874+
log.error( t.getMessage(), t );
1875+
1876+
}
1877+
finally {
1878+
super.finalize();
1879+
}
1880+
}
18611881
}
18621882
}

0 commit comments

Comments
 (0)