intel / asynch_mode_nginx

Other
210 stars 60 forks source link

why not add/del all async_fd, but just only one? #44

Closed zhuizhuhaomeng closed 2 years ago

zhuizhuhaomeng commented 3 years ago

https://github.com/intel/asynch_mode_nginx/blob/master/src/event/ngx_event_openssl.c#L1660

we can see that, c->async_fd is just to passed fd to ngx_add_async_conn or ngx_del_async_conn. why not add all the fds ?

if we only want to add/del one fd, the loop is not needed at all.

    if (num_del_fds) {
        for (loop = 0; loop < num_del_fds; loop++) {
            c->async_fd = del_fds[loop];
            if (c->num_async_fds) {
                ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, "%s: deleting fd = %d", __func__, c->async_fd);
                ngx_del_async_conn(c, NGX_DISABLE_EVENT);
                c->num_async_fds--;
            }
        }
    }
    if (num_add_fds) {
        for (loop = 0; loop < num_add_fds; loop++) {
            if (c->num_async_fds == 0) {
                c->num_async_fds++;
                c->async_fd = add_fds[loop];
                ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, "%s: adding fd = %d", __func__, c->async_fd);
                ngx_add_async_conn(c);
            }
        }
    }
zhangp8x commented 3 years ago

@zhuizhuhaomeng
Thank you for your advice, will look in to these codes and give you feedback.

zhangp8x commented 3 years ago

@zhuizhuhaomeng

I can not catch up with you. I see this code blocks just delete/add all the fds.

What's your point? Have you just omit the codes:

    SSL_get_changed_async_fds(c->ssl->connection, add_fds, &num_add_fds,
                              del_fds, &num_del_fds);
zhangp8x commented 3 years ago

@zhuizhuhaomeng Sorry for answering late, if no response in 7 days, I would like to close this issue, if any more questions, you can reopen this ticket or create a new one.