Home » U++ Library support » U++ MT-multithreading and servers » Error in RpcServer example
Error in RpcServer example [message #47464] |
Thu, 19 January 2017 11:22  |
Zbych
Messages: 327 Registered: July 2009
|
Senior Member |
|
|
Hi,
There is an error in RPC server shown here:
http://ultimatepp.org/reference$MtRpcServer$en-us.html
Take a look at mutex usage:
void Process(int n)
{
INTERLOCKED { LOG("Process " << n << " started"); }
Mutex accept_mutex;
for(;;)
{
TcpSocket http;
accept_mutex.Enter();
[...]
bool b = http.Accept(rpc);
This mutex should allow only one thread to enter Accept method at a time.
But since every thread has its own mutex instance, it doesn't do its job and all threads stuck not on Enter(), but inside http.Accept().
"Mutex accept_mutex" should either be part of MtRpcServer class or be static.
[Updated on: Thu, 19 January 2017 11:39] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri May 09 15:40:24 CEST 2025
Total time taken to generate the page: 0.01152 seconds
|