more logs and check task observer for other running password creation tasks

This commit is contained in:
Dario 2020-09-29 09:04:14 +02:00
parent d54bdcafd0
commit daca50286d
4 changed files with 38 additions and 1 deletions

View File

@ -212,6 +212,18 @@ std::vector<int> SingletonTaskObserver::getTasksCount(const std::string& email)
return taskCounts;
}
int SingletonTaskObserver::getTasksCount(TaskObserverType type)
{
int type_sum_count = 0;
lock("SingletonTaskObserver::getTasksCount");
for (int i = 0; i < mObserverEntrys.getNItems(); i++) {
UserObserverEntry* entry = static_cast<UserObserverEntry*>(mObserverEntrys.findByIndex(i));
type_sum_count += entry->mTasksCount[type];
}
unlock();
return type_sum_count;
}
const char* SingletonTaskObserver::TaskObserverTypeToString(TaskObserverType type)
{
switch (type) {

View File

@ -46,6 +46,7 @@ public:
int getTaskCount(const std::string& email, TaskObserverType type);
int getTaskCount(DHASH id, TaskObserverType type);
std::vector<int> getTasksCount(const std::string& email);
int getTasksCount(TaskObserverType type);
static const char* TaskObserverTypeToString(TaskObserverType type);
static TaskObserverType StringToTaskObserverType(const std::string& typeString);

View File

@ -817,7 +817,29 @@ UserStates Session::loadUser(const std::string& email, const std::string& passwo
printf("before if login\n");
if (!mSessionUser.isNull() && mSessionUser->getUserState() >= USER_LOADED_FROM_DB) {
printf("before login\n");
int loginResult = mNewUser->login(password);
int loginResult = 0;
int exitCount = 0;
do {
loginResult = mNewUser->login(password);
Poco::Thread::sleep(100);
exitCount++;
} while (-3 == loginResult && exitCount < 15);
if (exitCount > 0) {
addError(new ParamError(functionName, "login succeed, retrys: ", exitCount));
addError(new ParamError(functionName, "email: ", email));
sendErrorsAsEmail();
}
if (exitCount >= 15)
{
auto running_password_creations = observer->getTasksCount(TASK_OBSERVER_PASSWORD_CREATION);
addError(new ParamError(functionName, "login failed after 15 retrys and 100 ms sleep between, currently running passwort creation tasks: ", running_password_creations));
addError(new ParamError(functionName, "email: ", email));
sendErrorsAsEmail();
return USER_PASSWORD_ENCRYPTION_IN_PROCESS;
}
printf("new user login with result: %d\n", loginResult);
if (-1 == loginResult) {

2
src/cpsp/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/compile.sh
/*.dll