void LoginRESTService::Run() { soap soapServer(SOAP_C_UTFSTRING, SOAP_C_UTFSTRING); // check every 3 seconds if world ended soapServer.accept_timeout = 3; soapServer.recv_timeout = 5; soapServer.send_timeout = 5; if (!soap_valid_socket(soap_bind(&soapServer, _bindIP.c_str(), _port, 100))) { TC_LOG_ERROR("server.rest", "Couldn't bind to %s:%d", _bindIP.c_str(), _port); return; } TC_LOG_INFO("server.rest", "Login service bound to http://%s:%d", _bindIP.c_str(), _port); http_post_handlers handlers[] = { { "application/json;charset=utf-8", handle_post_plugin }, { "application/json", handle_post_plugin }, { nullptr, nullptr } }; soap_register_plugin_arg(&soapServer, &http_get, (void*)&handle_get_plugin); soap_register_plugin_arg(&soapServer, &http_post, handlers); soap_register_plugin_arg(&soapServer, &ContentTypePlugin::Init, (void*)"application/json;charset=utf-8"); // Use our already ready ssl context soapServer.ctx = Battlenet::SslContext::instance().native_handle(); soapServer.ssl_flags = SOAP_SSL_RSA; while (!_stopped) { if (!soap_valid_socket(soap_accept(&soapServer))) continue; // ran into an accept timeout std::shared_ptr<soap> soapClient = std::make_shared<soap>(soapServer); boost::asio::ip::address_v4 address(soapClient->ip); if (soap_ssl_accept(soapClient.get()) != SOAP_OK) { TC_LOG_DEBUG("server.rest", "Failed SSL handshake from IP=%s", address.to_string().c_str()); continue; } TC_LOG_DEBUG("server.rest", "Accepted connection from IP=%s", address.to_string().c_str()); std::thread([soapClient] { soap_serve(soapClient.get()); }).detach(); } // and release the context handle here - soap does not own it so it should not free it on exit soapServer.ctx = nullptr; TC_LOG_INFO("server.rest", "Login service exiting..."); }
void *process_request(void *soap) { #ifdef _POSIX_THREADS pthread_detach(pthread_self()); #endif soap_ssl_accept((struct soap*)soap); // serve request (or multiple requests with keep-alive enabled) soap_serve((struct soap*)soap); // cleanup class instances soap_destroy((struct soap*)soap); // cleanup soap_end((struct soap*)soap); // detach and free thread's copy of soap environment soap_free((struct soap*)soap); return NULL; }
void *process_request(struct soap *soap) { #if defined(_POSIX_THREADS) || defined(_SC_THREADS) pthread_detach(pthread_self()); #endif #ifdef WITH_OPENSSL if (soap_ssl_accept(soap) != SOAP_OK) { /* when soap_ssl_accept() fails, socket is closed and SSL data reset */ pmesg_safe(&global_flag, LOG_ERROR, __FILE__, __LINE__, "SSL request failed, continue with next call...\n"); soap_print_fault(soap, stderr); } else #endif soap_serve(soap); soap_destroy(soap); /* for C++ */ soap_end(soap); soap_free(soap); mysql_thread_end(); return NULL; }
int PullPointSubscriptionBindingService::ssl_accept() { return soap_ssl_accept(this->soap); }
int wsrmService::ssl_accept() { return soap_ssl_accept(this->soap); }
int calcService::ssl_accept() { return soap_ssl_accept(this); }
int AccountService::ssl_accept() { return soap_ssl_accept(this); }
int videooverlayService::ssl_accept() { return soap_ssl_accept(this); }
int BankService::ssl_accept() { return soap_ssl_accept(this); }
int ReceiverBindingService::ssl_accept() { return soap_ssl_accept(this); }
int RuleEngineBindingService::ssl_accept() { return soap_ssl_accept(this->soap); }
int ImagingBindingService::ssl_accept() { return soap_ssl_accept(this->soap); }
int ServiceSoapBindingService::ssl_accept() { return soap_ssl_accept(this); }
int BasicHttpBinding_USCOREICalculatorService::ssl_accept() { return soap_ssl_accept(this->soap); }
int WSHttpBinding_USCOREINWNMasterServerAPIService::ssl_accept() { return soap_ssl_accept(this); }
int DisplayBindingService::ssl_accept() { return soap_ssl_accept(this); }
int quoteService::ssl_accept() { return soap_ssl_accept(this); }
int AdvancedSecurityServiceBindingService::ssl_accept() { return soap_ssl_accept(this->soap); }
int AmazonS3SoapBindingService::ssl_accept() { return soap_ssl_accept(this->soap); }
int WSDualHttpBinding_USCOREICalculatorDuplexService::ssl_accept() { return soap_ssl_accept(this->soap); }