summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2016-12-24 07:19:26 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2017-01-31 14:36:15 -0500
commit82feb705880d8f7c42118224be403dbfe6bf8d1c (patch)
treeb802d097f5d5a722b979534af95514ee1b6c63e6 /src/network.c
parentafce434e0b0ee517fef06cf32d3f9de25ceddc14 (diff)
downloadlighttpd1.4-82feb705880d8f7c42118224be403dbfe6bf8d1c.tar.gz
lighttpd1.4-82feb705880d8f7c42118224be403dbfe6bf8d1c.zip
[core] move con throttling to connections-glue.c
move write throttling code from network.c:network_write_chunkqueue() to connections-glue.c:connection_write_chunkqueue() and fix the code to use TCP_CORK only on TCP sockets.
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c65
1 files changed, 0 insertions, 65 deletions
diff --git a/src/network.c b/src/network.c
index 0e5725c8..9afd5f88 100644
--- a/src/network.c
+++ b/src/network.c
@@ -591,68 +591,3 @@ int network_register_fdevents(server *srv) {
}
return 0;
}
-
-int network_write_chunkqueue(server *srv, connection *con, chunkqueue *cq, off_t max_bytes) {
- int ret = -1;
- off_t written = 0;
-#ifdef TCP_CORK
- int corked = 0;
-#endif
-
- if (con->conf.global_kbytes_per_second) {
- off_t limit = con->conf.global_kbytes_per_second * 1024 - *(con->conf.global_bytes_per_second_cnt_ptr);
- if (limit <= 0) {
- /* we reached the global traffic limit */
- con->traffic_limit_reached = 1;
-
- return 1;
- } else {
- if (max_bytes > limit) max_bytes = limit;
- }
- }
-
- if (con->conf.kbytes_per_second) {
- off_t limit = con->conf.kbytes_per_second * 1024 - con->bytes_written_cur_second;
- if (limit <= 0) {
- /* we reached the traffic limit */
- con->traffic_limit_reached = 1;
-
- return 1;
- } else {
- if (max_bytes > limit) max_bytes = limit;
- }
- }
-
- written = cq->bytes_out;
-
-#ifdef TCP_CORK
- /* Linux: put a cork into the socket as we want to combine the write() calls
- * but only if we really have multiple chunks
- */
- if (cq->first && cq->first->next) {
- corked = 1;
- (void)setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked));
- }
-#endif
-
- ret = con->network_write(srv, con, cq, max_bytes);
- if (ret >= 0) {
- chunkqueue_remove_finished_chunks(cq);
- ret = chunkqueue_is_empty(cq) ? 0 : 1;
- }
-
-#ifdef TCP_CORK
- if (corked) {
- corked = 0;
- (void)setsockopt(con->fd, IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked));
- }
-#endif
-
- written = cq->bytes_out - written;
- con->bytes_written += written;
- con->bytes_written_cur_second += written;
-
- *(con->conf.global_bytes_per_second_cnt_ptr) += written;
-
- return ret;
-}