arut / nginx-live-module

HTTP live module
BSD 2-Clause "Simplified" License
67 stars 17 forks source link

Fixed process init #2

Closed hongzhidao closed 5 years ago

hongzhidao commented 5 years ago

Hi.

Take a look, please.

diff --git a/src/ngx_http_live_module.c b/src/ngx_http_live_module.c
index e30812d..d7407c6 100644
--- a/src/ngx_http_live_module.c
+++ b/src/ngx_http_live_module.c
@@ -1291,6 +1291,10 @@ ngx_http_live_init_process(ngx_cycle_t *cycle)

     lmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_live_module);

+    if (ngx_process != NGX_PROCESS_WORKER) {
+        return NGX_OK;
+    }
+
     if (lmcf == NULL || lmcf->nfd == 0) {
         return NGX_OK;
     }

Because the other non-worker processes like cache process is meaningless to involve socketpairs. And their value of ngx_worker is 0, thus they will occupy the same fd for reading.

for (n = 0; n < lmcf->nfd; n++) {
        if (n == ngx_worker) {
            fd = lmcf->read_fd[n];
            continue;
        }
...
arut commented 5 years ago

Thanks @hongzhidao. Committed.