Commit 6e96d027 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Set the IPPacket to null in each future socket answer when destroying the proxy

parent 88328125
......@@ -3,6 +3,7 @@ package com.frostnerd.dnschanger.util.dnsproxy;
import android.net.VpnService;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.system.ErrnoException;
import android.system.Os;
......@@ -294,7 +295,10 @@ public class DNSTCPProxy extends DNSProxy{
}
synchronized (futureSocketAnswers){
try {
for(Socket socket: futureSocketAnswers.keySet())socket.close();
for(Map.Entry<Socket, PacketWrap> entry: futureSocketAnswers.entrySet()){
entry.getKey().close();
entry.getValue().packet = null;
}
} catch (IOException e) {
e.printStackTrace();
}
......@@ -312,7 +316,7 @@ public class DNSTCPProxy extends DNSProxy{
}
private class PacketWrap{
private final IpPacket packet;
private IpPacket packet;
private final long time;
public PacketWrap(IpPacket packet) {
......
......@@ -31,6 +31,7 @@ import java.net.DatagramSocket;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
......@@ -274,7 +275,10 @@ public class DNSUDPProxy extends DNSProxy{
} catch (Exception ignored) {
}
synchronized (futureSocketAnswers){
for(DatagramSocket socket: futureSocketAnswers.keySet())socket.close();
for(Map.Entry<DatagramSocket, PacketWrap> entry: futureSocketAnswers.entrySet()){
entry.getKey().close();
entry.getValue().packet = null;
}
futureSocketAnswers.clear();
}
upstreamServers.clear();
......@@ -289,7 +293,7 @@ public class DNSUDPProxy extends DNSProxy{
}
private class PacketWrap{
private final IpPacket packet;
private IpPacket packet;
private final long time;
public PacketWrap(IpPacket packet) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment