~spuul/nginx/trunk

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/src/ngx_http_lua_rewriteby.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-02-15 03:05:42 UTC
  • mfrom: (4.3.10 sid)
  • Revision ID: package-import@ubuntu.com-20140215030542-71ubtowl24vf7nfn
Tags: 1.4.5-1ubuntu1
* Resynchronise with Debian (LP: #1280511).  Remaining changes:
  - debian/patches/ubuntu-branding.patch:
    + Add Ubuntu branding to server_tokens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
146
146
{
147
147
    lua_State                   *L;
148
148
    ngx_int_t                    rc;
149
 
    ngx_http_lua_main_conf_t    *lmcf;
150
149
    ngx_http_lua_loc_conf_t     *llcf;
151
 
    char                        *err;
152
150
 
153
151
    dd("rewrite by lua inline");
154
152
 
155
153
    llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
156
 
    lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module);
157
 
 
158
 
    L = lmcf->lua;
 
154
    L = ngx_http_lua_get_lua_vm(r, NULL);
159
155
 
160
156
    /*  load Lua inline script (w/ cache) sp = 1 */
161
157
    rc = ngx_http_lua_cache_loadbuffer(L, llcf->rewrite_src.value.data,
162
158
                                       llcf->rewrite_src.value.len,
163
159
                                       llcf->rewrite_src_key,
164
 
                                       "rewrite_by_lua", &err,
165
 
                                       llcf->enable_code_cache ? 1 : 0);
166
 
 
 
160
                                       "rewrite_by_lua");
167
161
    if (rc != NGX_OK) {
168
 
        if (err == NULL) {
169
 
            err = "unknown error";
170
 
        }
171
 
 
172
 
        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
173
 
                      "failed to load Lua inlined code: %s", err);
174
 
 
175
162
        return NGX_HTTP_INTERNAL_SERVER_ERROR;
176
163
    }
177
164
 
185
172
    lua_State                       *L;
186
173
    ngx_int_t                        rc;
187
174
    u_char                          *script_path;
188
 
    ngx_http_lua_main_conf_t        *lmcf;
189
175
    ngx_http_lua_loc_conf_t         *llcf;
190
 
    char                            *err;
191
176
    ngx_str_t                        eval_src;
192
177
 
193
178
    llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
203
188
        return NGX_ERROR;
204
189
    }
205
190
 
206
 
    lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module);
207
 
    L = lmcf->lua;
 
191
    L = ngx_http_lua_get_lua_vm(r, NULL);
208
192
 
209
193
    /*  load Lua script file (w/ cache)        sp = 1 */
210
 
    rc = ngx_http_lua_cache_loadfile(L, script_path, llcf->rewrite_src_key,
211
 
                                     &err, llcf->enable_code_cache ? 1 : 0);
212
 
 
 
194
    rc = ngx_http_lua_cache_loadfile(L, script_path, llcf->rewrite_src_key);
213
195
    if (rc != NGX_OK) {
214
 
        if (err == NULL) {
215
 
            err = "unknown error";
216
 
        }
217
 
 
218
 
        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
219
 
                      "failed to load Lua file code: %s", err);
220
 
 
221
196
        return NGX_HTTP_INTERNAL_SERVER_ERROR;
222
197
    }
223
198
 
255
230
    lua_setfenv(co, -2);
256
231
 
257
232
    /*  save nginx request in coroutine globals table */
258
 
    lua_pushlightuserdata(co, &ngx_http_lua_request_key);
259
 
    lua_pushlightuserdata(co, r);
260
 
    lua_rawset(co, LUA_GLOBALSINDEX);
261
 
    /*  }}} */
 
233
    ngx_http_lua_set_req(co, r);
262
234
 
263
235
    /*  {{{ initialize request context */
264
236
    ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
286
258
            return NGX_HTTP_INTERNAL_SERVER_ERROR;
287
259
        }
288
260
 
289
 
        cln->handler = ngx_http_lua_request_cleanup;
290
 
        cln->data = r;
 
261
        cln->handler = ngx_http_lua_request_cleanup_handler;
 
262
        cln->data = ctx;
291
263
        ctx->cleanup = &cln->handler;
292
264
    }
293
265
    /*  }}} */