edisona / rcf-cpp

Automatically exported from code.google.com/p/rcf-cpp
1 stars 0 forks source link

High CPU load using several multithreaded servers #37

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Compile and run the following code

#include "RCF/Idl.hpp"
#include "RCF/SessionObjectFactoryService.hpp"
#include "RCF/TcpEndpoint.hpp"

RCF_BEGIN(I_Echo, "I_X")
        RCF_METHOD_R1(std::string, echo, const std::string &)
RCF_END(I_Echo)

class Echo
{
        public:
                std::string echo(std::string &a)
                {
                        return a;
                }
};

int main(void)
{
        RCF::RcfServer server( RCF::TcpEndpoint(50001));
        RCF::RcfServer server2( RCF::TcpEndpoint(50002));

        RCF::SessionObjectFactoryServicePtr sofsPtr(
                        new RCF::SessionObjectFactoryService());
        RCF::SessionObjectFactoryServicePtr sofsPtr2(
                        new RCF::SessionObjectFactoryService());

        sofsPtr->bind<I_Echo,Echo>();
        sofsPtr2->bind<I_Echo,Echo>();
        server.addService(sofsPtr);
        server2.addService(sofsPtr2);

        std::size_t threadCount = 2;
        server.setThreadPool( RCF::ThreadPoolPtr( new RCF::ThreadPool(threadCount)));
        server2.setThreadPool( RCF::ThreadPoolPtr( new RCF::ThreadPool(threadCount)));

        server.start();
        server2.start();

        sleep(50);
}

What is the expected output? What do you see instead?

The code launches two multithreaded servers and wait for incoming connections. 
The process keeps the CPU load on 100% without any client connection. Launching 
one single thread on each server works fine. Launching only one server with 
several threads also works fine. 

What version of the product are you using? On what operating system?

I'm using RCF 1.3 on a GNU/Linux system (Ubuntu).

Please provide any additional information below.

Thanks in advance.

Original issue reported on code.google.com by daniel.p...@gmail.com on 17 Jun 2011 at 12:19

GoogleCodeExporter commented 9 years ago
Hi Daniel,

This is a known bug in RCF 1.3 and has been fixed. If you can send me an email 
at jarl.lindrud at deltavsoft dot com, I'll send you a patch.

Regards,
Jarl

Original comment by jarl.lin...@gmail.com on 10 Aug 2011 at 11:17