update
This commit is contained in:
parent
0da36b9b8b
commit
f1bf409981
@ -40,7 +40,7 @@ struct myAdsVariable {
|
|||||||
&bytesRead);
|
&bytesRead);
|
||||||
|
|
||||||
if (error || (size != bytesRead)) {
|
if (error || (size != bytesRead)) {
|
||||||
vLog(LOG_ERROR, "AdsVariable read failed: %d,%s\n", error, strerror(errno));
|
vLog(LOG_ERROR, "AdsVariable read failed: %d, %s\n", error, strerror(errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
das-dn/third_party/AdsLib/Sockets.cpp
vendored
7
das-dn/third_party/AdsLib/Sockets.cpp
vendored
@ -84,7 +84,7 @@ uint32_t getIpv4(const std::string& addr)
|
|||||||
InitSocketLibrary();
|
InitSocketLibrary();
|
||||||
const auto status = getaddrinfo(addr.c_str(), nullptr, &addrinfo, &res);
|
const auto status = getaddrinfo(addr.c_str(), nullptr, &addrinfo, &res);
|
||||||
if (status) {
|
if (status) {
|
||||||
throw std::runtime_error("Invalid IPv4 address or unknown hostname: " + addr);
|
//throw std::runtime_error("Invalid IPv4 address or unknown hostname: " + addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto value = ((struct sockaddr_in*)res->ai_addr)->sin_addr.s_addr;
|
const auto value = ((struct sockaddr_in*)res->ai_addr)->sin_addr.s_addr;
|
||||||
@ -239,11 +239,14 @@ Frame& Socket::read(Frame& frame, timeval* timeout)
|
|||||||
bool Socket::Select(timeval* timeout)
|
bool Socket::Select(timeval* timeout)
|
||||||
{
|
{
|
||||||
/* prepare socket set for select() */
|
/* prepare socket set for select() */
|
||||||
|
if (!IsValid()) {
|
||||||
|
LOG_ERROR("Socket is invalid: " << std::dec << m_Socket);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
fd_set readSockets;
|
fd_set readSockets;
|
||||||
FD_ZERO(&readSockets);
|
FD_ZERO(&readSockets);
|
||||||
FD_SET(m_Socket, &readSockets);
|
FD_SET(m_Socket, &readSockets);
|
||||||
|
|
||||||
if (!IsValid()) return false;
|
|
||||||
/* wait for receive data */
|
/* wait for receive data */
|
||||||
const int state = NATIVE_SELECT(m_Socket + 1, &readSockets, nullptr, nullptr, timeout);
|
const int state = NATIVE_SELECT(m_Socket + 1, &readSockets, nullptr, nullptr, timeout);
|
||||||
if (0 == state) {
|
if (0 == state) {
|
||||||
|
@ -65,7 +65,7 @@ long AmsRouter::ConnectTarget(AmsNetId ams, const std::string& host)
|
|||||||
|
|
||||||
connection_attempts[ams] = {};
|
connection_attempts[ams] = {};
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
try {
|
// try {
|
||||||
//AmsConnection is created and try to connect remote host
|
//AmsConnection is created and try to connect remote host
|
||||||
auto new_connection = std::unique_ptr<AmsConnection>(new AmsConnection {*this, hostAddresses.get()});
|
auto new_connection = std::unique_ptr<AmsConnection>(new AmsConnection {*this, hostAddresses.get()});
|
||||||
if(new_connection.get() == nullptr || new_connection.get()->IsConnected() == false){
|
if(new_connection.get() == nullptr || new_connection.get()->IsConnected() == false){
|
||||||
@ -89,13 +89,13 @@ long AmsRouter::ConnectTarget(AmsNetId ams, const std::string& host)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return -1;//
|
return -1;//
|
||||||
} catch (std::exception& e) {
|
// } catch (std::exception& e) {
|
||||||
std::cout<<"AmsRouter::AddRoute(Exception) is occured."<<"\n";
|
// std::cout<<"AmsRouter::AddRoute(Exception) is occured."<<"\n";
|
||||||
lock.lock();
|
// lock.lock();
|
||||||
connection_attempts.erase(ams);
|
// connection_attempts.erase(ams);
|
||||||
connection_attempt_events.notify_all();
|
// connection_attempt_events.notify_all();
|
||||||
throw e;
|
// throw e;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmsRouter::DisconnectTarget(const AmsNetId& ams)
|
void AmsRouter::DisconnectTarget(const AmsNetId& ams)
|
||||||
|
Loading…
Reference in New Issue
Block a user