client_globals.append(globals);
}
+int32_t CLIENT::tryIncNumConcurrentJobs(int32_t val, int32_t inc)
+{
+ LOCK_GUARD(globals_mutex);
+ if (globals == NULL) {
+ return 0;
+ }
+ if (globals->NumConcurrentJobs < val) {
+ globals->NumConcurrentJobs += inc;
+
+ } else {
+ return 0;
+ }
+ return globals->NumConcurrentJobs;
+}
+
int32_t CLIENT::getNumConcurrentJobs()
{
LOCK_GUARD(globals_mutex);
store_globals.append(globals);
}
+int32_t STORE::tryIncNumConcurrentJobs(int32_t val, int32_t inc)
+{
+ LOCK_GUARD(globals_mutex);
+ if (globals == NULL) {
+ return 0;
+ }
+ if (globals->NumConcurrentJobs < val) {
+ globals->NumConcurrentJobs += inc;
+
+ } else {
+ return 0;
+ }
+ return globals->NumConcurrentJobs;
+}
+
int32_t STORE::getNumConcurrentReadJobs()
{
LOCK_GUARD(globals_mutex);
void create_client_globals();
int32_t getNumConcurrentJobs();
int32_t incNumConcurrentJobs(int32_t inc);
+ int32_t tryIncNumConcurrentJobs(int32_t val, int32_t inc);
char *address(POOLMEM *&buf);
void setAddress(char *addr);
bool is_enabled();
int32_t getNumConcurrentReadJobs();
int32_t incNumConcurrentJobs(int32_t inc);
int32_t incNumConcurrentReadJobs(int32_t inc);
+ int32_t tryIncNumConcurrentJobs(int32_t val, int32_t inc);
bool is_enabled();
void setEnabled(bool val);
};
/* Returns true if it was possible to increment Storage's write counter,
* returns false otherwise */
static bool inc_wstore(STORE *wstore) {
- Dmsg1(dbglvl, "Wstore=%s\n", wstore->name());
- int num = wstore->getNumConcurrentJobs();
- if (num < wstore->MaxConcurrentJobs) {
- num = wstore->incNumConcurrentJobs(1);
- Dmsg2(dbglvl, "Store: %s Inc wncj=%d\n", wstore->name(), num);
- return true;
- }
-
- return false;
+ //Dmsg1(dbglvl, "Wstore=%s\n", wstore->name());
+ int num = wstore->tryIncNumConcurrentJobs(wstore->MaxConcurrentJobs, 1);
+ return num > 0;
}
/* Returns true if it was possible to increment Storage's read counter,
}
/* Create a temp copy of the store list */
- alist *tmp_list = New(alist(10, not_owned_by_alist));
+ alist *tmp_list = New(alist(MAX(10, list->size()), not_owned_by_alist));
if (!tmp_list) {
Dmsg1(dbglvl, "Failed to allocate tmp list for jobid: %d\n", jcr->JobId);
return false;
/* Reset list */
list->destroy();
- list->init(10, not_owned_by_alist);
+ list->init(MAX(10, tmp_list->size()), not_owned_by_alist);
foreach_alist(tmp_store, tmp_list) {
if (write) {