Skip to content

Commit a459a33

Browse files
committed
fixup dns lookup for multicast to use affinity thread.
filedatasink should mkdirs
1 parent ba2667f commit a459a33

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

AndroidAsync/src/com/koushikdutta/async/dns/Dns.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public static Cancellable multicastLookup(String host, FutureCallback<DnsRespons
6161
}
6262

6363
public static Future<DnsResponse> lookup(AsyncServer server, String host, final boolean multicast, final FutureCallback<DnsResponse> callback) {
64+
if (!server.isAffinityThread()) {
65+
SimpleFuture<DnsResponse> ret = new SimpleFuture<>();
66+
server.post(() -> ret.setComplete(lookup(server, host, multicast, callback)));
67+
return ret;
68+
}
6469
ByteBuffer packet = ByteBufferList.obtain(1024).order(ByteOrder.BIG_ENDIAN);
6570
short id = (short)new Random().nextInt();
6671
short flags = (short)setQuery(0);

AndroidAsync/src/com/koushikdutta/async/stream/FileDataSink.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public FileDataSink(AsyncServer server, File file) {
2121
public OutputStream getOutputStream() throws IOException {
2222
OutputStream ret = super.getOutputStream();
2323
if (ret == null) {
24+
file.getParentFile().mkdirs();
2425
ret = new FileOutputStream(file);
2526
setOutputStream(ret);
2627
}

0 commit comments

Comments
 (0)