Merge pull request #5684 from rsyslog/codex/fix-data-race-reported-by-threadsanitizer

Fix race in notifyReArm
This commit is contained in:
Rainer Gerhards 2025-06-12 08:45:45 +02:00 committed by GitHub
commit 0ebc980309
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -836,10 +836,12 @@ static rsRetVal
notifyReArm(tcpsrv_io_descr_t *const pioDescr)
{
DEFiRet;
const unsigned waitIOEvent = (pioDescr->ioDirection == NSDSEL_WR) ? EPOLLOUT : EPOLLIN;
pioDescr->event.events = waitIOEvent | EPOLLET | EPOLLONESHOT;
if(epoll_ctl(pioDescr->pSrv->evtdata.epoll.efd, EPOLL_CTL_MOD, pioDescr->sock, &pioDescr->event) < 0) {
struct epoll_event event = {
.events = waitIOEvent | EPOLLET | EPOLLONESHOT,
.data = { .ptr = pioDescr }
};
if(epoll_ctl(pioDescr->pSrv->evtdata.epoll.efd, EPOLL_CTL_MOD, pioDescr->sock, &event) < 0) {
LogError(errno, RS_RET_ERR_EPOLL_CTL, "epoll_ctl failed re-armed socket %d", pioDescr->sock);
ABORT_FINALIZE(RS_RET_ERR_EPOLL_CTL);
}