2
0
Fork 0

Don't block fastcgi if limit on input queue is hit

personal/stbuehler/wip
Stefan Bühler 2009-03-11 21:16:30 +01:00
parent d696e0e0f7
commit 12b421b9a9
4 changed files with 19 additions and 3 deletions

View File

@ -113,7 +113,6 @@ LI_API void cqlimit_acquire(cqlimit *cql);
LI_API void cqlimit_release(cqlimit *cql);
LI_API void cqlimit_set_limit(cqlimit *cql, goffset limit);
/******************
* chunkqueue *
******************/
@ -124,6 +123,8 @@ LI_API void chunkqueue_free(chunkqueue *cq);
LI_API void chunkqueue_use_limit(chunkqueue *cq, vrequest *vr);
LI_API void chunkqueue_set_limit(chunkqueue *cq, cqlimit* cql);
/* return -1 for unlimited, 0 for full and n > 0 for n bytes free */
LI_API goffset chunkqueue_limit_available(chunkqueue *cq);
/* pass ownership of str to chunkqueue, do not free/modify it afterwards
* you may modify the data (not the length) if you are sure it isn't sent before.

View File

@ -454,6 +454,17 @@ void chunkqueue_set_limit(chunkqueue *cq, cqlimit* cql) {
if (upd_limit) cqlimit_update(cq, memusage);
}
/* return -1 for unlimited, 0 for full and n > 0 for n bytes free */
goffset chunkqueue_limit_available(chunkqueue *cq) {
cqlimit *cql = cq->limit;
goffset avail;
if (!cql) return -1;
if (cql->limit <= 0) return -1;
avail = cql->limit - cql->current;
if (avail < 0) return 0;
return avail;
}
/* pass ownership of str to chunkqueue, do not free/modify it afterwards
* you may modify the data (not the length) if you are sure it isn't sent before.
*/

View File

@ -498,4 +498,4 @@ LI_API gboolean mod_accesslog_free(modules *mods, module *mod) {
plugin_free(mods->main, mod->config);
return TRUE;
}
}

View File

@ -653,7 +653,11 @@ static handler_t fastcgi_statemachine(vrequest *vr, fastcgi_connection *fcon) {
switch (fcon->state) {
case FS_WAIT_FOR_REQUEST:
if (-1 == vr->request.content_length || vr->request.content_length != vr->in->length) return HANDLER_GO_ON;
/* wait until we have either all data or the cqlimit is full */
if (-1 == vr->request.content_length || vr->request.content_length != vr->in->length) {
if (0 != chunkqueue_limit_available(vr->in))
return HANDLER_GO_ON;
}
fcon->state = FS_CONNECT;
/* fall through */