@@ -15,15 +15,34 @@ static void ngx_rtmp_proxy_protocol_recv(ngx_event_t *rev);
15
15
void
16
16
ngx_rtmp_proxy_protocol (ngx_rtmp_session_t * s )
17
17
{
18
+ ngx_event_t * rev ;
18
19
ngx_connection_t * c ;
19
20
20
21
c = s -> connection ;
21
- c -> read -> handler = ngx_rtmp_proxy_protocol_recv ;
22
+ rev = c -> read ;
23
+ rev -> handler = ngx_rtmp_proxy_protocol_recv ;
22
24
23
25
ngx_log_debug0 (NGX_LOG_DEBUG_RTMP , s -> connection -> log , 0 ,
24
26
"proxy_protocol: start" );
25
27
26
- ngx_rtmp_proxy_protocol_recv (c -> read );
28
+ if (rev -> ready ) {
29
+ /* the deferred accept(), rtsig, aio, iocp */
30
+
31
+ if (ngx_use_accept_mutex ) {
32
+ ngx_post_event (rev , & ngx_posted_events );
33
+ return ;
34
+ }
35
+
36
+ rev -> handler (rev );
37
+ return ;
38
+ }
39
+
40
+ ngx_add_timer (rev , s -> timeout );
41
+
42
+ if (ngx_handle_read_event (rev , 0 ) != NGX_OK ) {
43
+ ngx_rtmp_finalize_session (s );
44
+ return ;
45
+ }
27
46
}
28
47
29
48
@@ -58,10 +77,12 @@ ngx_rtmp_proxy_protocol_recv(ngx_event_t *rev)
58
77
ngx_del_timer (rev );
59
78
}
60
79
61
- n = recv (c -> fd , buf , sizeof (buf ), MSG_PEEK );
80
+ n = recv (c -> fd , ( char * ) buf , sizeof (buf ), MSG_PEEK );
62
81
63
82
err = ngx_socket_errno ;
64
83
84
+ ngx_log_debug1 (NGX_LOG_DEBUG_RTMP , c -> log , 0 , "recv(): %d" , n );
85
+
65
86
if (n == -1 ) {
66
87
67
88
if (err == NGX_EAGAIN ) {
@@ -126,7 +147,7 @@ ngx_rtmp_proxy_protocol_recv(ngx_event_t *rev)
126
147
}
127
148
}
128
149
129
- if (i + 1 = = n ) {
150
+ if (i + 1 > = n ) {
130
151
goto bad_header ;
131
152
}
132
153
0 commit comments