Skip to content

Commit 99b0228

Browse files
committed
now we use the buf tag literal everywhere and removed the "tag" field from the location conf struct.
1 parent ec4becf commit 99b0228

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

src/ngx_http_lua_common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ typedef struct {
8989

9090

9191
typedef struct {
92-
ngx_buf_tag_t tag;
93-
9492
ngx_flag_t force_read_body; /* whether force request body to
9593
be read */
9694

src/ngx_http_lua_conf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ ngx_http_lua_create_loc_conf(ngx_conf_t *cf)
8787

8888
conf->force_read_body = NGX_CONF_UNSET;
8989
conf->enable_code_cache = NGX_CONF_UNSET;
90-
conf->tag = (ngx_buf_tag_t) &ngx_http_lua_module;
9190

9291
conf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
9392
conf->connect_timeout = NGX_CONF_UNSET_MSEC;

src/ngx_http_lua_req_body.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

src/ngx_http_lua_socket.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,6 @@ ngx_http_lua_socket_send(ngx_http_request_t *r,
17781778
ngx_int_t rc;
17791779
ngx_connection_t *c;
17801780
ngx_http_lua_ctx_t *ctx;
1781-
ngx_http_lua_loc_conf_t *llcf;
17821781

17831782
c = u->peer.connection;
17841783

@@ -1828,15 +1827,13 @@ ngx_http_lua_socket_send(ngx_http_request_t *r,
18281827
return NGX_ERROR;
18291828
}
18301829

1831-
llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
1832-
18331830
#if defined(nginx_version) && nginx_version >= 1001004
18341831
ngx_chain_update_chains(r->pool,
18351832
#else
18361833
ngx_chain_update_chains(
18371834
#endif
18381835
&ctx->free_bufs, &ctx->busy_bufs, &u->request_bufs,
1839-
llcf->tag);
1836+
(ngx_buf_tag_t) &ngx_http_lua_module);
18401837

18411838
u->request_sent = 0;
18421839
u->write_event_handler = ngx_http_lua_socket_dummy_handler;

src/ngx_http_lua_subrequest.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,6 @@ ngx_http_lua_post_subrequest(ngx_http_request_t *r, void *data, ngx_int_t rc)
805805
ngx_str_t *body_str;
806806
u_char *p;
807807
ngx_chain_t *cl;
808-
ngx_http_lua_loc_conf_t *llcf;
809808

810809
if (ctx->run_post_subrequest) {
811810
return rc;
@@ -907,15 +906,15 @@ ngx_http_lua_post_subrequest(ngx_http_request_t *r, void *data, ngx_int_t rc)
907906
}
908907

909908
if (ctx->body) {
910-
llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
911909

912910
#if defined(nginx_version) && nginx_version >= 1001004
913911
ngx_chain_update_chains(r->pool,
914912
#else
915913
ngx_chain_update_chains(
916914
#endif
917915
&pr_ctx->free_bufs, &pr_ctx->busy_bufs,
918-
&ctx->body, llcf->tag);
916+
&ctx->body,
917+
(ngx_buf_tag_t) &ngx_http_lua_module);
919918

920919
dd("free bufs: %p", pr_ctx->free_bufs);
921920
}

0 commit comments

Comments
 (0)