~spuul/nginx/trunk

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Christos Trochalakis, Christos Trochalakis
  • Date: 2014-02-13 11:41:49 UTC
  • mfrom: (1.3.32)
  • mto: This revision was merged to the branch mainline in revision 72.
  • Revision ID: package-import@ubuntu.com-20140213114149-tkp78c45rzu3wr6y
Tags: 1.4.5-1
[ Christos Trochalakis ]
* New upstream release.
* debian/modules/nginx-lua:
  + Update nginx-lua to v0.9.4
* debian/nginx-naxsi-ui.preinst:
  + Fix exit status issue (Closes: #735152)
* debian/control:
  + Fix arch:all to arch:any dependencies
  + Make nginx depend on specific flavor version
* debian/nginx-*.postinst:
  + Make nginx start by default (Closes: #735551)
* debian/nginx-*.prerm:
  + No need to check for invoke-rc.d,
    correctly set the exit code on error
* debian/nginx-common.nginx.init:
  + Rewrite some parts of the initscript
  + Introduce rotate command
  + Introduce upgrade command

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
ngx_http_lua_inject_uthread_api(ngx_log_t *log, lua_State *L)
31
31
{
32
32
    /* new thread table */
33
 
    lua_newtable(L);
 
33
    lua_createtable(L, 0 /* narr */, 2 /* nrec */);
34
34
 
35
35
    lua_pushcfunction(L, ngx_http_lua_uthread_spawn);
36
36
    lua_setfield(L, -2, "spawn");
52
52
 
53
53
    n = lua_gettop(L);
54
54
 
55
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
56
 
    lua_rawget(L, LUA_GLOBALSINDEX);
57
 
    r = lua_touserdata(L, -1);
58
 
    lua_pop(L, 1);
59
 
 
 
55
    r = ngx_http_lua_get_req(L);
60
56
    if (r == NULL) {
61
57
        return luaL_error(L, "no request found");
62
58
    }
111
107
    ngx_http_lua_ctx_t          *ctx;
112
108
    ngx_http_lua_co_ctx_t       *coctx, *sub_coctx;
113
109
 
114
 
    lua_pushlightuserdata(L, &ngx_http_lua_request_key);
115
 
    lua_rawget(L, LUA_GLOBALSINDEX);
116
 
    r = lua_touserdata(L, -1);
117
 
    lua_pop(L, 1);
118
 
 
 
110
    r = ngx_http_lua_get_req(L);
119
111
    if (r == NULL) {
120
112
        return luaL_error(L, "no request found");
121
113
    }
141
133
 
142
134
        sub_coctx = ngx_http_lua_get_co_ctx(sub_co, ctx);
143
135
        if (sub_coctx == NULL) {
144
 
            return luaL_error(L, "no co ctx found for the ngx.thread "
145
 
                              "instance given");
 
136
            return luaL_error(L, "no co ctx found");
146
137
        }
147
138
 
148
139
        if (!sub_coctx->is_uthread) {
162
153
 
163
154
            nrets = lua_gettop(sub_coctx->co);
164
155
 
165
 
            dd("child retval count: %d, %s: %s", n,
166
 
                    luaL_typename(sub_coctx->co, -1),
167
 
                    lua_tostring(sub_coctx->co, -1));
 
156
            dd("child retval count: %d, %s: %s", (int) nrets,
 
157
               luaL_typename(sub_coctx->co, -1),
 
158
               lua_tostring(sub_coctx->co, -1));
168
159
 
169
160
            if (nrets) {
170
161
                lua_xmove(sub_coctx->co, L, nrets);
177
168
 
178
169
            return nrets;
179
170
 
 
171
        case NGX_HTTP_LUA_CO_DEAD:
 
172
            dd("uthread already waited: %p (parent %p)", sub_coctx,
 
173
               coctx);
 
174
 
 
175
            if (i < nargs) {
 
176
                /* just ignore it if it is not the last one */
 
177
                continue;
 
178
            }
 
179
 
 
180
            /* being the last one */
 
181
            lua_pushnil(L);
 
182
            lua_pushliteral(L, "already waited");
 
183
            return 2;
 
184
 
180
185
        default:
181
 
            /* still alive */
 
186
            dd("uthread %p still alive, status: %d, parent %p", sub_coctx,
 
187
               sub_coctx->co_status, coctx);
182
188
            break;
183
189
        }
184
190