diff options
author | Ricardo Salveti <ricardo.salveti@linaro.org> | 2016-07-25 13:22:22 -0300 |
---|---|---|
committer | Ricardo Salveti <ricardo.salveti@linaro.org> | 2016-07-25 13:26:13 -0300 |
commit | 5b1ff351aa2d38446487eed6ccd7ace1b654bbe6 (patch) | |
tree | 383fc0fb3c0906113cdbdc0268a32479ed8fa038 /lib/librte_vhost/vhost_user/fd_man.c | |
parent | fe9e0a156b8ec361b633b4d20d2231113f28fa63 (diff) |
Imported Upstream version 16.07-rc4
Change-Id: Ic57f6a3726f2dbd1682223648d91310f45705327
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Diffstat (limited to 'lib/librte_vhost/vhost_user/fd_man.c')
-rw-r--r-- | lib/librte_vhost/vhost_user/fd_man.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/librte_vhost/vhost_user/fd_man.c b/lib/librte_vhost/vhost_user/fd_man.c index c691339a..2d3eeb7d 100644 --- a/lib/librte_vhost/vhost_user/fd_man.c +++ b/lib/librte_vhost/vhost_user/fd_man.c @@ -132,8 +132,10 @@ fdset_init(struct fdset *pfdset) if (pfdset == NULL) return; - for (i = 0; i < MAX_FDS; i++) + for (i = 0; i < MAX_FDS; i++) { pfdset->fd[i].fd = -1; + pfdset->fd[i].dat = NULL; + } pfdset->num = 0; } @@ -166,14 +168,16 @@ fdset_add(struct fdset *pfdset, int fd, fd_cb rcb, fd_cb wcb, void *dat) /** * Unregister the fd from the fdset. + * Returns context of a given fd or NULL. */ -void +void * fdset_del(struct fdset *pfdset, int fd) { int i; + void *dat = NULL; if (pfdset == NULL || fd == -1) - return; + return NULL; do { pthread_mutex_lock(&pfdset->fd_mutex); @@ -181,13 +185,17 @@ fdset_del(struct fdset *pfdset, int fd) i = fdset_find_fd(pfdset, fd); if (i != -1 && pfdset->fd[i].busy == 0) { /* busy indicates r/wcb is executing! */ + dat = pfdset->fd[i].dat; pfdset->fd[i].fd = -1; pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL; + pfdset->fd[i].dat = NULL; pfdset->num--; i = -1; } pthread_mutex_unlock(&pfdset->fd_mutex); } while (i != -1); + + return dat; } /** @@ -203,6 +211,7 @@ fdset_del_slot(struct fdset *pfdset, int index) pfdset->fd[index].fd = -1; pfdset->fd[index].rcb = pfdset->fd[index].wcb = NULL; + pfdset->fd[index].dat = NULL; pfdset->num--; pthread_mutex_unlock(&pfdset->fd_mutex); |