* Unregister the fd from the fdset. * Returns context of a given fd or NULL. */
| 144 | * Returns context of a given fd or NULL. |
| 145 | */ |
| 146 | void * |
| 147 | fdset_del(struct fdset *pfdset, int fd) |
| 148 | { |
| 149 | int i; |
| 150 | void *dat = NULL; |
| 151 | |
| 152 | if (pfdset == NULL || fd == -1) |
| 153 | return NULL; |
| 154 | |
| 155 | do { |
| 156 | pthread_mutex_lock(&pfdset->fd_mutex); |
| 157 | |
| 158 | i = fdset_find_fd(pfdset, fd); |
| 159 | if (i != -1 && pfdset->fd[i].busy == 0) { |
| 160 | /* busy indicates r/wcb is executing! */ |
| 161 | dat = pfdset->fd[i].dat; |
| 162 | pfdset->fd[i].fd = -1; |
| 163 | pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL; |
| 164 | pfdset->fd[i].dat = NULL; |
| 165 | i = -1; |
| 166 | } |
| 167 | pthread_mutex_unlock(&pfdset->fd_mutex); |
| 168 | } while (i != -1); |
| 169 | |
| 170 | return dat; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Unregister the fd from the fdset. |
no test coverage detected