From 75682f981d9016e1d17626770afc53d933409e9b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 22 Jul 2013 10:45:49 +0200 Subject: [PATCH] Add a threshold to httpbf before splitting the files --- modules/csync_owncloud.c | 9 ++++++++- modules/csync_owncloud.h | 1 + src/httpbf/src/httpbf.c | 5 +++++ src/httpbf/src/httpbf.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/csync_owncloud.c b/modules/csync_owncloud.c index 3edb381ee..7894c60ac 100644 --- a/modules/csync_owncloud.c +++ b/modules/csync_owncloud.c @@ -1200,7 +1200,10 @@ static int owncloud_sendfile(csync_vio_method_handle_t *src, csync_vio_method_ha Hbf_State state = HBF_SUCCESS; hbf_transfer_t *trans = hbf_init_transfer(clean_uri); if (dav_session.hbf_block_size > 0) { - trans->block_size = dav_session.hbf_block_size; + trans->threshold = trans->block_size = dav_session.hbf_block_size; + } + if (dav_session.hbf_threshold > 0) { + trans->threshold = dav_session.hbf_threshold; } finished = true; @@ -1756,6 +1759,10 @@ static int owncloud_set_property(const char *key, void *data) { dav_session.hbf_block_size = *(off_t*)(data); return 0; } + if( c_streq(key, "hbf_threshold")) { + dav_session.hbf_threshold = *(off_t*)(data); + return 0; + } return -1; } diff --git a/modules/csync_owncloud.h b/modules/csync_owncloud.h index ce776e652..d71fef872 100644 --- a/modules/csync_owncloud.h +++ b/modules/csync_owncloud.h @@ -152,6 +152,7 @@ struct dav_session_s { bool no_recursive_propfind; off_t hbf_block_size; + off_t hbf_threshold; }; extern struct dav_session_s dav_session; diff --git a/src/httpbf/src/httpbf.c b/src/httpbf/src/httpbf.c index 8fab931c9..3d4cf3ef1 100644 --- a/src/httpbf/src/httpbf.c +++ b/src/httpbf/src/httpbf.c @@ -87,6 +87,7 @@ hbf_transfer_t *hbf_init_transfer( const char *dest_uri ) { transfer->error_string = NULL; transfer->start_id = 0; transfer->block_size = DEFAULT_BLOCK_SIZE; + transfer->threshold = transfer->block_size; return transfer; } @@ -122,6 +123,10 @@ Hbf_State hbf_splitlist(hbf_transfer_t *transfer, int fd ) { /* calc the number of blocks to split in */ blk_size = transfer->block_size; + if (sb.st_size < transfer->threshold) { + blk_size = transfer->threshold; + } + num_blocks = sb.st_size / blk_size; /* there migth be a remainder. */ diff --git a/src/httpbf/src/httpbf.h b/src/httpbf/src/httpbf.h index 4418cdd66..b13d8916b 100644 --- a/src/httpbf/src/httpbf.h +++ b/src/httpbf/src/httpbf.h @@ -92,6 +92,7 @@ struct hbf_transfer_s { off_t stat_size; time_t modtime; off_t block_size; + off_t threshold; hbf_abort_callback abort_cb; #ifndef NDEBUG