MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fdset_try_del

Function fdset_try_del

dpdk/lib/vhost/fd_man.c:181–204  ·  view source on GitHub ↗

* Unregister the fd from the fdset. * * If parameters are invalid, return directly -2. * And check whether fd is busy, if yes, return -1. * Otherwise, try to delete the fd from fdset and * return true. */

Source from the content-addressed store, hash-verified

179 * return true.
180 */
181int
182fdset_try_del(struct fdset *pfdset, int fd)
183{
184 int i;
185
186 if (pfdset == NULL || fd == -1)
187 return -2;
188
189 pthread_mutex_lock(&pfdset->fd_mutex);
190 i = fdset_find_fd(pfdset, fd);
191 if (i != -1 && pfdset->fd[i].busy) {
192 pthread_mutex_unlock(&pfdset->fd_mutex);
193 return -1;
194 }
195
196 if (i != -1) {
197 pfdset->fd[i].fd = -1;
198 pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL;
199 pfdset->fd[i].dat = NULL;
200 }
201
202 pthread_mutex_unlock(&pfdset->fd_mutex);
203 return 0;
204}
205
206/**
207 * This functions runs in infinite blocking loop until there is no fd in

Callers 1

Calls 3

pthread_mutex_lockFunction · 0.85
fdset_find_fdFunction · 0.85
pthread_mutex_unlockFunction · 0.85

Tested by

no test coverage detected