Skip to content

Commit

Permalink
sync base repo (#1)
Browse files Browse the repository at this point in the history
* [fix] fixed a crash bug resulted from 'reload' (winshining#238).

* [fix] fixed 'proxy protocol not working' bug (winshining#239).

* [fix] fixed a typo.

* [fix] fixed an endian bug in mp4 vod.
  • Loading branch information
Executor-Cheng authored Aug 1, 2023
1 parent 62903f6 commit a5c3cf3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
* **[misc]** if some changes were done and bugs were fixed.

* Ensure that your codes conform to code conventions:
* All files are prefixed by 'ngx_'.
* All files are prefixed by 'ngx\_'.
* Include #ifndef \_FILE\_NAME\_H\_INCLUDED\_, #define \_FILE\_NAME\_H\_INCLUDED\_ and #endif in header files.
* Comments use /* ... */ are preferable.
* It would be better that built-in types appear before customized types.
* There should be no less than 2 spaces between types and variables.
* Variables are aligned by character, not '*'.
* Variables are aligned by character, not '\*'.
* No more than 80 characters in a single code or comment line.
* Two blank lines between two functions, styles of macro and type definitions are same as functions.

Expand Down
2 changes: 0 additions & 2 deletions ngx_rtmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ typedef struct {

ngx_buf_t **free;
ngx_int_t nfree;

unsigned proxy_protocol:1;
} ngx_rtmp_connection_t;


Expand Down
66 changes: 45 additions & 21 deletions ngx_rtmp_auto_push_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
struct sockaddr_un *saun;
#if (nginx_version >= 1009011)
ngx_event_t *rev;
ngx_connection_t *c, *old;
ngx_connection_t *c;
ngx_module_t **modules;
ngx_int_t i, auto_push_index, event_core_index;
#endif
Expand Down Expand Up @@ -310,26 +310,6 @@ ngx_rtmp_auto_push_init_process(ngx_cycle_t *cycle)
rev->deferred_accept = ls->deferred_accept;
#endif

if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {
if (ls->previous) {

/*
* delete the old accept events that were bound to
* the old cycle read events array
*/

old = ls->previous->connection;

if (ngx_del_event(old->read, NGX_READ_EVENT, NGX_CLOSE_EVENT)
== NGX_ERROR)
{
return NGX_ERROR;
}

old->fd = (ngx_socket_t) -1;
}
}

#if (nginx_version >= 1009013)
rev->handler = (c->type == SOCK_STREAM) ? ngx_event_accept
: ngx_event_recvmsg;
Expand Down Expand Up @@ -369,11 +349,55 @@ ngx_rtmp_auto_push_exit_process(ngx_cycle_t *cycle)
ngx_rtmp_auto_push_conf_t *apcf;
u_char path[NGX_MAX_PATH];

ngx_listening_t *ls;
ngx_connection_t *c;
size_t n;

apcf = (ngx_rtmp_auto_push_conf_t *) ngx_get_conf(cycle->conf_ctx,
ngx_rtmp_auto_push_module);
if (apcf->auto_push == 0) {
return;
}

ls = cycle->listening.elts;

for (n = 0; n < cycle->listening.nelts; ++n, ++ls) {
if ((ls->handler == ngx_rtmp_init_connection) &&
(ls->sockaddr && ls->sockaddr->sa_family == AF_UNIX))
{
c = ls->connection;

if (c) {
if (c->read->active) {
if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {

/*
* delete the old accept events that were bound to
* the old cycle read events array
*/

ngx_del_event(c->read,
NGX_READ_EVENT, NGX_CLOSE_EVENT);

ngx_free_connection(c);

c->fd = (ngx_socket_t) -1;
}
}
}

if (ngx_close_socket(ls->fd) == -1) {
ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_socket_errno,
ngx_close_socket_n "%V failed",
&ls->addr_text);
}

ls->fd = (ngx_socket_t) -1;

break;
}
}

*ngx_snprintf(path, sizeof(path),
"%V/" NGX_RTMP_AUTO_PUSH_SOCKNAME ".%i",
&apcf->socket_dir, ngx_process_slot)
Expand Down
2 changes: 1 addition & 1 deletion ngx_rtmp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ngx_rtmp_init_connection(ngx_connection_t *c)

s->auto_pushed = unix_socket;

if (rconn->proxy_protocol) {
if (rconn->addr_conf->proxy_protocol) {
ngx_rtmp_proxy_protocol(s);

} else {
Expand Down
5 changes: 5 additions & 0 deletions ngx_rtmp_mp4_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ typedef struct {
} ngx_rtmp_mp4_ctx_t;


#if (NGX_HAVE_LITTLE_ENDIAN)
#define ngx_rtmp_mp4_make_tag(a, b, c, d) \
((uint32_t)d << 24 | (uint32_t)c << 16 | (uint32_t)b << 8 | (uint32_t)a)
#else
#define ngx_rtmp_mp4_make_tag(a, b, c, d) \
((uint32_t)a << 24 | (uint32_t)b << 16 | (uint32_t)c << 8 | (uint32_t)d)
#endif


static ngx_inline uint32_t
Expand Down

0 comments on commit a5c3cf3

Please sign in to comment.