~spuul/nginx/trunk

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/src/ngx_http_lua_req_body.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:
80
80
        return luaL_error(L, "expecting 0 arguments but seen %d", n);
81
81
    }
82
82
 
83
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
84
 
    lua_rawget(L, LUA_GLOBALSINDEX);
85
 
    r = lua_touserdata(L, -1);
86
 
    lua_pop(L, 1);
87
 
 
 
83
    r = ngx_http_lua_get_req(L);
88
84
    if (r == NULL) {
89
85
        return luaL_error(L, "request object not found");
90
86
    }
146
142
                       "interruptions");
147
143
 
148
144
        ctx->waiting_more_body = 1;
149
 
        ctx->req_body_reader_co_ctx = coctx;
 
145
        ctx->downstream_co_ctx = coctx;
150
146
 
151
147
        coctx->cleanup = ngx_http_lua_req_body_cleanup;
152
148
        coctx->data = r;
179
175
    if (ctx->waiting_more_body) {
180
176
        ctx->waiting_more_body = 0;
181
177
 
182
 
        coctx = ctx->req_body_reader_co_ctx;
 
178
        coctx = ctx->downstream_co_ctx;
183
179
        ctx->cur_co_ctx = coctx;
184
180
 
185
181
        coctx->cleanup = NULL;
217
213
        return luaL_error(L, "expecting 0 arguments but seen %d", n);
218
214
    }
219
215
 
220
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
221
 
    lua_rawget(L, LUA_GLOBALSINDEX);
222
 
    r = lua_touserdata(L, -1);
223
 
    lua_pop(L, 1);
224
 
 
 
216
    r = ngx_http_lua_get_req(L);
225
217
    if (r == NULL) {
226
218
        return luaL_error(L, "request object not found");
227
219
    }
254
246
        return luaL_error(L, "expecting 0 arguments but seen %d", n);
255
247
    }
256
248
 
257
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
258
 
    lua_rawget(L, LUA_GLOBALSINDEX);
259
 
    r = lua_touserdata(L, -1);
260
 
    lua_pop(L, 1);
261
 
 
 
249
    r = ngx_http_lua_get_req(L);
262
250
    if (r == NULL) {
263
251
        return luaL_error(L, "request object not found");
264
252
    }
325
313
        return luaL_error(L, "expecting 0 arguments but seen %d", n);
326
314
    }
327
315
 
328
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
329
 
    lua_rawget(L, LUA_GLOBALSINDEX);
330
 
    r = lua_touserdata(L, -1);
331
 
    lua_pop(L, 1);
332
 
 
 
316
    r = ngx_http_lua_get_req(L);
333
317
    if (r == NULL) {
334
318
        return luaL_error(L, "request object not found");
335
319
    }
379
363
 
380
364
    body.data = (u_char *) luaL_checklstring(L, 1, &body.len);
381
365
 
382
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
383
 
    lua_rawget(L, LUA_GLOBALSINDEX);
384
 
    r = lua_touserdata(L, -1);
385
 
    lua_pop(L, 1);
386
 
 
 
366
    r = ngx_http_lua_get_req(L);
387
367
    if (r == NULL) {
388
368
        return luaL_error(L, "request object not found");
389
369
    }
546
526
        return luaL_error(L, "expecting 0 or 1 argument but seen %d", n);
547
527
    }
548
528
 
549
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
550
 
    lua_rawget(L, LUA_GLOBALSINDEX);
551
 
    r = lua_touserdata(L, -1);
552
 
    lua_pop(L, 1);
 
529
    r = ngx_http_lua_get_req(L);
 
530
    if (r == NULL) {
 
531
        return luaL_error(L, "no request found");
 
532
    }
553
533
 
554
534
    ngx_http_lua_check_fake_request(L, r);
555
535
 
578
558
 
579
559
        /* avoid allocating an unnecessary large buffer */
580
560
        if (size > (size_t) r->headers_in.content_length_n) {
581
 
            size = r->headers_in.content_length_n;
 
561
            size = (size_t) r->headers_in.content_length_n;
582
562
        }
583
563
    }
584
564
 
646
626
 
647
627
    body.data = (u_char *) luaL_checklstring(L, 1, &body.len);
648
628
 
649
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
650
 
    lua_rawget(L, LUA_GLOBALSINDEX);
651
 
    r = lua_touserdata(L, -1);
652
 
    lua_pop(L, 1);
 
629
    r = ngx_http_lua_get_req(L);
 
630
    if (r == NULL) {
 
631
        return luaL_error(L, "no request found");
 
632
    }
653
633
 
654
634
    ngx_http_lua_check_fake_request(L, r);
655
635
 
