Epoll and SIGALRM (setitimer) conflict

Discussion in 'C' started by Jamesbch, Aug 28, 2010.

  1. Jamesbch

    Jamesbch New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello there,

    I'm developing a server which use epoll to manage the incoming connections. I'm working at the moment on timers and I'm using the setitimer and sigaction interface of Linux. It's working well but I've found out that epoll and setitimer conflict each other: I guess they share the same signal SIGALRM because of this :
    Code:
             int nfds, fd;
            struct epoll_event events[MAX_EPOLL_EVENTS_PER_RUN];
            
            while (1) {
                    nfds = epoll_wait(_epoll_clients, events,
                                    MAX_EPOLL_EVENTS_PER_RUN,
                                    EPOLL_RUN_TIMEOUT);
                    
                    if (nfds < 0) {
                            // Is triggered when a timer has timeout
                            perror("epoll");
                    }
            }
    
    In the normal situations I would simply exit when epoll_wait returns a negative value but I don't want my program to quit when I'm using a timer. I tried to put a bool when a timer is scheduled and check it here. Unfortunately It didn't work when only 1 timer is scheduled because the epoll event comes AFTER my timer callback has finished its work (like resetting the bool). :icon_frown:

    Can you give me some advices or solution, please ? Many thanks in advance.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice