Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] fixed unix domain socket bugs in auto-push. #256

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ngx_rtmp_auto_push_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
ngx_socket_t s;
size_t n;
ngx_file_info_t fi;
ngx_pid_t pid;

if (ngx_process != NGX_PROCESS_WORKER) {
return NGX_OK;
Expand Down Expand Up @@ -197,9 +198,10 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
return NGX_ERROR;
}
saun->sun_family = AF_UNIX;
pid = ngx_getpid();
*ngx_snprintf((u_char *) saun->sun_path, sizeof(saun->sun_path),
"%V/" NGX_RTMP_AUTO_PUSH_SOCKNAME ".%i",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process id should be printed by "%P".

&apcf->socket_dir, ngx_process_slot)
&apcf->socket_dir, pid)
= 0;

ngx_log_debug1(NGX_LOG_DEBUG_RTMP, cycle->log, 0,
Expand Down Expand Up @@ -352,6 +354,7 @@ ngx_rtmp_auto_push_exit_process(ngx_cycle_t *cycle)
ngx_listening_t *ls;
ngx_connection_t *c;
size_t n;
ngx_pid_t pid;

apcf = (ngx_rtmp_auto_push_conf_t *) ngx_get_conf(cycle->conf_ctx,
ngx_rtmp_auto_push_module);
Expand Down Expand Up @@ -398,9 +401,10 @@ ngx_rtmp_auto_push_exit_process(ngx_cycle_t *cycle)
}
}

pid = ngx_getpid();
*ngx_snprintf(path, sizeof(path),
"%V/" NGX_RTMP_AUTO_PUSH_SOCKNAME ".%i",
&apcf->socket_dir, ngx_process_slot)
&apcf->socket_dir, pid)
= 0;

ngx_delete_file(path);
Expand Down Expand Up @@ -513,7 +517,7 @@ ngx_rtmp_auto_push_reconnect(ngx_event_t *ev)
u = &at.url.url;
p = ngx_snprintf(path, sizeof(path) - 1,
"unix:%V/" NGX_RTMP_AUTO_PUSH_SOCKNAME ".%i",
&apcf->socket_dir, n);
&apcf->socket_dir, pid);
*p = 0;

if (ngx_file_info(path + sizeof("unix:") - 1, &fi) != NGX_OK) {
Expand Down