Skip to content

Commit

Permalink
Fix getting client connection port
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-dryabzhinsky committed Jul 4, 2015
1 parent dc0b3df commit 3170037
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions ngx_rtmp_stat_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ ngx_rtmp_stat_client(ngx_http_request_t *r, ngx_chain_t ***lll,
ngx_rtmp_session_t *s)
{
u_char buf[NGX_INT_T_LEN];
struct sockaddr_in *tmp;
struct sockaddr_in sa;
socklen_t len = sizeof(struct sockaddr);
struct sockaddr_in *sa;

#ifdef NGX_RTMP_POOL_DEBUG
ngx_rtmp_stat_dump_pool(r, lll, s->connection->pool);
Expand All @@ -349,13 +347,9 @@ ngx_rtmp_stat_client(ngx_http_request_t *r, ngx_chain_t ***lll,
** Displays socket port number
*/
NGX_RTMP_STAT_L("<port>");
if (getsockname(s->connection->fd, (struct sockaddr *) &sa, &len) != -1) {
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf), "%ui",
(ngx_uint_t) ntohs(sa.sin_port)) - buf);
} else {
// Something not going well?
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf), "%ui", 0) - buf);
}
sa = (struct sockaddr_in *) s->connection->sockaddr;
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf), "%ui",
(ngx_uint_t) ntohs(sa->sin_port)) - buf);
NGX_RTMP_STAT_L("</port>");


Expand Down

0 comments on commit 3170037

Please sign in to comment.