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

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

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