Add a threshold to httpbf before splitting the files

This commit is contained in:
Olivier Goffart 2013-07-22 10:45:49 +02:00 committed by Klaas Freitag
parent 7a8b07443f
commit 75682f981d
4 changed files with 15 additions and 1 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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. */

View file

@ -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