arut / nginx-live-module

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

Fixed created sockets #1

Closed hongzhidao closed 6 years ago

hongzhidao commented 6 years ago

Hi. Please take a look.

Since the type of p is ngx_socket_t (not u_char ).

diff --git a/src/ngx_http_live_module.c b/src/ngx_http_live_module.c
index cfa3905..7e6756b 100644
--- a/src/ngx_http_live_module.c
+++ b/src/ngx_http_live_module.c
@@ -1110,7 +1110,7 @@ ngx_http_live_init_module(ngx_cycle_t *cycle)
     size_t                      buffer_size;
     socklen_t                   olen;
     ngx_uint_t                  n, nfd;
-    ngx_socket_t               *p, fds[2];
+    ngx_socket_t               *sockets, fds[2];
     ngx_core_conf_t            *ccf;
     ngx_pool_cleanup_t         *cln;
     ngx_http_live_main_conf_t  *lmcf;
@@ -1125,13 +1125,13 @@ ngx_http_live_init_module(ngx_cycle_t *cycle)

     nfd = ccf->worker_processes;

-    p = ngx_palloc(cycle->pool, nfd * 2 * sizeof(ngx_socket_t));
-    if (p == NULL) {
+    sockets = ngx_palloc(cycle->pool, nfd * 2 * sizeof(ngx_socket_t));
+    if (sockets == NULL) {
         return NGX_ERROR;
     }

-    lmcf->read_fd = p;
-    lmcf->write_fd = p + nfd * sizeof(ngx_socket_t);
+    lmcf->read_fd = sockets;
+    lmcf->write_fd = sockets + nfd;

     cln = ngx_pool_cleanup_add(cycle->pool, 0);
     if (cln == NULL) {
arut commented 6 years ago

Thanks for noticing this. But since the name sockets is never used in nginx code, I will rather rename p to fd.

hongzhidao commented 6 years ago

Hi.

I think write_fd isn't processed well.

diff --git a/src/ngx_http_live_module.c b/src/ngx_http_live_module.c
index 9fa88a8..1d9f8cc 100644
--- a/src/ngx_http_live_module.c
+++ b/src/ngx_http_live_module.c
@@ -1131,7 +1131,7 @@ ngx_http_live_init_module(ngx_cycle_t *cycle)
     }

     lmcf->read_fd = fd;
-    lmcf->write_fd = fd + nfd * sizeof(ngx_socket_t);
+    lmcf->write_fd = fd + nfd;

     cln = ngx_pool_cleanup_add(cycle->pool, 0);
     if (cln == NULL) {

On Thu, Sep 20, 2018 at 4:28 PM Roman Arutyunyan notifications@github.com wrote:

Closed #1 https://github.com/arut/nginx-live-module/issues/1.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arut/nginx-live-module/issues/1#event-1857009719, or mute the thread https://github.com/notifications/unsubscribe-auth/AHz516FHROw2vxImX0w2jx8-YMhmDV3Mks5uc1GfgaJpZM4WxTXR .