Skip to content

Instantly share code, notes, and snippets.

@ionutrazvanionita
Created November 6, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionutrazvanionita/86efca1c13c6654c2a74 to your computer and use it in GitHub Desktop.
Save ionutrazvanionita/86efca1c13c6654c2a74 to your computer and use it in GitHub Desktop.
diff --git a/io_wait.h b/io_wait.h
index 1aed8c8..0ff9b00 100644
--- a/io_wait.h
+++ b/io_wait.h
@@ -838,13 +838,39 @@ again:
}
}
#endif
+
for (r=0; r<n; r++) {
- if (h->ep_array[r].events & EPOLLOUT) {
+ if (h->ep_array[r].events&EPOLLIN){
+ if (h->ep_array[r].events&EPOLLHUP) {
+ LM_NOTICE("EPOLLIN(read) event: epoll_wait() "
+ "set event EPOLLHUP - "
+ "connection closed by the remote peer!\n");
+ }
+
+ while((handle_io((struct fd_map*)h->ep_array[r].data.ptr,-1,IO_WATCH_READ)>0)
+ && repeat);
+ }
+ else if (h->ep_array[r].events & EPOLLOUT) {
+ if (h->ep_array[r].events&EPOLLHUP) {
+ LM_NOTICE("EPOLLOUT(write) event: epoll_wait() "
+ "set event EPOLLHUP - "
+ "connection closed by the remote peer!\n");
+ }
+
handle_io((struct fd_map*)h->ep_array[r].data.ptr,-1,IO_WATCH_WRITE);
- } else if (h->ep_array[r].events & (EPOLLIN|EPOLLERR|EPOLLHUP)){
+ } else if (h->ep_array[r].events & EPOLLERR) {
+ LM_WARN("epoll_wait() set event EPOLLERR!"
+ "errno (%d): errmsg(%s)!"
+ "we still have to free the memory associated with this fd!\n",
+ errno, strerror(errno));
+
while((handle_io((struct fd_map*)h->ep_array[r].data.ptr,-1,IO_WATCH_READ)>0)
&& repeat);
- }else{
+ } else {
+ if (h->ep_array[r].events & EPOLLHUP) {
+ LM_NOTICE("connection closed by the remote peer!\n");
+ }
+
LM_ERR("unexpected event %x on %d/%d, data=%p\n",
h->ep_array[r].events, r+1, n, h->ep_array[r].data.ptr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment