prunratelimited => prun with throttling
This commit is contained in:
parent
0c55d738d4
commit
2c8d978c72
|
|
@ -35,16 +35,16 @@
|
|||
#include <string.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "plocalnotify.h"
|
||||
#include "pfile.h"
|
||||
#include "pfoldersync.h"
|
||||
#include "plibs.h"
|
||||
#include "prun.h"
|
||||
#include "plist.h"
|
||||
#include "plocalscan.h"
|
||||
#include "psettings.h"
|
||||
|
||||
#define NOTIFY_MSG_ADD 0
|
||||
#define NOTIFY_MSG_DEL 1
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
#include "plocalnotify.h"
|
||||
#include "plocalscan.h"
|
||||
#include "ppathstatus.h"
|
||||
#include "prunratelimit.h"
|
||||
#include "prunthrottled.h"
|
||||
#include "psettings.h"
|
||||
#include "pssl.h"
|
||||
#include "pstatus.h"
|
||||
|
|
@ -1234,7 +1234,7 @@ static void psync_do_wake_localscan() {
|
|||
}
|
||||
|
||||
void psync_wake_localscan() {
|
||||
psync_run_ratelimited("wake localscan", psync_do_wake_localscan,
|
||||
prun_throttled("wake localscan", psync_do_wake_localscan,
|
||||
PSYNC_LOCALSCAN_MIN_INTERVAL, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
DAMAGE.
|
||||
*/
|
||||
|
||||
#include "prunratelimit.h"
|
||||
#include "prunthrottled.h"
|
||||
#include "plibs.h"
|
||||
#include "ptimer.h"
|
||||
#include "ptree.h"
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
typedef struct {
|
||||
psync_tree tree;
|
||||
psync_run_ratelimit_callback0 call;
|
||||
prun_throttle_cb call;
|
||||
const char *name;
|
||||
unsigned char scheduled;
|
||||
} psync_rr_tree_node;
|
||||
|
|
@ -46,10 +46,10 @@ typedef struct {
|
|||
static pthread_mutex_t task_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static psync_tree *tasks = PSYNC_TREE_EMPTY;
|
||||
|
||||
static void psync_run_ratelimited_timer(psync_timer_t timer, void *ptr) {
|
||||
static void ratelimit_timer(psync_timer_t timer, void *ptr) {
|
||||
psync_rr_tree_node *node;
|
||||
const char *name;
|
||||
psync_run_ratelimit_callback0 call;
|
||||
prun_throttle_cb call;
|
||||
int run;
|
||||
node = (psync_rr_tree_node *)ptr;
|
||||
pthread_mutex_lock(&task_mutex);
|
||||
|
|
@ -72,7 +72,7 @@ static void psync_run_ratelimited_timer(psync_timer_t timer, void *ptr) {
|
|||
}
|
||||
}
|
||||
|
||||
void psync_run_ratelimited(const char *name, psync_run_ratelimit_callback0 call,
|
||||
void prun_throttled(const char *name, prun_throttle_cb call,
|
||||
uint32_t minintervalsec, int runinthread) {
|
||||
psync_tree *tr, **addto;
|
||||
psync_rr_tree_node *node;
|
||||
|
|
@ -128,6 +128,6 @@ void psync_run_ratelimited(const char *name, psync_run_ratelimit_callback0 call,
|
|||
debug(D_NOTICE, "running %s on this thread", name);
|
||||
call();
|
||||
}
|
||||
psync_timer_register(psync_run_ratelimited_timer, minintervalsec, node);
|
||||
psync_timer_register(ratelimit_timer, minintervalsec, node);
|
||||
}
|
||||
}
|
||||
|
|
@ -34,9 +34,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef void (*psync_run_ratelimit_callback0)();
|
||||
typedef void (*prun_throttle_cb)();
|
||||
|
||||
void psync_run_ratelimited(const char *name, psync_run_ratelimit_callback0 call,
|
||||
uint32_t minintervalsec, int runinthread);
|
||||
void prun_throttled(const char *name, prun_throttle_cb call, uint32_t minintervalsec, int runinthread);
|
||||
|
||||
#endif
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#include "pstatus.h"
|
||||
#include "pfstasks.h"
|
||||
#include "plibs.h"
|
||||
#include "prunratelimit.h"
|
||||
#include "prunthrottled.h"
|
||||
#include "psettings.h"
|
||||
#include "ptask.h"
|
||||
#include "putil.h"
|
||||
|
|
@ -232,11 +232,11 @@ void pstatus_upload_recalc() {
|
|||
}
|
||||
|
||||
void pstatus_download_recalc_async() {
|
||||
psync_run_ratelimited("recalc download", proc_recalc_download, PSYNC_MIN_INTERVAL_RECALC_DOWNLOAD, 1);
|
||||
prun_throttled("recalc download", proc_recalc_download, PSYNC_MIN_INTERVAL_RECALC_DOWNLOAD, 1);
|
||||
}
|
||||
|
||||
void pstatus_upload_recalc_async() {
|
||||
psync_run_ratelimited("recalc upload", proc_recalc_upload, PSYNC_MIN_INTERVAL_RECALC_UPLOAD, 1);
|
||||
prun_throttled("recalc upload", proc_recalc_upload, PSYNC_MIN_INTERVAL_RECALC_UPLOAD, 1);
|
||||
}
|
||||
|
||||
uint32_t pstatus_get(uint32_t statusid) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue