mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-12-27 03:17:43 +01:00
Release connection break a bit to not completely freeze the webserver on too many requests
This commit is contained in:
parent
eadf854c50
commit
a09d930b15
@ -74,15 +74,17 @@ public void run() {
|
||||
try {
|
||||
HttpRequest request = acceptRequest();
|
||||
|
||||
boolean hasPermit = false;
|
||||
try {
|
||||
processingSemaphore.acquire();
|
||||
//just slow down processing if limit is reached
|
||||
hasPermit = processingSemaphore.tryAcquire(1, TimeUnit.SECONDS);
|
||||
|
||||
HttpResponse response = handler.handle(request);
|
||||
sendResponse(response);
|
||||
|
||||
if (verbose) log(request, response);
|
||||
} finally {
|
||||
processingSemaphore.release();
|
||||
if (hasPermit) processingSemaphore.release();
|
||||
}
|
||||
|
||||
} catch (InvalidRequestException e){
|
||||
|
@ -60,7 +60,7 @@ public WebServer(InetAddress bindAddress, int port, int maxConnections, HttpRequ
|
||||
this.verbose = verbose;
|
||||
|
||||
this.handler = handler;
|
||||
this.processingSemaphore = new Semaphore(18);
|
||||
this.processingSemaphore = new Semaphore(24);
|
||||
|
||||
connectionThreads = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user