Archived
This forum has been archived. Please start a new discussion on GitHub.
Ice seems to not support client side multi processes.
mzhang
in Help Center
I just wrote a very simple Ice application to produce the problem.
Slice file:
module Test
{
interface TestInterface
{
idempotent string hello();
};
};
Client code:
#include <Ice/Ice.h>
#include "hello.h"
#include <sys/wait.h>
int main(int argc, char **argv)
{
Ice::CommunicatorPtr comm;
comm = Ice::initialize(argc, argv);
std::string proxyconf = "TestInterface:tcp -h localhost -p 50000";
Ice::ObjectPrx base = comm->stringToProxy(proxyconf);
Test::TestInterfacePrx proxy = Test::TestInterfacePrx::checkedCast(base);
long l_child_pid = 0;
l_child_pid = fork ();
std::string output = proxy->hello();
if (l_child_pid == 0 )
{
exit(0);
}
int status = 0;
waitpid(l_child_pid, &status, 0);
std::cout << output << std::endl;
}
And if running the program, it is blocked forever.
Stack trace for the parent:
#0 0x007bc7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x0086447b in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x0805ca4b in main (argc=1, argv=0xbfeebfd4) at /net/soft_scratch/users/mzhang/temp/ice/client.cpp:21
This is fine. The parent process is waiting for the child process.
Stack trace for the child process:
#0 0x007bc7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x00a3cb26 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0
#2 0x008aeb17 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libc.so.6
#3 0x00d8b6f1 in IceInternal::Outgoing::invoke (this=0xbfeebc70) at ../../include/IceUtil/Cond.h:203
#4 0x08056d7f in IceDelegateM::Test::TestInterface::hello (this=0x882cff8, __context=0x0) at /net/soft_scratch/users/mzhang/temp/ice/hello.cpp:194
#5 0x0805698f in IceProxy::Test::TestInterface::hello (this=0x882cfc0, __ctx=0x0) at /net/soft_scratch/users/mzhang/temp/ice/hello.cpp:123
#6 0x0805cc57 in IceProxy::Test::TestInterface::hello (this=0x882cfc0) at /net/soft_scratch/users/mzhang/temp/ice/hello.h:118
#7 0x0805ca15 in main (argc=1, argv=0xbfeebfd4) at /net/soft_scratch/users/mzhang/temp/ice/client.cpp:15
It is blocked there forever on a Ice call.
Best Regards,
Michael
Slice file:
module Test
{
interface TestInterface
{
idempotent string hello();
};
};
Client code:
#include <Ice/Ice.h>
#include "hello.h"
#include <sys/wait.h>
int main(int argc, char **argv)
{
Ice::CommunicatorPtr comm;
comm = Ice::initialize(argc, argv);
std::string proxyconf = "TestInterface:tcp -h localhost -p 50000";
Ice::ObjectPrx base = comm->stringToProxy(proxyconf);
Test::TestInterfacePrx proxy = Test::TestInterfacePrx::checkedCast(base);
long l_child_pid = 0;
l_child_pid = fork ();
std::string output = proxy->hello();
if (l_child_pid == 0 )
{
exit(0);
}
int status = 0;
waitpid(l_child_pid, &status, 0);
std::cout << output << std::endl;
}
And if running the program, it is blocked forever.
Stack trace for the parent:
#0 0x007bc7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x0086447b in __waitpid_nocancel () from /lib/tls/libc.so.6
#2 0x0805ca4b in main (argc=1, argv=0xbfeebfd4) at /net/soft_scratch/users/mzhang/temp/ice/client.cpp:21
This is fine. The parent process is waiting for the child process.
Stack trace for the child process:
#0 0x007bc7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x00a3cb26 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libpthread.so.0
#2 0x008aeb17 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/libc.so.6
#3 0x00d8b6f1 in IceInternal::Outgoing::invoke (this=0xbfeebc70) at ../../include/IceUtil/Cond.h:203
#4 0x08056d7f in IceDelegateM::Test::TestInterface::hello (this=0x882cff8, __context=0x0) at /net/soft_scratch/users/mzhang/temp/ice/hello.cpp:194
#5 0x0805698f in IceProxy::Test::TestInterface::hello (this=0x882cfc0, __ctx=0x0) at /net/soft_scratch/users/mzhang/temp/ice/hello.cpp:123
#6 0x0805cc57 in IceProxy::Test::TestInterface::hello (this=0x882cfc0) at /net/soft_scratch/users/mzhang/temp/ice/hello.h:118
#7 0x0805ca15 in main (argc=1, argv=0xbfeebfd4) at /net/soft_scratch/users/mzhang/temp/ice/client.cpp:15
It is blocked there forever on a Ice call.
Best Regards,
Michael
0
Comments
-
Try to call _exit() instead of exit(). For more information on how to use fork() with Ice, please have a look at this FAQ.0
