@@ -246,7 +246,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
246246 ngx_int_t rc ;
247247#endif
248248 ngx_chain_t * cl ;
249- ngx_http_lua_loc_conf_t * llcf ;
249+ ngx_buf_tag_t tag ;
250250
251251 n = lua_gettop (L );
252252
@@ -280,6 +280,8 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
280280 rb = r -> request_body ;
281281 }
282282
283+ tag = (ngx_buf_tag_t ) & ngx_http_lua_module ;
284+
283285 tf = rb -> temp_file ;
284286
285287 if (tf ) {
@@ -302,10 +304,8 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
302304
303305 if (rb -> bufs ) {
304306
305- llcf = ngx_http_get_module_loc_conf (r , ngx_http_lua_module );
306-
307307 for (cl = rb -> bufs ; cl ; cl = cl -> next ) {
308- if (cl -> buf -> tag == llcf -> tag && cl -> buf -> temporary ) {
308+ if (cl -> buf -> tag == tag && cl -> buf -> temporary ) {
309309
310310 dd ("free old request body buffer: size:%d" ,
311311 (int ) ngx_buf_size (cl -> buf ));
@@ -324,12 +324,10 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
324324 goto set_header ;
325325 }
326326
327- llcf = ngx_http_get_module_loc_conf (r , ngx_http_lua_module );
328-
329327 if (rb -> bufs ) {
330328
331329 for (cl = rb -> bufs ; cl ; cl = cl -> next ) {
332- if (cl -> buf -> tag == llcf -> tag && cl -> buf -> temporary ) {
330+ if (cl -> buf -> tag == tag && cl -> buf -> temporary ) {
333331 dd ("free old request body buffer: size:%d" ,
334332 (int ) ngx_buf_size (cl -> buf ));
335333
@@ -346,7 +344,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
346344 ngx_memzero (b , sizeof (ngx_buf_t ));
347345
348346 b -> temporary = 1 ;
349- b -> tag = llcf -> tag ;
347+ b -> tag = tag ;
350348
351349 b -> start = ngx_palloc (r -> pool , body .len );
352350 if (b -> start == NULL ) {
@@ -366,7 +364,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
366364 rb -> bufs -> next = NULL ;
367365
368366 b = ngx_create_temp_buf (r -> pool , body .len );
369- b -> tag = llcf -> tag ;
367+ b -> tag = tag ;
370368 b -> last = ngx_copy (b -> pos , body .data , body .len );
371369
372370 rb -> bufs -> buf = b ;
@@ -449,7 +447,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
449447 ngx_pool_cleanup_file_t * clnf ;
450448 ngx_err_t err ;
451449 ngx_chain_t * cl ;
452- ngx_http_lua_loc_conf_t * llcf ;
450+ ngx_buf_tag_t tag ;
453451
454452 n = lua_gettop (L );
455453
@@ -495,13 +493,13 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
495493
496494 /* clean up existing r->request_body->bufs (if any) */
497495
498- llcf = ngx_http_get_module_loc_conf ( r , ngx_http_lua_module ) ;
496+ tag = ( ngx_buf_tag_t ) & ngx_http_lua_module ;
499497
500498 if (rb -> bufs ) {
501499 dd ("XXX reusing buf" );
502500
503501 for (cl = rb -> bufs ; cl ; cl = cl -> next ) {
504- if (cl -> buf -> tag == llcf -> tag && cl -> buf -> temporary ) {
502+ if (cl -> buf -> tag == tag && cl -> buf -> temporary ) {
505503 dd ("free old request body buffer: size:%d" ,
506504 (int ) ngx_buf_size (cl -> buf ));
507505
@@ -516,7 +514,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
516514
517515 ngx_memzero (b , sizeof (ngx_buf_t ));
518516
519- b -> tag = llcf -> tag ;
517+ b -> tag = tag ;
520518
521519 } else {
522520
@@ -533,7 +531,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
533531 return luaL_error (L , "out of memory" );
534532 }
535533
536- b -> tag = llcf -> tag ;
534+ b -> tag = tag ;
537535
538536 rb -> bufs -> buf = b ;
539537 rb -> buf = b ;
0 commit comments