Skip to content

Commit 76f433f

Browse files
committed
fixed auto-pushing to non-worker child processes (cache loader & cache manager)
1 parent 709b173 commit 76f433f

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

ngx_rtmp_auto_push_module.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
309309
u_char *p;
310310
ngx_str_t *u;
311311
ngx_pid_t pid;
312+
char *pname;
312313

313314
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
314315
"auto_push: reconnect");
@@ -346,6 +347,20 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
346347
continue;
347348
}
348349

350+
/*
351+
* This is a dirty way to skip "cache manager" and
352+
* "cache loader" processes when pushing streams.
353+
*/
354+
355+
pname = ngx_processes[n].name;
356+
if (ngx_strstr(pname, "cache")) {
357+
ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
358+
"auto_push: skip process slot=%i pid=%i "
359+
"name='%s' pname='%s'",
360+
n, (ngx_int_t) pid, ctx->name, pname);
361+
continue;
362+
}
363+
349364
if (*slot) {
350365
continue;
351366
}
@@ -373,10 +388,10 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
373388
at.flash_ver.data = flash_ver;
374389
at.flash_ver.len = p - flash_ver;
375390

376-
ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
391+
ngx_log_debug5(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
377392
"auto_push: connect slot=%i pid=%i socket='%s' "
378-
"name='%s'",
379-
n, (ngx_int_t) pid, path, ctx->name);
393+
"name='%s' pname='%s'",
394+
n, (ngx_int_t) pid, path, ctx->name, pname);
380395

381396
if (ngx_rtmp_relay_push(s, &name, &at) == NGX_OK) {
382397
*slot = 1;
@@ -385,8 +400,8 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
385400

386401
ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
387402
"auto_push: connect failed: slot=%i pid=%i socket='%s'"
388-
"url='%V' name='%s'",
389-
n, (ngx_int_t) pid, path, u, ctx->name);
403+
"url='%V' name='%s' pname='%s'",
404+
n, (ngx_int_t) pid, path, u, ctx->name, pname);
390405

391406
if (!ctx->push_evt.timer_set) {
392407
ngx_add_timer(&ctx->push_evt, apcf->push_reconnect);

0 commit comments

Comments
 (0)