Archived

This forum has been archived. Please start a new discussion on GitHub.

Quetion about object of class Ice::Service

Hi!
I tried to write daemon in C++, who can reload configuration file into communicator - in main () function in loop i try to create object of class, which inherited from Ice::Service, then make call to it's method run() and then, if nessasary, exit from program or go to another oteration of a loop. First iteration works fine, but in second iteration i catch exception in adapter's function c.adapter->addWithUUID:
Reading /dev/urandom failed:
Random.cpp:147: IceUtil::SyscallException:
syscall exception: Bad file descriptor

I tried to write test case with simple object of class Ice::Session, instead of function addWithUUID, i used IceUtil::generateUUID(), but error still exists. Example of code:
class MyService : public Ice::Service
{
    protected:
	virtual bool start(int argc, char* argv[], int& cnt)
	{
            //artificial status to exit from service
	    return false;
	}
	void initService();
};

int main(int argc, char* argv[])
{
    cout << "UUID1 = " << IceUtil::generateUUID()<< endl;
    MyService* srv = new MyService();
    srv -> main(argc,argv);
    delete srv;
    //here i cauht an exception
    cout << "UUID2 = " << IceUtil::generateUUID()<< endl;
    srv = new MyService();
    srv -> main(argc,argv);
    delete srv;
    cout << "UUID3 = " << IceUtil::generateUUID()<< endl;
    return 0;
}


May be i was wrong in method of reload configuration properties?
How can i fix this issue?
Thank's for help!

P.S. I use Ice 3.4.2 on Linux Centos.

Comments

  • xdm
    xdm La Coruña, Spain
    That exception happens because Ice::Service close all open fds when using "--daemon", and when IceUtil/Random try to read from /dev/urandom to generate an UUID it fails. You can avoid this by adding "--noclose" to Ice::Service arguments.

    About reloading the configuration, IceBox provide some administration facilities that could help you, specially it can start/stop services. See IceBox - Ice 3.5 - ZeroC

    You can be also interested in the Properties Facet introduce in 3.5 The Properties Facet - Ice 3.5 - ZeroC
  • Thank you for help, --noclose works :)