709
689
        return luaL_error(L, "expecting 0 argument but seen %d", n);
710
690
    }
711
691
 
712
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
713
 
    lua_rawget(L, LUA_GLOBALSINDEX);
714
 
    r = lua_touserdata(L, -1);
715
 
    lua_pop(L, 1);
716
 
 
 
692
    r = ngx_http_lua_get_req(L);
717
693
    if (r == NULL) {
718
 
        return luaL_error(L, "no request");
 
694
        return luaL_error(L, "no request found");
719
695
    }
720
696
 
721
697
    ngx_http_lua_check_fake_request(L, r);
762
738
        return luaL_error(L, "out of memory");
763
739
    }
764
740
 
765
 
    size = r->headers_in.content_length_n;
 
741
    size = (size_t) r->headers_in.content_length_n;
766
742
 
767
743
    value.len = ngx_sprintf(value.data, "%uz", size) - value.data;
768
744
    value.data[value.len] = '\0';
841
817
 
842
818
    p = (u_char *) luaL_checklstring(L, 1, &name.len);
843
819
 
844
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
845
 
    lua_rawget(L, LUA_GLOBALSINDEX);
846
 
    r = lua_touserdata(L, -1);
847
 
    lua_pop(L, 1);
848
 
 
 
820
    r = ngx_http_lua_get_req(L);
849
821
    if (r == NULL) {
850
 
        return luaL_error(L, "request object not found");
 
822
        return luaL_error(L, "no request found");
851
823
    }
852
824
 
853
825
    ngx_http_lua_check_fake_request(L, r);
904
876
        ngx_memzero(b, sizeof(ngx_buf_t));
905
877
 
906
878
        b->tag = tag;
 
879
        rb->buf = NULL;
907
880
 
908
881
    } else {
909
882
 
923
896
        b->tag = tag;
924
897
 
925
898
        rb->bufs->buf = b;
926
 
        rb->buf = b;
 
899
        rb->buf = NULL;
927
900
    }
928
901
 
929
902
    b->last_in_chain = 1;
963
936
 
964
937
    ngx_memzero(&of, sizeof(ngx_open_file_info_t));
965
938
 
 
939
    of.directio = NGX_OPEN_FILE_DIRECTIO_OFF;
 
940
 
966
941
    if (ngx_http_lua_open_and_stat_file(name.data, &of, r->connection->log)
967
942
        != NGX_OK)
968
943
    {
974
949
    tf->file.fd = of.fd;
975
950
    tf->file.name = name;
976
951
    tf->file.log = r->connection->log;
977
 
 
978
 
    /* FIXME we should not always set directio here */
979
 
    tf->file.directio = 1;
 
952
    tf->file.directio = 0;
980
953
 
981
954
    if (of.size == 0) {
982
955
        if (clean) {
1128
1101
static ngx_int_t
1129
1102
ngx_http_lua_read_body_resume(ngx_http_request_t *r)
1130
1103
{
 
1104
    lua_State                   *vm;
1131
1105
    ngx_int_t                    rc;
1132
1106
    ngx_connection_t            *c;
1133
1107
    ngx_http_lua_ctx_t          *ctx;
1134
 
    ngx_http_lua_main_conf_t    *lmcf;
1135
1108
 
1136
1109
    ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
1137
1110
 
1138
1111
    ctx->resume_handler = ngx_http_lua_wev_handler;
1139
1112
 
1140
 
    lmcf = ngx_http_get_module_main_conf(r, ngx_http_lua_module);
1141
 
 
1142
1113
    c = r->connection;
 
1114
    vm = ngx_http_lua_get_lua_vm(r, ctx);
1143
1115
 
1144
 
    rc = ngx_http_lua_run_thread(lmcf->lua, r, ctx, 0);
 
1116
    rc = ngx_http_lua_run_thread(vm, r, ctx, 0);
1145
1117
 
1146
1118
    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1147
1119
                   "lua run thread returned %d", rc);
1148
1120
 
1149
1121
    if (rc == NGX_AGAIN) {
1150
 
        return ngx_http_lua_run_posted_threads(c, lmcf->lua, r, ctx);
 
1122
        return ngx_http_lua_run_posted_threads(c, vm, r, ctx);
1151
1123
    }
1152
1124
 
1153
1125
    if (rc == NGX_DONE) {
1154
1126
        ngx_http_lua_finalize_request(r, NGX_DONE);
1155
 
        return ngx_http_lua_run_posted_threads(c, lmcf->lua, r, ctx);
 
1127
        return ngx_http_lua_run_posted_threads(c, vm, r, ctx);
1156
1128
    }
1157
1129
 
1158
1130
    if (ctx->entered_content_phase) {