Add configuration option max_upload_attempts
This commit is contained in:
@ -126,8 +126,6 @@ static const char* const type[] = {
|
||||
[END] = NULL
|
||||
};
|
||||
|
||||
#define MAX_UPLOAD_ATTEMPTS 20
|
||||
|
||||
|
||||
/* Private global variables */
|
||||
/*==========================*/
|
||||
@ -180,6 +178,9 @@ static time_t min_retry;
|
||||
/* Maximum retry time. */
|
||||
static time_t max_retry;
|
||||
|
||||
/* Maximum number of upload attempts. */
|
||||
static int max_upload_attempts;
|
||||
|
||||
/* Refresh locks this much seconds before they time out. */
|
||||
static time_t lock_refresh;
|
||||
|
||||
@ -309,7 +310,7 @@ set_next_upload_attempt(dav_node *node)
|
||||
item = item->next;
|
||||
if (!item) return 0;
|
||||
item->attempts++;
|
||||
if (item->attempts > MAX_UPLOAD_ATTEMPTS)
|
||||
if (item->attempts > max_upload_attempts)
|
||||
return -1;
|
||||
time_t delay = item->attempts * min_retry;
|
||||
item->save_at += (delay > max_retry) ? max_retry : delay;
|
||||
@ -606,6 +607,7 @@ dav_init_cache(const dav_args *args, const char *mpoint)
|
||||
retry = dir_refresh;
|
||||
min_retry = args->retry;
|
||||
max_retry = args->max_retry;
|
||||
max_upload_attempts = args->max_upload_attempts;
|
||||
lock_refresh = args->lock_refresh;
|
||||
|
||||
fs_stat = (dav_stat *) malloc(sizeof(dav_stat));
|
||||
|
@ -161,15 +161,20 @@
|
||||
May be overridden by system config file and user config file. */
|
||||
#define DAV_READ_TIMEOUT 30
|
||||
|
||||
/* Default retry time after a PROPFIND request failed. When the request fails
|
||||
/* Default retry time after a HTTP request failed. When the request fails
|
||||
again, the retry time will subsequently be increased up to DAV_MAX_RETRY.
|
||||
May be overridden by system config file and user config file. */
|
||||
#define DAV_RETRY 30
|
||||
|
||||
/* Maximum retry time after a PROPFIND request failed.
|
||||
/* Maximum retry time after a HTTP request failed.
|
||||
May be overridden by system config file and user config file. */
|
||||
#define DAV_MAX_RETRY 300
|
||||
|
||||
/* Maximum Number of attempts made to upoad a changed file before it is
|
||||
moved into the lost+found directory.
|
||||
May be overridden by system config file and user config file. */
|
||||
#define DAV_MAX_UPLOAD_ATTEMPTS 15
|
||||
|
||||
/* Preferred live time of locks in seconds, before they have to be refreshed.
|
||||
May be overridden by system config file and user config file. */
|
||||
#define DAV_LOCK_TIMEOUT 1800
|
||||
|
@ -1753,6 +1753,7 @@ new_args(void)
|
||||
args->read_timeout = DAV_READ_TIMEOUT;
|
||||
args->retry = DAV_RETRY;
|
||||
args->max_retry = DAV_MAX_RETRY;
|
||||
args->max_upload_attempts = DAV_MAX_UPLOAD_ATTEMPTS;
|
||||
args->s_charset = NULL;
|
||||
args->header = NULL;
|
||||
|
||||
@ -2194,6 +2195,8 @@ read_config(dav_args *args, const char * filename, int system)
|
||||
args->retry = arg_to_int(parmv[1], 10, parmv[0]);
|
||||
} else if (strcmp(parmv[0], "max_retry") == 0) {
|
||||
args->max_retry = arg_to_int(parmv[1], 10, parmv[0]);
|
||||
} else if (strcmp(parmv[0], "max_upload_attempts") == 0) {
|
||||
args->max_upload_attempts = arg_to_int(parmv[1], 10, parmv[0]);
|
||||
} else if (strcmp(parmv[0], "server_charset") == 0) {
|
||||
if (args->s_charset)
|
||||
free(args->s_charset);
|
||||
|
@ -81,6 +81,7 @@ typedef struct {
|
||||
time_t read_timeout; /* User config file, system config file */
|
||||
time_t retry; /* User config file, system config file */
|
||||
time_t max_retry; /* User config file, system config file */
|
||||
int max_upload_attempts; /* User config file, system config file */
|
||||
char * s_charset; /* User config file, system config file */
|
||||
char * header; /* User config file, system config file */
|
||||
/* Cache */
|
||||
|
Reference in New Issue
Block a user