* 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. */
| 179 | * return true. |
| 180 | */ |
| 181 | int |
| 182 | fdset_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 |
no test coverage detected