Merge "Fix tethering WTF issue"
This commit is contained in:
commit
e522b7ff75
1 changed files with 8 additions and 1 deletions
|
|
@ -23,6 +23,7 @@ import static android.system.OsConstants.IPPROTO_RAW;
|
|||
import static android.system.OsConstants.SOCK_DGRAM;
|
||||
import static android.system.OsConstants.SOCK_NONBLOCK;
|
||||
import static android.system.OsConstants.SOCK_RAW;
|
||||
import static android.system.OsConstants.ENODEV;
|
||||
|
||||
import android.net.util.SocketUtils;
|
||||
import android.os.Handler;
|
||||
|
|
@ -131,7 +132,13 @@ public class NeighborPacketForwarder extends PacketReader {
|
|||
ETH_P_IPV6, mListenIfaceParams.index);
|
||||
Os.bind(mFd, bindAddress);
|
||||
} catch (ErrnoException | SocketException e) {
|
||||
Log.wtf(mTag, "Failed to create socket", e);
|
||||
// An ENODEV(No such device) will rise if tethering stopped before this function, this
|
||||
// may happen when enable/disable tethering quickly.
|
||||
if (e instanceof ErrnoException && ((ErrnoException) e).errno == ENODEV) {
|
||||
Log.w(mTag, "Failed to create socket because tethered interface is gone", e);
|
||||
} else {
|
||||
Log.wtf(mTag, "Failed to create socket", e);
|
||||
}
|
||||
closeSocketQuietly(mFd);
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue