提交 32f2eac4 编写于 作者: S Serge Rider

Standby detection poc


Former-commit-id: a32cfd23
上级 71dc3821
......@@ -38,12 +38,14 @@ import java.util.*;
public class KeepAliveListenerJob extends AbstractJob
{
private static final int MONITOR_INTERVAL = 3000; // once per 3 seconds
private static final long SYSTEM_SUSPEND_INTERVAL = 30000; // 30 seconds of inactivity - most likely a system suspend
private static final Log log = Log.getLog(KeepAliveListenerJob.class);
private final DBPPlatform platform;
private Map<String, Long> checkCache = new HashMap<>();
private final Set<String> pingCache = new HashSet<>();
private long lastPingTime = -1;
public KeepAliveListenerJob(DBPPlatform platform)
{
......@@ -59,6 +61,11 @@ public class KeepAliveListenerJob extends AbstractJob
if (platform.isShuttingDown()) {
return Status.OK_STATUS;
}
if (lastPingTime > 0 && System.currentTimeMillis() - lastPingTime > SYSTEM_SUSPEND_INTERVAL) {
log.debug("System suspend detected! Reinitialize all remote connections.");
}
lastPingTime = System.currentTimeMillis();
final DBPWorkspace workspace = platform.getWorkspace();
for (DBPProject project : workspace.getProjects()) {
if (project.isOpen() && project.isRegistryLoaded()) {
......
......@@ -107,6 +107,7 @@ public class Win32WindowDemo implements WindowProc {
}
case WM_POWERBROADCAST: {
// FIXME: it doesn't work!!
System.out.println("Power event");
if (wParam.intValue() == PBT_APMQUERYSUSPEND)
{
onSuspend(wParam, lParam);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册