kaltura / nginx-srt-module

Nginx SRT/TCP gateway
GNU Affero General Public License v3.0
83 stars 15 forks source link

can you explain it? #1

Closed shenlei190810 closed 2 years ago

shenlei190810 commented 2 years ago

as the code shows, when srt_post_flags==1, the sc struct is not put in the ngx_srt_srt_posted; I ask for the reason, thank you.

static void
ngx_srt_conn_post_srt(ngx_srt_conn_t *sc, uint32_t flags)
{
    ngx_flag_t  notify;

    ngx_log_debug2(NGX_LOG_DEBUG_EVENT, sc->connection->log, 0,
        "ngx_srt_conn_post_srt: conn: %p, flags: 0x%uxD", sc, flags);

    ngx_spinlock(&ngx_srt_srt_posted_lock, 1, 2048);

    if (!sc->srt_post_flags) {
        sc->srt_next = ngx_srt_srt_posted;
        ngx_srt_srt_posted = sc;

        notify = 1;
    } else {
        notify = 0;
    }

    sc->srt_post_flags |= flags;

    ngx_memory_barrier();

    ngx_unlock(&ngx_srt_srt_posted_lock);

    if (notify) {
        (void) ngx_srt_epoll_notify(sc->connection->log);
    }
}

1

kaltura-hooks commented 2 years ago

Hi @shenlei190810,

Thank for you reporting an issue and helping improve Kaltura!

To get the fastest response time, and help the maintainers review and test your reported issues or suggestions, please ensure that your issue includes the following (please comment with more info if you have not included all this info in your original issue):

For general troubleshooting see: https://github.com/kaltura/platform-install-packages/blob/Jupiter-10.13.0/doc/kaltura-packages-faq.md#troubleshooting-help

If you only have a general question rather than a bug report, please close this issue and post at: http://forum.kaltura.org

Thank you in advance,

erankor commented 2 years ago

These functions are used for passing notifications between the SRT thread and the main nginx thread. There is a linked list of pending connections for each thread, events are sent by adding the connection object to the list + writing to an eventfd. If the post flags are non-zero (note that it's not necessarily 1, can be any mix of NGX_SRT_POST_XXX flags), it means the connection object is already linked to the respective list, so it should not be added again.