@@ -95,7 +95,7 @@ static int ngx_stream_lua_socket_receiveuntil_iterator(lua_State *L);
9595static ngx_int_t ngx_stream_lua_socket_compile_pattern (u_char * data , size_t len ,
9696 ngx_stream_lua_socket_compiled_pattern_t * cp , ngx_log_t * log );
9797static int ngx_stream_lua_socket_cleanup_compiled_pattern (lua_State * L );
98- static int ngx_stream_lua_req_socket (lua_State * L );
98+ static int ngx_stream_lua_tcp_req_socket (lua_State * L );
9999static void ngx_stream_lua_req_socket_rev_handler (ngx_stream_session_t * s ,
100100 ngx_stream_lua_ctx_t * ctx );
101101static int ngx_stream_lua_socket_tcp_getreusedtimes (lua_State * L );
@@ -193,7 +193,7 @@ enum {
193193static char ngx_stream_lua_req_socket_metatable_key ;
194194#endif
195195static char ngx_stream_lua_raw_req_socket_metatable_key ;
196- static char ngx_stream_lua_tcp_socket_metatable_key ;
196+ static char ngx_stream_lua_socket_tcp_metatable_key ;
197197static char ngx_stream_lua_upstream_udata_metatable_key ;
198198static char ngx_stream_lua_downstream_udata_metatable_key ;
199199static char ngx_stream_lua_pool_udata_metatable_key ;
@@ -276,8 +276,16 @@ ngx_stream_lua_inject_socket_tcp_api(ngx_log_t *log, lua_State *L)
276276 /* }}} */
277277
278278 /* {{{tcp object metatable */
279+ <<<<<<< HEAD
279280 lua_pushlightuserdata (L , & ngx_stream_lua_tcp_socket_metatable_key );
280281 lua_createtable (L , 0 /* narr */ , 11 /* nrec */ );
282+ = == == ==
283+ lua_pushlightuserdata (L , & ngx_stream_lua_skcoet_tcp_metatable_key );
284+ lua_createtable (L , 0 /* narr */ , 12 /* nrec */ );
285+
286+ lua_pushcfunction (L , ngx_stream_lua_socket_tcp_bind );
287+ lua_setfield (L , -2 , "bind" );
288+ >>>>>>> 75 a9f4b ... udp downstream api - work in progress
281289
282290 lua_pushcfunction (L , ngx_stream_lua_socket_tcp_connect );
283291 lua_setfield (L , -2 , "connect" );
@@ -364,14 +372,6 @@ ngx_stream_lua_inject_socket_tcp_api(ngx_log_t *log, lua_State *L)
364372}
365373
366374
367- void
368- ngx_stream_lua_inject_req_socket_api (lua_State * L )
369- {
370- lua_pushcfunction (L , ngx_stream_lua_req_socket );
371- lua_setfield (L , -2 , "socket" );
372- }
373-
374-
375375static int
376376ngx_stream_lua_socket_tcp (lua_State * L )
377377{
@@ -396,8 +396,13 @@ ngx_stream_lua_socket_tcp(lua_State *L)
396396 ngx_stream_lua_check_context (L , ctx , NGX_STREAM_LUA_CONTEXT_CONTENT
397397 | NGX_STREAM_LUA_CONTEXT_TIMER );
398398
399+ <<<<<<< HEAD
399400 lua_createtable (L , 3 /* narr */ , 1 /* nrec */ );
400401 lua_pushlightuserdata (L , & ngx_stream_lua_tcp_socket_metatable_key );
402+ = == == ==
403+ lua_createtable (L , 4 /* narr */ , 1 /* nrec */ );
404+ lua_pushlightuserdata (L , & ngx_stream_lua_socket_tcp_metatable_key );
405+ >>>>>>> 75 a9f4b ... udp downstream api - work in progress
401406 lua_rawget (L , LUA_REGISTRYINDEX );
402407 lua_setmetatable (L , -2 );
403408
@@ -3918,14 +3923,22 @@ ngx_stream_lua_socket_cleanup_compiled_pattern(lua_State *L)
39183923}
39193924
39203925
3926+ void
3927+ ngx_stream_lua_inject_tcp_req_socket_api (lua_State * L )
3928+ {
3929+ lua_pushcfunction (L , ngx_stream_lua_tcp_req_socket );
3930+ lua_setfield (L , -2 , "socket" );
3931+ }
3932+
3933+
39213934static int
3922- ngx_stream_lua_req_socket (lua_State * L )
3935+ ngx_stream_lua_tcp_req_socket (lua_State * L )
39233936{
39243937 int n , raw ;
3938+ ngx_stream_session_t * s ;
39253939 ngx_peer_connection_t * pc ;
39263940 ngx_stream_lua_srv_conf_t * lscf ;
39273941 ngx_connection_t * c ;
3928- ngx_stream_session_t * s ;
39293942 ngx_stream_lua_ctx_t * ctx ;
39303943 ngx_stream_lua_co_ctx_t * coctx ;
39313944 ngx_stream_lua_cleanup_t * cln ;
@@ -3956,6 +3969,11 @@ ngx_stream_lua_req_socket(lua_State *L)
39563969
39573970 c = s -> connection ;
39583971
3972+ if (c -> type != SOCK_STREAM ) {
3973+ return luaL_error (L , "socket api does not match connection transport" ,
3974+ lua_gettop (L ));
3975+ }
3976+
39593977#if !defined(nginx_version ) || nginx_version < 1003013
39603978 lua_pushnil (L );
39613979 lua_pushliteral (L , "nginx version too old" );
0 commit comments