@@ -495,43 +495,47 @@ ngx_rtmp_relay_create_connection(ngx_rtmp_conf_ctx_t *cctx, ngx_str_t *name,
495495 c = pc -> connection ;
496496 c -> pool = pool ;
497497
498+ ngx_str_set (& c -> addr_text , "ngx-relay" );
499+
500+ addr_conf = ngx_pcalloc (pool , sizeof (ngx_rtmp_addr_conf_t ));
501+ if (addr_conf == NULL ) {
502+ goto clear ;
503+ }
504+
498505 if (addr -> sockaddr -> sa_family != AF_UNIX ) {
499506 len = ngx_sock_ntop (pc -> sockaddr ,
500507#if (nginx_version >= 1005003 )
501508 pc -> socklen ,
502509#endif
503510 buf , NGX_SOCKADDR_STRLEN , 0 );
504511
505- c -> addr_text .data = ngx_pcalloc (pool , len );
506- if (c -> addr_text .data == NULL ) {
512+ addr_conf -> addr_text .data = ngx_pcalloc (pool , len );
513+ if (addr_conf -> addr_text .data == NULL ) {
507514 ngx_log_error (NGX_LOG_ERR , racf -> log , 0 ,
508515 "relay: allocation for address failed" );
509516 goto clear ;
510517 }
511518
512- c -> addr_text .len = len ;
513- ngx_memcpy (c -> addr_text .data , buf , len );
519+ addr_conf -> addr_text .len = len ;
520+ ngx_memcpy (addr_conf -> addr_text .data , buf , len );
514521 }
515522
516523#if (NGX_HAVE_UNIX_DOMAIN )
517524 if (addr -> sockaddr -> sa_family == AF_UNIX ) {
518- c -> addr_text .len = target -> url .host .len ;
519- c -> addr_text .data = ngx_pcalloc (pool , c -> addr_text .len );
520- if (c -> addr_text .data == NULL ) {
525+ addr_conf -> addr_text .len = target -> url .host .len ;
526+ addr_conf -> addr_text .data = ngx_pcalloc (pool ,
527+ addr_conf -> addr_text .len );
528+ if (addr_conf -> addr_text .data == NULL ) {
521529 ngx_log_error (NGX_LOG_ERR , racf -> log , 0 ,
522530 "relay: allocation for unix address failed" );
523531 goto clear ;
524532 }
525533
526- ngx_memcpy (c -> addr_text .data , target -> url .host .data , c -> addr_text .len );
534+ ngx_memcpy (addr_conf -> addr_text .data , target -> url .host .data ,
535+ addr_conf -> addr_text .len );
527536 }
528537#endif
529538
530- addr_conf = ngx_pcalloc (pool , sizeof (ngx_rtmp_addr_conf_t ));
531- if (addr_conf == NULL ) {
532- goto clear ;
533- }
534-
535539 addr_conf -> default_server = ngx_pcalloc (pool ,
536540 sizeof (ngx_rtmp_core_srv_conf_t ));
537541 if (addr_conf -> default_server == NULL ) {
@@ -546,7 +550,6 @@ ngx_rtmp_relay_create_connection(ngx_rtmp_conf_ctx_t *cctx, ngx_str_t *name,
546550 addr_conf -> default_server -> ctx = addr_ctx ;
547551 addr_ctx -> main_conf = cctx -> main_conf ;
548552 addr_ctx -> srv_conf = cctx -> srv_conf ;
549- ngx_str_set (& addr_conf -> addr_text , "ngx-relay" );
550553
551554 rs = ngx_rtmp_init_session (c , addr_conf );
552555 if (rs == NULL ) {
0 commit comments