Skip to content

Commit f688376

Browse files
committed
HttpClient: Fix for not timing out queued requests
We would not watch the future until we started processing the request. This means that if we never started processing the request it would never timeout. This could have been so bad that eventually we might request a watchdog with a negative timeout. As an added bonus this reduces the variation of timeouts we may request from the WatchdogCache, allowing it to be much more efficent.
1 parent 30c0168 commit f688376

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

client/src/main/java/org/threadly/litesockets/client/http/HTTPClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ private void processQueue() {
333333
private void process(HTTPRequestWrapper hrw) {
334334
if(hrw != null) {
335335
try {
336-
sei.watchFuture(hrw.slf, hrw.timeTillExpired()+1);
337-
338336
hrw.updateReadTime();
339337
hrw.client = getTCPClient(hrw.chr.getHTTPAddress());
340338
inProcess.put(hrw.client, hrw);
@@ -520,12 +518,14 @@ private class HTTPRequestWrapper implements HTTPResponseCallback {
520518
private TCPClient client;
521519
private long lastRead = Clock.lastKnownForwardProgressingMillis();
522520

523-
public HTTPRequestWrapper(ClientHTTPRequest chr) {
521+
private HTTPRequestWrapper(ClientHTTPRequest chr) {
524522
hrp = new HTTPResponseProcessor(chr.getHTTPRequest()
525523
.getHTTPRequestHeader()
526524
.getRequestMethod().equals("HEAD"));
527525
hrp.addHTTPResponseCallback(this);
528526
this.chr = chr;
527+
528+
sei.watchFuture(slf, chr.getTimeoutMS());
529529
}
530530

531531
public void updateReadTime() {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group = org.threadly
2-
version = 0.17
2+
version = 0.18
33
threadlyVersion = 5.18
44
litesocketsVersion = 4.3
55
org.gradle.parallel=true

0 commit comments

Comments
 (0)