Questions about ae events & masks

24 views
Skip to first unread message

Konstantin Svist

unread,
Aug 24, 2015, 5:19:06 PM8/24/15
to Redis DB
I started looking into this code after seeing some strange errors in the log. Pretty sure this is caused by some additions, like thredis, but my quesitons are about the original code.

1. in src/networking.c, lines 728-729:
        aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
        aeDeleteFileEvent
(server.el,c->fd,AE_WRITABLE);

How come this is not a single call with a merged mask? Looks like the inner functions would easily support that.
Hunch: one of implementations (epoll/select/kqueue/etc.) doesn't support this..?

2. src/networking.c, line 888:
        aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);

It looks like the conneciton is closed completely here -- but only WRITABLE flag is removed. Is there no reason to clean up READABLE as well?

3. src/ae_evport.c lines 209-217:
    /*
     * The fd is currently associated with the port.  Like with the add case
     * above, we must look at the full mask for the file descriptor before
     * updating that association.  We don't have a good way of knowing what the
     * events are without looking into the eventLoop state directly.  We rely on
     * the fact that our caller has already updated the mask in the eventLoop.
     */


    fullmask
= eventLoop->events[fd].mask;

as opposed to ae.c line 161-162:
    aeApiDelEvent(eventLoop, fd, mask);
    fe
->mask = fe->mask & (~mask);

... so ae_evport.c seems to rely on caller clearing the mask, first -- but caller clears it only after the call!?



Konstantin Svist

unread,
Aug 24, 2015, 5:24:46 PM8/24/15
to Redis DB

3. src/ae_evport.c lines 209-217:
    /*
     * The fd is currently associated with the port.  Like with the add case
     * above, we must look at the full mask for the file descriptor before
     * updating that association.  We don't have a good way of knowing what the
     * events are without looking into the eventLoop state directly.  We rely on
     * the fact that our caller has already updated the mask in the eventLoop.
     */


    fullmask
= eventLoop->events[fd].mask;

as opposed to ae.c line 161-162:
    aeApiDelEvent(eventLoop, fd, mask);
    fe
->mask = fe->mask & (~mask);

... so ae_evport.c seems to rely on caller clearing the mask, first -- but caller clears it only after the call!?


Nevermind #3, looks like I misread the comment and jumped to conclusion too fast

Konstantin Svist

unread,
Aug 24, 2015, 6:55:47 PM8/24/15
to Redis DB
On Monday, August 24, 2015 at 2:19:06 PM UTC-7, Konstantin Svist wrote:
I started looking into this code after seeing some strange errors in the log. Pretty sure this is caused by some additions, like thredis, but my quesitons are about the original code.

1. in src/networking.c, lines 728-729:
        aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
        aeDeleteFileEvent
(server.el,c->fd,AE_WRITABLE);

How come this is not a single call with a merged mask? Looks like the inner functions would easily support that.
Hunch: one of implementations (epoll/select/kqueue/etc.) doesn't support this..?

2. src/networking.c, line 888:
        aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);

It looks like the conneciton is closed completely here -- but only WRITABLE flag is removed. Is there no reason to clean up READABLE as well?


On 3rd thought, ignore these questions too -- looks like I made some assumptions that don't hold water.
Still reading through the code, though
 
Reply all
Reply to author
Forward
0 new messages