Explorar o código

HPCC-14452 CSocketEpollThread - no exception for bad file descriptor

Signed-off-by: Mark Kelly <mark.kelly@lexisnexis.com>
Mark Kelly %!s(int64=9) %!d(string=hai) anos
pai
achega
c5ae245c1b
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      system/jlib/jsocket.cpp

+ 8 - 5
system/jlib/jsocket.cpp

@@ -3917,6 +3917,7 @@ public:
                     EXCLOG(e,"CSocketSelectThread::updateItems");
                     e->Release();
                 }
+                // NOTE: si is a reference, put last item into remove slot
                 n--;
                 if (i<n) 
                     si = items.item(n);
@@ -4306,8 +4307,7 @@ class CSocketEpollThread: public CSocketBaseThread
         // if another thread closed fd before here don't fail
         if ( (srtn < 0) && (op != EPOLL_CTL_DEL) ){
             int err = ERRNO();
-            LOGERR(err,1,"epoll_ctl");
-            THROWJSOCKEXCEPTION2(err);
+            WARNLOG("epoll_ctl failed op:%d, fd:%d, err=%d", op, fd, err);
         }
     }
 
@@ -4421,8 +4421,8 @@ public:
             try {
                 SelectItem &si = items.element(i);
                 epoll_op(epfd, EPOLL_CTL_DEL, si.handle, 0);
-                si.sock->Release();
                 si.nfy->Release();
+                si.sock->Release();
             }
             catch (IException *e) {
                 EXCLOG(e,"~CSocketEpollThread");
@@ -4453,8 +4453,10 @@ public:
                 reindex = true;
             }
             if (si.del) {
-                epoll_op(epfd, EPOLL_CTL_DEL, si.handle, 0);
-                epfdtbl[si.handle] = -1;
+                if (epfdtbl[si.handle] >= 0) {
+                    epoll_op(epfd, EPOLL_CTL_DEL, si.handle, 0);
+                    epfdtbl[si.handle] = -1;
+                }
                 reindex = true;
                 si.nfy->Release();
                 try {
@@ -4467,6 +4469,7 @@ public:
                     EXCLOG(e,"CSocketEpollThread::updateItems");
                     e->Release();
                 }
+                // NOTE: si is a reference, put last item into remove slot
                 n--;
                 if (i<n)
                     si = items.item(n);