]> granicus.if.org Git - curl/commitdiff
examples/ephiperfifo: report error when epoll_ctl fails
authorRomain Fliedel <rfliedel@freebox.fr>
Mon, 5 Nov 2018 10:46:56 +0000 (11:46 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 20 Nov 2018 18:58:41 +0000 (19:58 +0100)
docs/examples/ephiperfifo.c

index e2737259841eac059ee7c3f210181f1e11812d88..efb27b1bd0a1c4685f9071a82383392b47bb4f23 100644 (file)
@@ -257,7 +257,9 @@ static void remsock(SockInfo *f, GlobalInfo* g)
 {
   if(f) {
     if(f->sockfd) {
-      epoll_ctl(g->epfd, EPOLL_CTL_DEL, f->sockfd, NULL);
+      if(epoll_ctl(g->epfd, EPOLL_CTL_DEL, f->sockfd, NULL))
+        fprintf(stderr, "EPOLL_CTL_DEL failed for fd: %d : %s\n",
+                f->sockfd, strerror(errno));
     }
     free(f);
   }
@@ -274,7 +276,9 @@ static void setsock(SockInfo *f, curl_socket_t s, CURL *e, int act,
              (act & CURL_POLL_OUT ? EPOLLOUT : 0);
 
   if(f->sockfd) {
-    epoll_ctl(g->epfd, EPOLL_CTL_DEL, f->sockfd, NULL);
+    if(epoll_ctl(g->epfd, EPOLL_CTL_DEL, f->sockfd, NULL))
+      fprintf(stderr, "EPOLL_CTL_DEL failed for fd: %d : %s\n",
+              f->sockfd, strerror(errno));
   }
 
   f->sockfd = s;
@@ -283,7 +287,9 @@ static void setsock(SockInfo *f, curl_socket_t s, CURL *e, int act,
 
   ev.events = kind;
   ev.data.fd = s;
-  epoll_ctl(g->epfd, EPOLL_CTL_ADD, s, &ev);
+  if(epoll_ctl(g->epfd, EPOLL_CTL_ADD, s, &ev))
+    fprintf(stderr, "EPOLL_CTL_ADD failed for fd: %d : %s\n",
+            s, strerror(errno));
 }