From daca50286d01014837501fbf54fa8180b11a331e Mon Sep 17 00:00:00 2001 From: Dario Date: Tue, 29 Sep 2020 09:04:14 +0200 Subject: [PATCH] more logs and check task observer for other running password creation tasks --- .../SingletonTaskObserver.cpp | 12 ++++++++++ .../SingletonManager/SingletonTaskObserver.h | 1 + src/cpp/model/Session.cpp | 24 ++++++++++++++++++- src/cpsp/.gitignore | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/cpsp/.gitignore diff --git a/src/cpp/SingletonManager/SingletonTaskObserver.cpp b/src/cpp/SingletonManager/SingletonTaskObserver.cpp index 66490353a..f4dba3849 100644 --- a/src/cpp/SingletonManager/SingletonTaskObserver.cpp +++ b/src/cpp/SingletonManager/SingletonTaskObserver.cpp @@ -212,6 +212,18 @@ std::vector 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(mObserverEntrys.findByIndex(i)); + type_sum_count += entry->mTasksCount[type]; + } + unlock(); + return type_sum_count; +} + const char* SingletonTaskObserver::TaskObserverTypeToString(TaskObserverType type) { switch (type) { diff --git a/src/cpp/SingletonManager/SingletonTaskObserver.h b/src/cpp/SingletonManager/SingletonTaskObserver.h index 3eb7983f2..96e97223f 100644 --- a/src/cpp/SingletonManager/SingletonTaskObserver.h +++ b/src/cpp/SingletonManager/SingletonTaskObserver.h @@ -46,6 +46,7 @@ public: int getTaskCount(const std::string& email, TaskObserverType type); int getTaskCount(DHASH id, TaskObserverType type); std::vector getTasksCount(const std::string& email); + int getTasksCount(TaskObserverType type); static const char* TaskObserverTypeToString(TaskObserverType type); static TaskObserverType StringToTaskObserverType(const std::string& typeString); diff --git a/src/cpp/model/Session.cpp b/src/cpp/model/Session.cpp index cb574786b..77c5362d4 100644 --- a/src/cpp/model/Session.cpp +++ b/src/cpp/model/Session.cpp @@ -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) { diff --git a/src/cpsp/.gitignore b/src/cpsp/.gitignore new file mode 100644 index 000000000..863ee1751 --- /dev/null +++ b/src/cpsp/.gitignore @@ -0,0 +1,2 @@ +/compile.sh +/*.dll