fix bug: spawn: coro: stack size limit on windows

This commit is contained in:
jie 2021-11-22 19:29:05 +08:00
parent 06707c4446
commit 774efcec0d
4 changed files with 512 additions and 454 deletions

View File

@ -134,7 +134,11 @@ namespace bserv {
std::ref(req_), std::ref(req_),
std::ref(routes_), std::ref(routes_),
std::ref(session_->ioc_), std::ref(session_->ioc_),
std::placeholders::_1)); std::placeholders::_1)
#ifdef _MSC_VER
, boost::coroutines::attributes{ STACK_SIZE }
#endif
);
} }
public: public:
explicit websocket_session_server( explicit websocket_session_server(
@ -322,7 +326,13 @@ namespace bserv {
std::ref(lambda_), std::ref(lambda_),
std::ref(routes_), std::ref(routes_),
std::ref(ioc_), std::ref(ioc_),
std::placeholders::_1)); std::placeholders::_1)
#ifdef _MSC_VER
// currently, it is only identified on windows
// that the default stack size is too small
, boost::coroutines::attributes{ STACK_SIZE }
#endif
);
// handle_request(parser_->release(), lambda_, routes_); // handle_request(parser_->release(), lambda_, routes_);
// at this point the parser can be reset // at this point the parser can be reset

View File

@ -26,6 +26,10 @@ namespace bserv {
//const std::string DB_CONN_STR = "dbname=bserv"; //const std::string DB_CONN_STR = "dbname=bserv";
const std::string DB_CONN_STR = ""; const std::string DB_CONN_STR = "";
#ifdef _MSC_VER
const std::size_t STACK_SIZE = 1024 * 1024;
#endif
#define decl_field(type, name, default_value) \ #define decl_field(type, name, default_value) \
private: \ private: \
std::optional<type> name##_; \ std::optional<type> name##_; \

View File

@ -0,0 +1,22 @@
import requests
import random
from multiprocessing import Process
def test():
if random.randint(0, 1) == 0:
resp = requests.get("http://localhost:8080/statics/js/bootstrap.bundle.min.js")
else:
resp = requests.get("http://localhost:8080/statics/css/bootstrap.min.css")
if resp.status_code != 200:
print(resp)
if __name__ == '__main__':
print('starting test')
processes = [Process(target=test) for _ in range(200)]
for p in processes:
p.start()
for p in processes:
p.join()
print('end of test')

View File

@ -0,0 +1,22 @@
import requests
import random
from multiprocessing import Process
def test():
if random.randint(0, 1) == 0:
resp = requests.get("http://localhost:8080")
else:
resp = requests.get("http://localhost:8080/users")
if resp.status_code != 200:
print(resp)
if __name__ == '__main__':
print('starting test')
processes = [Process(target=test) for _ in range(200)]
for p in processes:
p.start()
for p in processes:
p.join()
print('end of test')