Skip to content

Commit

Permalink
Fix event deletion for kqueue
Browse files Browse the repository at this point in the history
It seems that agnostic 'wide' deletion of both read and write events from kqueue
does not actually delete any of them, but fails because another doesn't exist in the time.
Later on execution it usually causes crash of the daemon.
  • Loading branch information
klirichek committed Jan 16, 2020
1 parent 66f994c commit a404c85
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/searchdha.cpp
Expand Up @@ -4224,10 +4224,11 @@ class KqueueEvents_c : public ISphNetPoller, public EventsList_t, public Timeout

sphLogDebugv ( "%p kqueue remove, ev=0x%u, sock=%d",
pEvent->m_tBack.pPtr, pEvent->m_uNetEvents, pEvent->m_iSock );
struct kevent tEv[2];
EV_SET( &tEv[0], pEvent->m_iSock, EVFILT_WRITE, EV_DELETE | EV_CLEAR, 0, 0, nullptr );
EV_SET( &tEv[1], pEvent->m_iSock, EVFILT_READ, EV_DELETE | EV_CLEAR, 0, 0, nullptr );
int iRes = kevent ( m_iKQ, tEv, 2, nullptr, 0, nullptr );
struct kevent tEv;
EV_SET( &tEv, pEvent->m_iSock,
( ( pEvent->m_uNetEvents & NetPollEvent_t::READ ) ? EVFILT_READ : EVFILT_WRITE ),
EV_DELETE | EV_CLEAR, 0, 0, nullptr );
int iRes = kevent ( m_iKQ, &tEv, 1, nullptr, 0, nullptr );

// might be already closed by worker from thread pool
if ( iRes==-1 )
Expand Down

0 comments on commit a404c85

Please sign in to comment.