android: Mitigate race condition on reauthentication
If the TUN device gets recreated while another thread in handle_plain() has not yet called select(2) but already stored the file descriptor of the old TUN device in its FD set, select() will fail with EBADF. Fixes #301.
This commit is contained in:
1 parent
4c969f7906
commit
e88b529a30
1 file changed
+4
@@ -167,6 +167,10 @@ static job_requeue_t handle_plain(private_android_service_t *this)
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
if (errno == EBADF)
|
||||
{ /* the TUN device got closed just before calling select(), retry */
|
||||
return JOB_REQUEUE_FAIR;
|
||||
}
|
||||
DBG1(DBG_DMN, "select on TUN device failed: %s", strerror(errno));
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user