|
|
@ -709,8 +709,10 @@ K_ITEM *get_workerstatus(int64_t userid, char *workername) |
|
|
|
|
|
|
|
|
|
|
|
/* Worker loading/creation calls this with create = true
|
|
|
|
/* Worker loading/creation calls this with create = true
|
|
|
|
* All others with create = false since the workerstatus should exist |
|
|
|
* All others with create = false since the workerstatus should exist |
|
|
|
* Failure is a code bug and a reported error, but handled anyway |
|
|
|
* If it is missing, it will check for and create the worker if needed |
|
|
|
|
|
|
|
* and create a new workerstatus and return it |
|
|
|
* This has 2 sets of file/func/line to allow 2 levels of traceback |
|
|
|
* This has 2 sets of file/func/line to allow 2 levels of traceback |
|
|
|
|
|
|
|
* to see why it happened |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
K_ITEM *_find_create_workerstatus(int64_t userid, char *workername, |
|
|
|
K_ITEM *_find_create_workerstatus(int64_t userid, char *workername, |
|
|
|
bool create, const char *file2, |
|
|
|
bool create, const char *file2, |
|
|
@ -718,32 +720,55 @@ K_ITEM *_find_create_workerstatus(int64_t userid, char *workername, |
|
|
|
WHERE_FFL_ARGS) |
|
|
|
WHERE_FFL_ARGS) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WORKERSTATUS *row; |
|
|
|
WORKERSTATUS *row; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *ws_item, *w_item = NULL; |
|
|
|
|
|
|
|
bool ws_err = false, w_err = false; |
|
|
|
|
|
|
|
tv_t now; |
|
|
|
|
|
|
|
|
|
|
|
item = get_workerstatus(userid, workername); |
|
|
|
ws_item = get_workerstatus(userid, workername); |
|
|
|
if (!item) { |
|
|
|
if (!ws_item) { |
|
|
|
if (!create) { |
|
|
|
if (!create) { |
|
|
|
LOGEMERG("%s(): Missing workerstatus %"PRId64"/%s" |
|
|
|
ws_err = true; |
|
|
|
WHERE_FFL WHERE_FFL, |
|
|
|
|
|
|
|
__func__, userid, workername, |
|
|
|
w_item = find_workers(userid, workername); |
|
|
|
file2, func2, line2, WHERE_FFL_PASS); |
|
|
|
if (!w_item) { |
|
|
|
return NULL; |
|
|
|
w_err = true; |
|
|
|
|
|
|
|
setnow(&now); |
|
|
|
|
|
|
|
w_item = workers_add(NULL, userid, workername, |
|
|
|
|
|
|
|
NULL, NULL, NULL, |
|
|
|
|
|
|
|
by_default, |
|
|
|
|
|
|
|
(char *)__func__, |
|
|
|
|
|
|
|
(char *)inet_default, |
|
|
|
|
|
|
|
&now, NULL); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
K_WLOCK(workerstatus_free); |
|
|
|
K_WLOCK(workerstatus_free); |
|
|
|
item = k_unlink_head(workerstatus_free); |
|
|
|
ws_item = k_unlink_head(workerstatus_free); |
|
|
|
|
|
|
|
|
|
|
|
DATA_WORKERSTATUS(row, item); |
|
|
|
DATA_WORKERSTATUS(row, ws_item); |
|
|
|
|
|
|
|
|
|
|
|
bzero(row, sizeof(*row)); |
|
|
|
bzero(row, sizeof(*row)); |
|
|
|
row->userid = userid; |
|
|
|
row->userid = userid; |
|
|
|
STRNCPY(row->workername, workername); |
|
|
|
STRNCPY(row->workername, workername); |
|
|
|
|
|
|
|
|
|
|
|
workerstatus_root = add_to_ktree(workerstatus_root, item, cmp_workerstatus); |
|
|
|
workerstatus_root = add_to_ktree(workerstatus_root, ws_item, cmp_workerstatus); |
|
|
|
k_add_head(workerstatus_store, item); |
|
|
|
k_add_head(workerstatus_store, ws_item); |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
|
K_WUNLOCK(workerstatus_free); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ws_err) { |
|
|
|
|
|
|
|
LOGERR("%s(): CREATED Missing workerstatus %"PRId64"/%s" |
|
|
|
|
|
|
|
WHERE_FFL WHERE_FFL, |
|
|
|
|
|
|
|
__func__, userid, workername, |
|
|
|
|
|
|
|
file2, func2, line2, WHERE_FFL_PASS); |
|
|
|
|
|
|
|
if (w_err) { |
|
|
|
|
|
|
|
LOGERR("%s(): %s Missing worker %"PRId64"/%s", |
|
|
|
|
|
|
|
__func__, |
|
|
|
|
|
|
|
w_item ? "CREATED" : "FAILED TO CREATE", |
|
|
|
|
|
|
|
userid, workername); |
|
|
|
} |
|
|
|
} |
|
|
|
return item; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ws_item; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* All data is loaded, now update workerstatus fields
|
|
|
|
/* All data is loaded, now update workerstatus fields
|
|
|
|