vhost: use loop instead of goto
This patch reorder the code a bit to use loop instead of goto. Besides, remove abudant check 'fd != -1'. Signed-off-by: Huawei Xie <huawei.xie@intel.com> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
This commit is contained in:
parent
31ff0c6a45
commit
aee87dd706
@ -172,23 +172,19 @@ fdset_del(struct fdset *pfdset, int fd)
|
|||||||
if (pfdset == NULL || fd == -1)
|
if (pfdset == NULL || fd == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
again:
|
do {
|
||||||
pthread_mutex_lock(&pfdset->fd_mutex);
|
pthread_mutex_lock(&pfdset->fd_mutex);
|
||||||
|
|
||||||
i = fdset_find_fd(pfdset, fd);
|
i = fdset_find_fd(pfdset, fd);
|
||||||
if (i != -1 && fd != -1) {
|
if (i != -1 && pfdset->fd[i].busy == 0) {
|
||||||
/* busy indicates r/wcb is executing! */
|
/* busy indicates r/wcb is executing! */
|
||||||
if (pfdset->fd[i].busy == 1) {
|
pfdset->fd[i].fd = -1;
|
||||||
pthread_mutex_unlock(&pfdset->fd_mutex);
|
pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL;
|
||||||
goto again;
|
pfdset->num--;
|
||||||
|
i = -1;
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&pfdset->fd_mutex);
|
||||||
pfdset->fd[i].fd = -1;
|
} while (i != -1);
|
||||||
pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL;
|
|
||||||
pfdset->num--;
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&pfdset->fd_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user