~ubuntu-branches/ubuntu/quantal/nginx/quantal-updates

« 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): Kartik Mistry, Kartik Mistry
  • Date: 2011-09-26 10:17:04 UTC
  • mfrom: (4.2.38 sid)
  • Revision ID: package-import@ubuntu.com-20110926101704-x8pxngiujrmkxnn3
Tags: 1.1.4-2
[Kartik Mistry]
* debian/modules:
  + Updated nginx-upload-progress module, Thanks to upstream for fixing issue
    that FTBFS nginx on kFreeBSD-* archs.
  + Updated nginx-lua module to latest upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
#define DDEBUG 0
4
4
 
5
 
#include "nginx.h"
 
5
#include <nginx.h>
6
6
#include "ngx_http_lua_rewriteby.h"
7
7
#include "ngx_http_lua_util.h"
8
 
#include "ngx_http_lua_hook.h"
 
8
#include "ngx_http_lua_exception.h"
9
9
#include "ngx_http_lua_cache.h"
10
10
 
11
11
 
22
22
 
23
23
    if (cc == NULL) {
24
24
        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
25
 
                "(lua-content-by-chunk) failed to create new coroutine "
26
 
                "to handle request");
 
25
                "lua: failed to create new coroutine to handle request");
27
26
 
28
27
        return NGX_HTTP_INTERNAL_SERVER_ERROR;
29
28
    }
108
107
 
109
108
    /*  load Lua script file (w/ cache)        sp = 1 */
110
109
    rc = ngx_http_lua_cache_loadfile(L, script_path, llcf->rewrite_src_key,
111
 
            &err, llcf->enable_code_cache);
 
110
            &err, llcf->enable_code_cache ? 1 : 0);
112
111
 
113
112
    if (rc != NGX_OK) {
114
113
        if (err == NULL) {
130
129
        return rc;
131
130
    }
132
131
 
 
132
    if (rc == NGX_AGAIN) {
 
133
        return NGX_DONE;
 
134
    }
 
135
 
133
136
    if (rc == NGX_DONE) {
134
 
        return NGX_DONE;
 
137
        return NGX_OK;
135
138
    }
136
139
 
137
 
    if (rc == NGX_AGAIN) {
138
 
        return NGX_DONE;
 
140
    if (rc >= NGX_HTTP_OK && rc < NGX_HTTP_SPECIAL_RESPONSE) {
 
141
        return rc;
139
142
    }
140
143
 
141
144
    return NGX_DECLINED;
150
153
    ngx_int_t                    rc;
151
154
    ngx_http_lua_main_conf_t    *lmcf;
152
155
 
153
 
    dd("in rewrite handler: %.*s", (int) r->uri.len, r->uri.data);
 
156
    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
 
157
            "lua rewrite handler, uri \"%V\"", &r->uri);
154
158
 
155
159
    lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module);
156
160
 
211
215
        dd("setting new ctx: ctx = %p", ctx);
212
216
 
213
217
        ctx->cc_ref = LUA_NOREF;
 
218
        ctx->ctx_ref = LUA_NOREF;
214
219
 
215
220
        ngx_http_set_ctx(r, ctx, ngx_http_lua_module);
216
221
    }
218
223
    dd("entered? %d", (int) ctx->entered_rewrite_phase);
219
224
 
220
225
    if (ctx->waiting_more_body) {
221
 
        return NGX_DECLINED;
 
226
        return NGX_DONE;
222
227
    }
223
228
 
224
229
    if (ctx->entered_rewrite_phase) {
225
 
        dd("calling wev handler");
 
230
        dd("rewriteby: calling wev handler");
226
231
        rc = ngx_http_lua_wev_handler(r);
227
 
        dd("wev handler returns %d", (int) rc);
 
232
        dd("rewriteby: wev handler returns %d", (int) rc);
228
233
        return rc;
229
234
    }
230
235
 
269
274
    /*  load Lua inline script (w/ cache) sp = 1 */
270
275
    rc = ngx_http_lua_cache_loadbuffer(L, llcf->rewrite_src.value.data,
271
276
            llcf->rewrite_src.value.len, llcf->rewrite_src_key,
272
 
            "rewrite_by_lua", &err, llcf->enable_code_cache);
 
277
            "rewrite_by_lua", &err, llcf->enable_code_cache ? 1 : 0);
273
278
 
274
279
    if (rc != NGX_OK) {
275
280
        if (err == NULL) {
290
295
        return rc;
291
296
    }
292
297
 
 
298
    if (rc == NGX_AGAIN) {
 
299
        return NGX_DONE;
 
300
    }
 
301
 
293
302
    if (rc == NGX_DONE) {
294
 
        return NGX_DONE;
295
 
    }
296
 
 
297
 
    if (rc == NGX_AGAIN) {
298
 
        return NGX_DONE;
299
 
    }
 
303
        return NGX_OK;
 
304
    }
 
305
 
 
306
    if (rc >= NGX_HTTP_OK && rc < NGX_HTTP_SPECIAL_RESPONSE) {
 
307
        return rc;
 
308
    }
 
309
 
 
310
    dd("returning declined...");
300
311
 
301
312
    return NGX_DECLINED;
302
313
}