Archived
This forum has been archived. Please start a new discussion on GitHub.
problem with adapter.add()
Hello,
i'am a newer in ICE,recently i downloaded ice3.3.1 and write an helloworld(client and server) with VC++6.0 in win7.
and all the work have been done correctly i think(because i almost do it as same as the documention says),right i run the server,then the client,the trouble comes:
both client and server blocked.
after some troubleshooting,i find that :"adapter->add(object,id);"---<when i try to add the servant to the proxy,server blocked(i added a" cout<<"done"<<endl;"after the adapter->add perform,if this perform returned ,the cout should excuted,but it haven't).
is any situation could make add() blocked?
please give me some help,thank you!
i'am a newer in ICE,recently i downloaded ice3.3.1 and write an helloworld(client and server) with VC++6.0 in win7.
and all the work have been done correctly i think(because i almost do it as same as the documention says),right i run the server,then the client,the trouble comes:
both client and server blocked.
after some troubleshooting,i find that :"adapter->add(object,id);"---<when i try to add the servant to the proxy,server blocked(i added a" cout<<"done"<<endl;"after the adapter->add perform,if this perform returned ,the cout should excuted,but it haven't).
is any situation could make add() blocked?
please give me some help,thank you!
0
Comments
-
Hi Eric,
Invocations to adapter.add should not block, but is difficult to know what is going on without more details.
The easiest way for us to help would be to post a stack trace of the hung or a small compilable demo that shows your problem.
Bests,
José0 -
reply
Ok
here is the content of my server.cpp
#include <Ice/Ice.h>
#include "helloworld.h"
#include <string>
#include <iostream>
using namespace std;
using namespace helloworldSP;
class helloworldI:public helloworld
{
virtual void sayhello(const string& str,const Ice::Current &);
};
void helloworldI::sayhello(const string& str,const Ice::Current &)
{
cout<<"hello,welcome to ICE-WORLD!"<<endl;
cout<<"Your name is "<<str<<endl;
}
int main(int argc,char * argv[])
{
Ice::CommunicatorPtr ic;
try{
string Port="tcp -p 12345";
ic=Ice::initialize(argc,argv);
Ice::ObjectAdapterPtr adapter
=ic->createObjectAdapterWithEndpoints("helloAdapter",Port);
helloworldSP::helloworldPtr object=new helloworldI;
string id("helloworldId");
adapter->add(object,ic->stringToIdentity(id));
cout << "ICE-Server have started!" << endl;//if the adapter->add() not blocked,this cout should have excuted.
adapter->activate();
ic->waitForShutdown();
}
catch (const Ice::Exception & e)
{
cout << e << endl;
}
catch (const char * msg)
{
cout << msg << endl;
}
if (ic)
ic->destroy();
}
and the slice file is simply like this:
module helloworldSP
{
interface helloworld
{
void sayhello(string str);
};
};
thanks for your reply0 -
Hi Eric,
Are you sure that's add which is blocking actually?
It could be that createObjectAdapter() call is blocking because you have a firewall turned on for Windows7, can you confirm that createObjectAdapter is not blocking by print to cerr after it success, you should also try to turn off the firewall to see if that made any difference.
If this doesn't help you should provide us with a stack trace so we could look into the issue, note that win7 vc6 is not yet a supported platform so you could also test that on Win Xp.
Bests,
José0 -
how can i get the stack trace with vc++6.0?
hello
i have made sure that createObjectAdapterWithEndpoints() is run correcrly in two ways:
1.put a cout<<"ok"<<endl; after the "createObjectAdapterWithEndpoints()" but before the adapter->add().
2.close the windows 7 firewall.
however the problem is still there.
btw,how can i get the stack trace with vc++ 6.0?
thanks for your reply!0 -
btw,how can i get the stack trace with vc++ 6.0?
Usually you need to run the program inside the debugger and break it when it hung to get an stack trace.
You should also check if the tests provide with Ice distribution work on your system.
In general will be better to use a supported platform configuration, see here http://www.zeroc.com/platforms_3_3_1.html
Bests,
José0 -
is this?
hi,
i run the server under the debug mode and break it when it get blocked.
then i get the copy of this(call stack in debug toolbar):
NTDLL! 777464f4()
KERNELBASE! 759f1818()
STLPORT_VC6_STLDEBUG46! 00303797()
STLPORT_VC6_STLDEBUG46! 002f2332()
STLPORT_VC6_STLDEBUG46! 002e1060()
STLPORT_VC6_STLDEBUG46! 002f200e()
STLPORT_VC6_STLDEBUG46! 002e1590()
STLPORT_VC6_STLDEBUG46! 002e144b()
STLPORT_VC6_STLDEBUG46! 002e1d2e()
Ice::Identity::~Identity() + 71 bytes
main(int 1, char * * 0x00ac38b8) line 35 + 209 bytes
mainCRTStartup() line 338 + 17 bytes
KERNEL32! 77481174()
NTDLL! 7775b3f5()
NTDLL! 7775b3c8()
also i checked the disassembly which show the program blocking in this sentence:
-> 777464F4 ret
777464F5 lea esp,[esp]
777464FC lea esp,[esp]
77746500 lea edx,[esp+8]
does it mean that the system is waitting for the subfunction return ,thus the subfunction adapter->add()( or another?) nerver return(blocked),it lead the main program blocked in this place?
thx0 -
-
Hihi,
i have checked the demo,and it can run perfectly under my windows 7 with the VC++ 6.0.
so sholud we consider that my problem has nothing to do with windows 7?
If that works your demo should also work, could you upload a small compilable project that reproduce the issue.
José0 -
project uploaded
compliable project of server uploaded.
pls check it .
thanks for helping me so much!0 -
Hi Eric,
I have run your demo without problems in Xp Vc6, but i have changed the project settings for that to work.
Your project was linking the debug binary with ice.lib and iceutil.lib, for debug builds you should use iced.lib and iceutild.lib, i have also update other build settings.
You should review your project settings and compare it with the ones used to build the demos in Ice-3.3.1-VC60 distribution.
I have attached the project with the modified settings.
Bests,
José0 -
solved
hi,xdm
thanks for your help!
I have solved this problem just now by using preprocess
#ifndef _DEBUG
#pragma comment(lib, "iced.lib")
#pragma comment(lib, "iceutild.lib")
#else
#pragma comment(lib, "ice.lib")
#pragma comment(lib, "iceutil.lib")
#endif
btw,may i ask why ice have such library especially for debug use?
iced.lib d(short for debug?).
can't just put it into a lib file?
bests
eric0 -
Hi,
I´m glad you solve the issuebtw,may i ask why ice have such library especially for debug use?
iced.lib d(short for debug?).
can't just put it into a lib file?
d is short for debug right, iced.lib is just a .lib but is build with debug info, for development is better to use debug builds because they give you more info in the debugger and macros like assert are executed , when you release an application you just link with release lib (ice.lib) that are build with optimizations so they are smaller and faster.
Bests,
José0 -
okd is short for debug right, iced.lib is just a .lib but is build with debug info, for development is better to use debug builds because they give you more info in the debugger and macros like assert are executed , when you release an application you just link with release lib (ice.lib) that are build with optimizations so they are smaller and faster.
thanks for your patient answer
I've got what you mean,but I still can't figure it out how it is associated with add() blocking by using release lib for debug project?
bests
eric0 -
Hi Eric,
I don't know the exact cause, but when you mix debug and release libraries your program will be using both c++ runtime's, so and object could be allocated by the release runtime and deallocated by the debug runtime such configurations are not supported and you will get undefined behavior, in new versions of visual studio you will get and assertion if you try to do that.
Also if you have the possibility to switch to Visual Studio 2008 or 2005 professional edition, you could use Visual Studio Plug-in to develop your Ice application much easier.
Bests,
José0 -
thxAlso if you have the possibility to switch to Visual Studio 2008 or 2005 professional edition, you could use Visual Studio Plug-in to develop your Ice application much easier.
xdm,thanks for your advise,I'am going to switch to Visual Studio 2008.
bests
eric0 -
Hi
You should take a look to Matthew Newhook Screencast which provides an overview of the Ice Visual Studio Extension.
Bests,
José0