added command line option to change the number of the maximum number of network connection allowed

This commit is contained in:
Fufu Fang 2019-04-26 11:27:39 +01:00
parent 33ace8e120
commit f4fd419528
2 changed files with 17 additions and 11 deletions

View File

@ -143,6 +143,7 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
{"proxy-password", required_argument, NULL, 'L'}, /* 7 */
{"cache", required_argument, NULL, 'L'}, /* 8 */
{"dl-seg-size", required_argument, NULL, 'L'}, /* 9 */
{"max-conns", required_argument, NULL, 'L'}, /* 10 */
{0, 0, 0, 0}
};
while ((c =
@ -197,6 +198,9 @@ parse_arg_list(int argc, char **argv, char ***fuse_argv, int *fuse_argc)
case 9:
DATA_BLK_SZ = atoi(optarg) * 1024 * 1024;
break;
case 10:
NETWORK_CONFIG.max_conns = atoi(optarg);
break;
default:
fprintf(stderr, "Error: Invalid option\n");
add_arg(fuse_argv, fuse_argc, "--help");
@ -243,15 +247,17 @@ static void print_http_options()
{
fprintf(stderr,
"HTTP options:\n\
-u --username HTTP authentication username\n\
-p --password HTTP authentication password\n\
-P --proxy Proxy for libcurl, for more details refer to\n\
https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html\n\
--proxy-username Username for the proxy\n\
--proxy-password Password for the proxy\n\
--cache Set the cache folder\n\
--dl-seg-size Set the size of each download segment in MB, \n\
default to 8MB\n\
-u --username HTTP authentication username\n\
-p --password HTTP authentication password\n\
-P --proxy Proxy for libcurl, for more details refer to\n\
https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html\n\
--proxy-username Username for the proxy\n\
--proxy-password Password for the proxy\n\
--cache Set the cache folder\n\
--dl-seg-size Set the size of each download segment in MB, \n\
default to 8MB\n\
--max-conns The maximum number of network connections that\
libcurl is allowed to make.\
\n\
libfuse options:\n");
}

View File

@ -8,7 +8,7 @@
#include <stdio.h>
#include <unistd.h>
#define NETWORK_MAX_CONNS 10
#define DEFAULT_NETWORK_MAX_CONNS 10
/* ----------------- External variables ---------------------- */
CURLSH *CURL_SHARE;
@ -205,7 +205,7 @@ void network_config_init()
NETWORK_CONFIG.proxy = NULL;
NETWORK_CONFIG.proxy_user = NULL;
NETWORK_CONFIG.proxy_pass = NULL;
NETWORK_CONFIG.max_conns = NETWORK_MAX_CONNS;
NETWORK_CONFIG.max_conns = DEFAULT_NETWORK_MAX_CONNS;
}
LinkTable *network_init(const char *url)