| 295 | } |
| 296 | |
| 297 | int |
| 298 | conn_poll_for_msg(struct conn *conn) |
| 299 | { |
| 300 | struct epoll_event event; |
| 301 | int fd_client, status, status_data = 0, status_control = 0; |
| 302 | |
| 303 | /* Check input arguments */ |
| 304 | if (conn == NULL) |
| 305 | return -1; |
| 306 | |
| 307 | /* Client group */ |
| 308 | status = epoll_wait(conn->fd_client_group, |
| 309 | &event, |
| 310 | 1, |
| 311 | 0); |
| 312 | if (status == -1) |
| 313 | return -1; |
| 314 | if (status == 0) |
| 315 | return 0; |
| 316 | |
| 317 | fd_client = event.data.fd; |
| 318 | |
| 319 | /* Data available */ |
| 320 | if (event.events & EPOLLIN) |
| 321 | status_data = data_event_handle(conn, fd_client); |
| 322 | |
| 323 | /* Control events */ |
| 324 | if (event.events & (EPOLLRDHUP | EPOLLERR | EPOLLHUP)) |
| 325 | status_control = control_event_handle(conn, fd_client); |
| 326 | |
| 327 | if (status_data || status_control) |
| 328 | return -1; |
| 329 | |
| 330 | return 0; |
| 331 | } |
no test coverage detected