Browse Source

make write more fair...until now it was written as long a possible given no chance for reading anymore...

release0.1.6
Georg Hopp 12 years ago
parent
commit
691673991c
  1. 2
      src/application/adapter/http/update.c
  2. 9
      src/http/writer/write.c

2
src/application/adapter/http/update.c

@ -184,13 +184,13 @@ applicationAdapterHttpUpdate(void * _this, void * subject)
session = applicationSessionGet(this->application, sid); session = applicationSessionGet(this->application, sid);
if (NULL == session) { if (NULL == session) {
session = applicationSessionStart(this->application); session = applicationSessionStart(this->application);
}
// send session cookie // send session cookie
nbuf = sprintf(buf, "sid=%s;Path=/", session->id); nbuf = sprintf(buf, "sid=%s;Path=/", session->id);
queuePut( queuePut(
worker->additional_headers, worker->additional_headers,
new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf)); new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));
}
if (0 == strcmp("POST", worker->current_request->method)) { if (0 == strcmp("POST", worker->current_request->method)) {
if (0 == strcmp("/login/", worker->current_request->path)) { if (0 == strcmp("/login/", worker->current_request->path)) {

9
src/http/writer/write.c

@ -37,15 +37,14 @@ ssize_t
httpWriterWrite(void * _this, Stream st) httpWriterWrite(void * _this, Stream st)
{ {
HttpWriter this = _this; HttpWriter this = _this;
int cont = 1;
while (cont) {
switch (this->state) { switch (this->state) {
char * start; char * start;
ssize_t to_write; ssize_t to_write;
ssize_t written; ssize_t written;
case HTTP_WRITER_GET: case HTTP_WRITER_GET:
if (! queueEmpty(this->queue)) { if (! queueEmpty(this->queue)) {
this->current = queueGet(this->queue); this->current = queueGet(this->queue);
@ -82,11 +81,11 @@ httpWriterWrite(void * _this, Stream st)
this->state = HTTP_WRITER_WRITE; this->state = HTTP_WRITER_WRITE;
} }
else { else {
cont = 0;
break; break;
} }
case HTTP_WRITER_WRITE: case HTTP_WRITER_WRITE:
if (this->written >= this->nbuffer) { if (this->written >= this->nbuffer) {
size_t body_done = this->written - this->nheader; size_t body_done = this->written - this->nheader;
@ -117,7 +116,6 @@ httpWriterWrite(void * _this, Stream st)
* By the way, the same is true for reading, * By the way, the same is true for reading,
* so to say, the parser. * so to say, the parser.
*/ */
cont = 0;
break; break;
} }
@ -129,6 +127,7 @@ httpWriterWrite(void * _this, Stream st)
} }
case HTTP_WRITER_DONE: case HTTP_WRITER_DONE:
this->state = HTTP_WRITER_GET; this->state = HTTP_WRITER_GET;
if (! httpMessageHasKeepAlive(this->current)) { if (! httpMessageHasKeepAlive(this->current)) {
@ -139,13 +138,13 @@ httpWriterWrite(void * _this, Stream st)
* underlying connection should be closed at their side. * underlying connection should be closed at their side.
* Then we close to connection. * Then we close to connection.
*/ */
delete(this->current);
return -2; return -2;
} }
delete(this->current); delete(this->current);
break; break;
} }
}
return NULL == this->current ? return NULL == this->current ?
this->queue->nmsg : this->queue->nmsg :

Loading…
Cancel
Save