Commit 268cf1db authored by Pavel Vainerman's avatar Pavel Vainerman

(unet2): исправил ошибку в вылавливании исключений при создании соединений

parent ee4ce4f5
...@@ -41,6 +41,7 @@ cache_init_ok(false) ...@@ -41,6 +41,7 @@ cache_init_ok(false)
myname = s.str(); myname = s.str();
} }
ost::Thread::setException(ost::Thread::throwException);
try try
{ {
// ost::IPV4Cidr ci(s_host.c_str()); // ost::IPV4Cidr ci(s_host.c_str());
...@@ -49,18 +50,18 @@ cache_init_ok(false) ...@@ -49,18 +50,18 @@ cache_init_ok(false)
addr = s_host.c_str(); addr = s_host.c_str();
udp = new ost::UDPDuplex(addr,port); udp = new ost::UDPDuplex(addr,port);
} }
catch( ost::SockException& e ) catch( std::exception& e )
{ {
ostringstream s; ostringstream s;
s << "(" << s_host << ":" << port << "): " << e.getString() << ": " << e.getSystemErrorString(); s << "Could not create connection for " << s_host << ":" << port << " err: " << e.what();
dlog[Debug::CRIT] << myname << "(init): (ost::SocketException) " << s.str() << std::endl; dlog[Debug::CRIT] << myname << "(init): " << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
catch(ost::Socket& socket) catch( ... )
{ {
ostringstream s; ostringstream s;
s << "Could not create connection for " << s_host << ":" << port; s << "Could not create connection for " << s_host << ":" << port;
dlog[Debug::CRIT] << myname << "(init): (ost::Socket) " << s.str() << std::endl; dlog[Debug::CRIT] << myname << "(init): " << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
......
...@@ -36,24 +36,24 @@ s_thr(0) ...@@ -36,24 +36,24 @@ s_thr(0)
if( dlog.debugging(Debug::INFO) ) if( dlog.debugging(Debug::INFO) )
dlog[Debug::INFO] << "(UNetSender): UDP set to " << s_host << ":" << port << endl; dlog[Debug::INFO] << "(UNetSender): UDP set to " << s_host << ":" << port << endl;
ost::Thread::setException(ost::Thread::throwException);
try try
{ {
addr = s_host.c_str(); addr = s_host.c_str();
udp = new ost::UDPBroadcast(addr,port); udp = new ost::UDPBroadcast(addr,port);
} }
catch( ost::SockException& e ) catch( std::exception& e )
{ {
ostringstream s; ostringstream s;
s << "(" << s_host << ":" << port << "): " << e.getString() << ": " << e.getSystemErrorString(); s << "Could not create broadcast connection for " << s_host << ":" << port << " err: " << e.what();
dlog[Debug::CRIT] << myname << "(init): (ost::SocketException) " << s.str() << std::endl; dlog[Debug::CRIT] << myname << "(init): " << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
catch(ost::Socket& socket) catch( ... )
{ {
ostringstream s; ostringstream s;
s << "Could not create connection for " << s_host << ":" << port; s << "Could not create connection for " << s_host << ":" << port;
dlog[Debug::CRIT] << myname << "(init): (ost::Socket) " << s.str() << std::endl; dlog[Debug::CRIT] << myname << "(init): " << s.str() << std::endl;
throw SystemError(s.str()); throw SystemError(s.str());
} }
......
...@@ -22,20 +22,19 @@ int main( int argc, const char** argv ) ...@@ -22,20 +22,19 @@ int main( int argc, const char** argv )
return 0; return 0;
} }
string confile=UniSetTypes::getArgParam("--confile",argc,argv,"configure.xml"); uniset_init(argc,argv);
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--unet-logfile")); string logfilename(conf->getArgParam("--unet-logfile"));
if( logfilename.empty() ) if( logfilename.empty() )
logfilename = "udpexchange.log"; logfilename = "udpexchange.log";
conf->initDebug(dlog,"dlog");
std::ostringstream logname; std::ostringstream logname;
string dir(conf->getLogDir()); string dir(conf->getLogDir());
logname << dir << logfilename; logname << dir << logfilename;
unideb.logFile( logname.str() ); unideb.logFile( logname.str() );
dlog.logFile( logname.str() ); UniSetExtensions::dlog.logFile( logname.str() );
conf->initDebug(UniSetExtensions::dlog,"dlog");
ObjectId shmID = DefaultObjectId; ObjectId shmID = DefaultObjectId;
string sID = conf->getArgParam("--smemory-id"); string sID = conf->getArgParam("--smemory-id");
...@@ -75,12 +74,6 @@ int main( int argc, const char** argv ) ...@@ -75,12 +74,6 @@ int main( int argc, const char** argv )
{ {
dlog[Debug::CRIT] << "(unetexchange): " << ex << std::endl; dlog[Debug::CRIT] << "(unetexchange): " << ex << std::endl;
} }
catch( ost::SockException& e )
{
ostringstream s;
s << e.getString() << ": " << e.getSystemErrorString();
dlog[Debug::CRIT] << s.str() << endl;
}
catch(...) catch(...)
{ {
dlog[Debug::CRIT] << "(unetexchange): catch ..." << std::endl; dlog[Debug::CRIT] << "(unetexchange): catch ..." << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment