mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
changed elopage handler, adding message for debugging crash
This commit is contained in:
parent
8fcd28d189
commit
efe039a7a9
@ -89,11 +89,10 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
ServerConfig::initEMailAccount(config());
|
||||
|
||||
// start cpu scheduler
|
||||
unsigned int worker_count = Poco::Environment::processorCount();
|
||||
if (worker_count > 1) {
|
||||
worker_count--;
|
||||
}
|
||||
ServerConfig::g_CPUScheduler = new UniLib::controller::CPUSheduler(worker_count, "Login Worker");
|
||||
unsigned int worker_count = Poco::Environment::processorCount() * 2;
|
||||
|
||||
ServerConfig::g_CPUScheduler = new UniLib::controller::CPUSheduler(worker_count, "Default Worker");
|
||||
ServerConfig::g_CryptoCPUScheduler = new UniLib::controller::CPUSheduler(2, "Crypto Worker");
|
||||
|
||||
// load up connection configs
|
||||
// register MySQL connector
|
||||
@ -119,6 +118,7 @@ int Gradido_LoginServer::main(const std::vector<std::string>& args)
|
||||
// set-up a server socket
|
||||
Poco::Net::ServerSocket svs(port);
|
||||
// set-up a HTTPServer instance
|
||||
Poco::ThreadPool& pool = Poco::ThreadPool::defaultPool();
|
||||
Poco::Net::HTTPServer srv(new PageRequestHandlerFactory, svs, new Poco::Net::HTTPServerParams);
|
||||
// start the HTTPServer
|
||||
srv.start();
|
||||
|
||||
@ -9,7 +9,20 @@
|
||||
void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
|
||||
{
|
||||
// simply write request to file for later lookup
|
||||
ServerConfig::writeToFile(request.stream(), "elopage_webhook_requests.txt");
|
||||
//ServerConfig::writeToFile(request.stream(), "elopage_webhook_requests.txt");
|
||||
|
||||
|
||||
std::istream& stream = request.stream();
|
||||
Poco::Net::NameValueCollection elopageRequestData;
|
||||
while (!stream.eof()) {
|
||||
char keyBuffer[30];
|
||||
char valueBuffer[35];
|
||||
stream.get(keyBuffer, 30, '=')
|
||||
.get(valueBuffer, 35, '&');
|
||||
elopageRequestData.set(keyBuffer, valueBuffer);
|
||||
}
|
||||
UniLib::controller::TaskPtr handleElopageTask(new HandleElopageRequestTask(elopageRequestData));
|
||||
handleElopageTask->scheduleTask(handleElopageTask);
|
||||
|
||||
response.setChunkedTransferEncoding(true);
|
||||
response.setContentType("application/json");
|
||||
@ -23,3 +36,14 @@ void ElopageWebhook::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::
|
||||
|
||||
if (_compressResponse) _gzipStream.close();
|
||||
}
|
||||
|
||||
|
||||
int HandleElopageRequestTask::run()
|
||||
{
|
||||
printf("[HandleElopageRequestTask::run]\n");
|
||||
for (auto it = mRequestData.begin(); it != mRequestData.end(); it++) {
|
||||
printf("%s => %s\n", it->first.data(), it->second.data());
|
||||
}
|
||||
printf("[HandleElopageRequestTask::run] end\n");
|
||||
return 0;
|
||||
}
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include "Poco/Net/HTTPRequestHandler.h"
|
||||
#include "../tasks/CPUTask.h"
|
||||
|
||||
|
||||
class ElopageWebhook : public Poco::Net::HTTPRequestHandler
|
||||
@ -11,5 +12,18 @@ public:
|
||||
void handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response);
|
||||
};
|
||||
|
||||
class HandleElopageRequestTask : public UniLib::controller::CPUTask
|
||||
{
|
||||
public:
|
||||
HandleElopageRequestTask(Poco::Net::NameValueCollection& requestData)
|
||||
: CPUTask(ServerConfig::g_CPUScheduler), mRequestData(requestData) {}
|
||||
|
||||
const char* getResourceType() const { return "HandleElopageRequestTask"; };
|
||||
int run();
|
||||
|
||||
protected:
|
||||
Poco::Net::NameValueCollection mRequestData;
|
||||
};
|
||||
|
||||
|
||||
#endif // Elopage_Webhook_INCLUDED
|
||||
|
||||
@ -30,6 +30,7 @@ namespace ServerConfig {
|
||||
ObfusArray* g_ServerCryptoKey = nullptr;
|
||||
// std::string g_ServerAdminPublic;
|
||||
UniLib::controller::CPUSheduler* g_CPUScheduler = nullptr;
|
||||
UniLib::controller::CPUSheduler* g_CryptoCPUScheduler = nullptr;
|
||||
Context::Ptr g_SSL_CLient_Context = nullptr;
|
||||
EmailAccount g_EmailAccount;
|
||||
int g_SessionTimeout = SESSION_TIMEOUT_DEFAULT;
|
||||
@ -123,6 +124,10 @@ namespace ServerConfig {
|
||||
if (g_CPUScheduler) {
|
||||
delete g_CPUScheduler;
|
||||
}
|
||||
|
||||
if (g_CryptoCPUScheduler) {
|
||||
delete g_CryptoCPUScheduler;
|
||||
}
|
||||
}
|
||||
|
||||
void writeToFile(std::istream& datas, std::string& fileName)
|
||||
|
||||
@ -26,6 +26,7 @@ namespace ServerConfig {
|
||||
extern ObfusArray* g_ServerCryptoKey;
|
||||
//extern unsigned char g_ServerAdminPublic[];
|
||||
extern UniLib::controller::CPUSheduler* g_CPUScheduler;
|
||||
extern UniLib::controller::CPUSheduler* g_CryptoCPUScheduler;
|
||||
extern Poco::Net::Context::Ptr g_SSL_CLient_Context;
|
||||
extern EmailAccount g_EmailAccount;
|
||||
extern int g_SessionTimeout;
|
||||
|
||||
@ -86,8 +86,9 @@ Session::Session(int handle)
|
||||
|
||||
Session::~Session()
|
||||
{
|
||||
|
||||
printf("[Session::~Session] \n");
|
||||
reset();
|
||||
printf("[Session::~Session] finished \n");
|
||||
}
|
||||
|
||||
|
||||
@ -184,7 +185,7 @@ bool Session::createUser(const std::string& name, const std::string& email, cons
|
||||
prepareEmail->scheduleTask(prepareEmail);
|
||||
|
||||
// create user crypto key
|
||||
UniLib::controller::TaskPtr cryptoKeyTask(new UserCreateCryptoKey(mSessionUser, password, ServerConfig::g_CPUScheduler));
|
||||
UniLib::controller::TaskPtr cryptoKeyTask(new UserCreateCryptoKey(mSessionUser, password, ServerConfig::g_CryptoCPUScheduler));
|
||||
cryptoKeyTask->setFinishCommand(new SessionStateUpdateCommand(SESSION_STATE_CRYPTO_KEY_GENERATED, this));
|
||||
cryptoKeyTask->scheduleTask(cryptoKeyTask);
|
||||
|
||||
|
||||
@ -188,8 +188,10 @@ User::User(const char* email)
|
||||
|
||||
User::~User()
|
||||
{
|
||||
printf("[User::~User]\n");
|
||||
if (mCryptoKey) {
|
||||
delete mCryptoKey;
|
||||
mCryptoKey = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ namespace UniLib {
|
||||
|
||||
CPUSheduler::~CPUSheduler()
|
||||
{
|
||||
printf("[CPUSheduler::~CPUSheduler]\n");
|
||||
for(int i = 0; i < mThreadCount; i++) {
|
||||
if (mThreads[i]) {
|
||||
delete mThreads[i];
|
||||
@ -29,6 +30,7 @@ namespace UniLib {
|
||||
}
|
||||
delete[] mThreads;
|
||||
mThreadCount = 0;
|
||||
printf("[CPUSheduler::~CPUSheduler] finished\n");
|
||||
}
|
||||
|
||||
int CPUSheduler::sheduleTask(TaskPtr task)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user