Permalink
Browse files

now we use the buf tag literal everywhere and removed the "tag" field…

… from the location conf struct.
  • Loading branch information...
1 parent ec4becf commit 99b02286f72472a5b44040f20781ca7ab5ab06d5 @agentzh agentzh committed Feb 23, 2012
Showing with 15 additions and 24 deletions.
  1. +0 −2 src/ngx_http_lua_common.h
  2. +0 −1 src/ngx_http_lua_conf.c
  3. +12 −14 src/ngx_http_lua_req_body.c
  4. +1 −4 src/ngx_http_lua_socket.c
  5. +2 −3 src/ngx_http_lua_subrequest.c
@@ -89,8 +89,6 @@ typedef struct {
typedef struct {
- ngx_buf_tag_t tag;
-
ngx_flag_t force_read_body; /* whether force request body to
be read */
View
@@ -87,7 +87,6 @@ ngx_http_lua_create_loc_conf(ngx_conf_t *cf)
conf->force_read_body = NGX_CONF_UNSET;
conf->enable_code_cache = NGX_CONF_UNSET;
- conf->tag = (ngx_buf_tag_t) &ngx_http_lua_module;
conf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
conf->connect_timeout = NGX_CONF_UNSET_MSEC;
@@ -246,7 +246,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
ngx_int_t rc;
#endif
ngx_chain_t *cl;
- ngx_http_lua_loc_conf_t *llcf;
+ ngx_buf_tag_t tag;
n = lua_gettop(L);
@@ -280,6 +280,8 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
rb = r->request_body;
}
+ tag = (ngx_buf_tag_t) &ngx_http_lua_module;
+
tf = rb->temp_file;
if (tf) {
@@ -302,10 +304,8 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
if (rb->bufs) {
- llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
-
for (cl = rb->bufs; cl; cl = cl->next) {
- if (cl->buf->tag == llcf->tag && cl->buf->temporary) {
+ if (cl->buf->tag == tag && cl->buf->temporary) {
dd("free old request body buffer: size:%d",
(int) ngx_buf_size(cl->buf));
@@ -324,12 +324,10 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
goto set_header;
}
- llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
-
if (rb->bufs) {
for (cl = rb->bufs; cl; cl = cl->next) {
- if (cl->buf->tag == llcf->tag && cl->buf->temporary) {
+ if (cl->buf->tag == tag && cl->buf->temporary) {
dd("free old request body buffer: size:%d",
(int) ngx_buf_size(cl->buf));
@@ -346,7 +344,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
ngx_memzero(b, sizeof(ngx_buf_t));
b->temporary = 1;
- b->tag = llcf->tag;
+ b->tag = tag;
b->start = ngx_palloc(r->pool, body.len);
if (b->start == NULL) {
@@ -366,7 +364,7 @@ ngx_http_lua_ngx_req_set_body_data(lua_State *L)
rb->bufs->next = NULL;
b = ngx_create_temp_buf(r->pool, body.len);
- b->tag = llcf->tag;
+ b->tag = tag;
b->last = ngx_copy(b->pos, body.data, body.len);
rb->bufs->buf = b;
@@ -449,7 +447,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
ngx_pool_cleanup_file_t *clnf;
ngx_err_t err;
ngx_chain_t *cl;
- ngx_http_lua_loc_conf_t *llcf;
+ ngx_buf_tag_t tag;
n = lua_gettop(L);
@@ -495,13 +493,13 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
/* clean up existing r->request_body->bufs (if any) */
- llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
+ tag = (ngx_buf_tag_t) &ngx_http_lua_module;
if (rb->bufs) {
dd("XXX reusing buf");
for (cl = rb->bufs; cl; cl = cl->next) {
- if (cl->buf->tag == llcf->tag && cl->buf->temporary) {
+ if (cl->buf->tag == tag && cl->buf->temporary) {
dd("free old request body buffer: size:%d",
(int) ngx_buf_size(cl->buf));
@@ -516,7 +514,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
ngx_memzero(b, sizeof(ngx_buf_t));
- b->tag = llcf->tag;
+ b->tag = tag;
} else {
@@ -533,7 +531,7 @@ ngx_http_lua_ngx_req_set_body_file(lua_State *L)
return luaL_error(L, "out of memory");
}
- b->tag = llcf->tag;
+ b->tag = tag;
rb->bufs->buf = b;
rb->buf = b;
@@ -1778,7 +1778,6 @@ ngx_http_lua_socket_send(ngx_http_request_t *r,
ngx_int_t rc;
ngx_connection_t *c;
ngx_http_lua_ctx_t *ctx;
- ngx_http_lua_loc_conf_t *llcf;
c = u->peer.connection;
@@ -1828,15 +1827,13 @@ ngx_http_lua_socket_send(ngx_http_request_t *r,
return NGX_ERROR;
}
- llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
-
#if defined(nginx_version) && nginx_version >= 1001004
ngx_chain_update_chains(r->pool,
#else
ngx_chain_update_chains(
#endif
&ctx->free_bufs, &ctx->busy_bufs, &u->request_bufs,
- llcf->tag);
+ (ngx_buf_tag_t) &ngx_http_lua_module);
u->request_sent = 0;
u->write_event_handler = ngx_http_lua_socket_dummy_handler;
@@ -805,7 +805,6 @@ ngx_http_lua_post_subrequest(ngx_http_request_t *r, void *data, ngx_int_t rc)
ngx_str_t *body_str;
u_char *p;
ngx_chain_t *cl;
- ngx_http_lua_loc_conf_t *llcf;
if (ctx->run_post_subrequest) {
return rc;
@@ -907,15 +906,15 @@ ngx_http_lua_post_subrequest(ngx_http_request_t *r, void *data, ngx_int_t rc)
}
if (ctx->body) {
- llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
#if defined(nginx_version) && nginx_version >= 1001004
ngx_chain_update_chains(r->pool,
#else
ngx_chain_update_chains(
#endif
&pr_ctx->free_bufs, &pr_ctx->busy_bufs,
- &ctx->body, llcf->tag);
+ &ctx->body,
+ (ngx_buf_tag_t) &ngx_http_lua_module);
dd("free bufs: %p", pr_ctx->free_bufs);
}

0 comments on commit 99b0228

Please sign in to comment.