mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-12 22:18:11 -05:00
Close idle connections to exchange after one minute
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@493 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
4fdca92f08
commit
f10b0b6a85
@ -25,6 +25,10 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
final static String IE_USER_AGENT = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
|
final static String IE_USER_AGENT = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
|
||||||
static MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager;
|
static MultiThreadedHttpConnectionManager multiThreadedHttpConnectionManager;
|
||||||
|
|
||||||
|
final static long ONE_MINUTE = 60000;
|
||||||
|
|
||||||
|
static Thread httpConnectionManagerThread = null;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DavGatewayHttpClientFacade.start();
|
DavGatewayHttpClientFacade.start();
|
||||||
// force XML response with Internet Explorer header
|
// force XML response with Internet Explorer header
|
||||||
@ -279,14 +283,14 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
* @return Http Exception
|
* @return Http Exception
|
||||||
*/
|
*/
|
||||||
public static HttpException buildHttpException(HttpMethod method) {
|
public static HttpException buildHttpException(HttpMethod method) {
|
||||||
HttpException httpException = new HttpException();
|
return new HttpException(method.getStatusCode() + " " + method.getStatusText());
|
||||||
httpException.setReasonCode(method.getStatusCode());
|
|
||||||
httpException.setReason(method.getStatusText());
|
|
||||||
return httpException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stop() {
|
public static void stop() {
|
||||||
if (multiThreadedHttpConnectionManager != null) {
|
if (multiThreadedHttpConnectionManager != null) {
|
||||||
|
if (httpConnectionManagerThread != null) {
|
||||||
|
httpConnectionManagerThread.interrupt();
|
||||||
|
}
|
||||||
multiThreadedHttpConnectionManager.shutdown();
|
multiThreadedHttpConnectionManager.shutdown();
|
||||||
multiThreadedHttpConnectionManager = null;
|
multiThreadedHttpConnectionManager = null;
|
||||||
}
|
}
|
||||||
@ -295,7 +299,23 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
public static void start() {
|
public static void start() {
|
||||||
if (multiThreadedHttpConnectionManager == null) {
|
if (multiThreadedHttpConnectionManager == null) {
|
||||||
multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
|
multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
|
||||||
multiThreadedHttpConnectionManager.setMaxConnectionsPerHost(10);
|
multiThreadedHttpConnectionManager.getParams().setDefaultMaxConnectionsPerHost(100);
|
||||||
|
httpConnectionManagerThread = new Thread("HttpConnectionManager") {
|
||||||
|
public void run() {
|
||||||
|
boolean terminated = false;
|
||||||
|
while (!terminated) {
|
||||||
|
try {
|
||||||
|
sleep(ONE_MINUTE);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
terminated = true;
|
||||||
|
}
|
||||||
|
if (multiThreadedHttpConnectionManager != null) {
|
||||||
|
multiThreadedHttpConnectionManager.closeIdleConnections(ONE_MINUTE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
httpConnectionManagerThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user