diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-08-08 12:29:28 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-08-08 12:29:28 +0000 |
commit | 341b9db92e91d9ddcf8230a0329c52e319bdee1f (patch) | |
tree | 6bf118a931356311a70171841730e7d1877c7b9a /src | |
parent | 95d084fa6ad9dbd7d40d03d1310af1229553c71f (diff) | |
download | libmicrohttpd-341b9db92e91d9ddcf8230a0329c52e319bdee1f.tar.gz libmicrohttpd-341b9db92e91d9ddcf8230a0329c52e319bdee1f.zip |
connection.c: try_ready_chunked_body(): refactoring for optimization and clarity
Diffstat (limited to 'src')
-rw-r--r-- | src/microhttpd/connection.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 5a4e44a3..0933a7f7 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -429,7 +429,9 @@ try_ready_chunked_body (struct MHD_Connection *connection) | |||
429 | connection->write_buffer = buf; | 429 | connection->write_buffer = buf; |
430 | } | 430 | } |
431 | 431 | ||
432 | if ( (response->data_start <= | 432 | if (0 == response->total_size) |
433 | ret = 0; /* response must be empty, don't bother calling crc */ | ||
434 | else if ( (response->data_start <= | ||
433 | connection->response_write_position) && | 435 | connection->response_write_position) && |
434 | (response->data_size + response->data_start > | 436 | (response->data_size + response->data_start > |
435 | connection->response_write_position) ) | 437 | connection->response_write_position) ) |
@@ -446,13 +448,10 @@ try_ready_chunked_body (struct MHD_Connection *connection) | |||
446 | else | 448 | else |
447 | { | 449 | { |
448 | /* buffer not in range, try to fill it */ | 450 | /* buffer not in range, try to fill it */ |
449 | if (0 == response->total_size) | 451 | ret = response->crc (response->crc_cls, |
450 | ret = 0; /* response must be empty, don't bother calling crc */ | 452 | connection->response_write_position, |
451 | else | 453 | &connection->write_buffer[sizeof (cbuf)], |
452 | ret = response->crc (response->crc_cls, | 454 | connection->write_buffer_size - sizeof (cbuf) - 2); |
453 | connection->response_write_position, | ||
454 | &connection->write_buffer[sizeof (cbuf)], | ||
455 | connection->write_buffer_size - sizeof (cbuf) - 2); | ||
456 | } | 455 | } |
457 | if ( ((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) | 456 | if ( ((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) |
458 | { | 457 | { |