@@ -246,7 +246,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
246
246
ngx_int_t rc ;
247
247
#endif
248
248
ngx_chain_t * cl ;
249
- ngx_http_lua_loc_conf_t * llcf ;
249
+ ngx_buf_tag_t tag ;
250
250
251
251
n = lua_gettop (L );
252
252
@@ -280,6 +280,8 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
280
280
rb = r -> request_body ;
281
281
}
282
282
283
+ tag = (ngx_buf_tag_t ) & ngx_http_lua_module ;
284
+
283
285
tf = rb -> temp_file ;
284
286
285
287
if (tf ) {
@@ -302,10 +304,8 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
302
304
303
305
if (rb -> bufs ) {
304
306
305
- llcf = ngx_http_get_module_loc_conf (r , ngx_http_lua_module );
306
-
307
307
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 ) {
309
309
310
310
dd ("free old request body buffer: size:%d" ,
311
311
(int ) ngx_buf_size (cl -> buf ));
@@ -324,12 +324,10 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
324
324
goto set_header ;
325
325
}
326
326
327
- llcf = ngx_http_get_module_loc_conf (r , ngx_http_lua_module );
328
-
329
327
if (rb -> bufs ) {
330
328
331
329
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 ) {
333
331
dd ("free old request body buffer: size:%d" ,
334
332
(int ) ngx_buf_size (cl -> buf ));
335
333
@@ -346,7 +344,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
346
344
ngx_memzero (b , sizeof (ngx_buf_t ));
347
345
348
346
b -> temporary = 1 ;
349
- b -> tag = llcf -> tag ;
347
+ b -> tag = tag ;
350
348
351
349
b -> start = ngx_palloc (r -> pool , body .len );
352
350
if (b -> start == NULL ) {
@@ -366,7 +364,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
366
364
rb -> bufs -> next = NULL ;
367
365
368
366
b = ngx_create_temp_buf (r -> pool , body .len );
369
- b -> tag = llcf -> tag ;
367
+ b -> tag = tag ;
370
368
b -> last = ngx_copy (b -> pos , body .data , body .len );
371
369
372
370
rb -> bufs -> buf = b ;
@@ -449,7 +447,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
449
447
ngx_pool_cleanup_file_t * clnf ;
450
448
ngx_err_t err ;
451
449
ngx_chain_t * cl ;
452
- ngx_http_lua_loc_conf_t * llcf ;
450
+ ngx_buf_tag_t tag ;
453
451
454
452
n = lua_gettop (L );
455
453
@@ -495,13 +493,13 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
495
493
496
494
/* clean up existing r->request_body->bufs (if any) */
497
495
498
- llcf = ngx_http_get_module_loc_conf ( r , ngx_http_lua_module ) ;
496
+ tag = ( ngx_buf_tag_t ) & ngx_http_lua_module ;
499
497
500
498
if (rb -> bufs ) {
501
499
dd ("XXX reusing buf" );
502
500
503
501
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 ) {
505
503
dd ("free old request body buffer: size:%d" ,
506
504
(int ) ngx_buf_size (cl -> buf ));
507
505
@@ -516,7 +514,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
516
514
517
515
ngx_memzero (b , sizeof (ngx_buf_t ));
518
516
519
- b -> tag = llcf -> tag ;
517
+ b -> tag = tag ;
520
518
521
519
} else {
522
520
@@ -533,7 +531,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
533
531
return luaL_error (L , "out of memory" );
534
532
}
535
533
536
- b -> tag = llcf -> tag ;
534
+ b -> tag = tag ;
537
535
538
536
rb -> bufs -> buf = b ;
539
537
rb -> buf = b ;
0 commit comments