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);
if (NULL == session) {
session = applicationSessionStart(this->application);
}
// send session cookie
nbuf = sprintf(buf, "sid=%s;Path=/", session->id);
queuePut(
worker->additional_headers,
new(HttpHeader, CSTRA("Set-Cookie"), buf, nbuf));
}
if (0 == strcmp("POST", worker->current_request->method)) {
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)
{
HttpWriter this = _this;
int cont = 1;
while (cont) {
switch (this->state) {
char * start;
ssize_t to_write;
ssize_t written;
case HTTP_WRITER_GET:
if (! queueEmpty(this->queue)) {
this->current = queueGet(this->queue);
@ -82,11 +81,11 @@ httpWriterWrite(void * _this, Stream st)
this->state = HTTP_WRITER_WRITE;
}
else {
cont = 0;
break;
}
case HTTP_WRITER_WRITE:
if (this->written >= this->nbuffer) {
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,
* so to say, the parser.
*/
cont = 0;
break;
}
@ -129,6 +127,7 @@ httpWriterWrite(void * _this, Stream st)
}
case HTTP_WRITER_DONE:
this->state = HTTP_WRITER_GET;
if (! httpMessageHasKeepAlive(this->current)) {
@ -139,13 +138,13 @@ httpWriterWrite(void * _this, Stream st)
* underlying connection should be closed at their side.
* Then we close to connection.
*/
delete(this->current);
return -2;
}
delete(this->current);
break;
}
}
return NULL == this->current ?
this->queue->nmsg :

Loading…
Cancel
Save