-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from zerotier/bugfix/242
Fix #242
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import com.zerotier.sockets.*; | ||
|
||
// | ||
// Test for: | ||
// Java process does not exit after finishing libzt work | ||
// https://github.com/zerotier/libzt/issues/242 | ||
// | ||
// Run and ensure that process exits | ||
// | ||
public class ExitTest { | ||
|
||
public static void main(String[] args) throws InterruptedException { | ||
|
||
long networkId = Long.parseUnsignedLong("ebe7fbd445e76ac6", 16); | ||
String storagePath = "exittest_storage"; | ||
|
||
ZeroTierNode node = new ZeroTierNode(); | ||
node.initFromStorage(storagePath); | ||
node.initSetEventHandler(new ZeroTierEventListener() { | ||
@Override | ||
public void onZeroTierEvent(long l, int eventCode) { | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NODE_UP) { | ||
System.err.println("ZTS_EVENT_NODE_UP"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NODE_ONLINE) { | ||
System.err.println("ZTS_EVENT_NODE_ONLINE"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NODE_OFFLINE) { | ||
System.err.println("ZTS_EVENT_NODE_OFFLINE"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NODE_DOWN) { | ||
System.err.println("ZTS_EVENT_NODE_DOWN"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NETWORK_READY_IP4) { | ||
System.err.println("ZTS_EVENT_NETWORK_READY_IP4"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NETWORK_READY_IP6) { | ||
System.err.println("ZTS_EVENT_NETWORK_READY_IP6"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NETWORK_DOWN) { | ||
System.err.println("ZTS_EVENT_NETWORK_DOWN"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NETWORK_OK) { | ||
System.err.println("ZTS_EVENT_NETWORK_OK"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NETWORK_ACCESS_DENIED) { | ||
System.err.println("ZTS_EVENT_NETWORK_ACCESS_DENIED"); | ||
} | ||
if (eventCode == ZeroTierNative.ZTS_EVENT_NETWORK_NOT_FOUND) { | ||
System.err.println("ZTS_EVENT_NETWORK_NOT_FOUND"); | ||
} | ||
} | ||
}); | ||
|
||
System.err.println("start"); | ||
node.start(); | ||
|
||
System.err.println("delay until online"); | ||
while (!node.isOnline()) { | ||
ZeroTierNative.zts_util_delay(50); | ||
} | ||
System.err.println("done delaying"); | ||
|
||
System.out.println("join"); | ||
node.join(networkId); | ||
|
||
System.out.println("delaying until transport ready"); | ||
while (! node.isNetworkTransportReady(networkId)) { | ||
ZeroTierNative.zts_util_delay(50); | ||
} | ||
|
||
System.err.println("stop"); | ||
node.stop(); | ||
|
||
System.err.println("exiting"); | ||
} | ||
} |