-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,12 @@ | |
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import static com.danikula.videocache.Preconditions.checkAllNotNull; | ||
import static com.danikula.videocache.Preconditions.checkNotNull; | ||
import static com.danikula.videocache.ProxyCacheUtils.LOG_TAG; | ||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
|
||
/** | ||
* Simple lightweight proxy server with file caching support that handles HTTP requests. | ||
|
@@ -96,18 +96,17 @@ private void makeSureServerWorks() { | |
while (pingAttempts < maxPingAttempts) { | ||
try { | ||
Future<Boolean> pingFuture = socketProcessor.submit(new PingCallable()); | ||
pinged = pingFuture.get(delay, TimeUnit.MILLISECONDS); | ||
if (pinged) { | ||
this.pinged = pingFuture.get(delay, MILLISECONDS); | ||
if (this.pinged) { | ||
return; | ||
} | ||
pingAttempts++; | ||
SystemClock.sleep(delay); | ||
delay *= 2; | ||
} catch (InterruptedException | ExecutionException | TimeoutException e) { | ||
Log.e(LOG_TAG, "Error pinging server [attempt: " + pingAttempts + ", timeout: " + delay + "]. ", e); | ||
} | ||
pingAttempts++; | ||
delay *= 2; | ||
} | ||
|
||
Log.e(LOG_TAG, "Shutdown server… Error pinging server [attempt: " + pingAttempts + ", timeout: " + delay + "]. " + | ||
"If you see this message, please, email me [email protected]"); | ||
shutdown(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters