#include <cstdlib>
#include <cstdio> // snprintf
#include <cerrno>
+#include <cmath>
#include <algorithm>
#include "stg/common.h"
{
errorStr = "Cannot create thread.";
printfd(__FILE__, "Cannot create recv thread\n");
+ logger("Cannot create recv thread.");
return -1;
}
}
{
errorStr = "Cannot create thread.";
printfd(__FILE__, "Cannot create timeouter thread\n");
+ logger("Cannot create timeouter thread.");
return -1;
}
}
if (listenSocket < 0)
{
errorStr = "Cannot create socket.";
+ logger("Cannot create a socket: %s", strerror(errno));
return -1;
}
if (bind(listenSocket, (struct sockaddr*)&listenAddr, sizeof(listenAddr)) < 0)
{
errorStr = "AUTH_IA: Bind failed.";
+ logger("Cannot bind the socket: %s", strerror(errno));
return -1;
}
if (errno != EINTR)
{
printfd(__FILE__, "recvfrom res=%d, error: '%s'\n", dataLen, strerror(errno));
+ logger("recvfrom error: %s", strerror(errno));
return -1;
}
return 0;
if (user->GetProperty().disabled.Get())
{
+ logger("Cannont authorize '%s', user is disabled.", login);
SendError(sip, sport, protoVer, "õÞÅÔÎÁÑ ÚÁÐÉÓØ ÚÁÂÌÏËÉÒÏ×ÁÎÁ");
return 0;
}
if (user->GetProperty().passive.Get())
{
+ logger("Cannont authorize '%s', user is passive.", login);
SendError(sip, sport, protoVer, "õÞÅÔÎÁÑ ÚÁÐÉÓØ ÚÁÍÏÒÏÖÅÎÁ");
return 0;
}
userPtr->GetLogin().c_str(),
inet_ntostring(sip).c_str(),
login.c_str());
- logger("IP address already in use by user '%s'. IP %s, login: '%s'",
+ logger("IP address is already in use by user '%s'. IP %s, login: '%s'",
userPtr->GetLogin().c_str(),
inet_ntostring(sip).c_str(),
login.c_str());
it->second.user->GetLogin().c_str(),
inet_ntostring(sip).c_str(),
user->GetLogin().c_str());
- logger("IP address already in use by user '%s'. IP %s, login: '%s'",
+ logger("IP address is already in use by user '%s'. IP %s, login: '%s'",
it->second.user->GetLogin().c_str(),
inet_ntostring(sip).c_str(),
user->GetLogin().c_str());
printfd(__FILE__, "Login %s already in use from ip %s. IP %s\n",
login.c_str(), inet_ntostring(user->GetCurrIP()).c_str(),
inet_ntostring(sip).c_str());
- logger("Login %s already in use from ip %s. IP %s",
+ logger("Login '%s' is already in use from ip %s. IP %s",
login.c_str(),
inet_ntostring(user->GetCurrIP()).c_str(),
inet_ntostring(sip).c_str());
aliveSyn6.md[dn],
dn,
stgTime);
- p *= (1024 * 1024);
- if (p == 0)
+ p *= 1024 * 1024;
+ if (std::fabs(p) < 1.0e-3)
{
snprintf((char*)aliveSyn6.freeMb, IA_FREEMB_LEN, "---");
}
aliveSyn8.md[dn],
dn,
stgTime);
- p *= (1024 * 1024);
- if (p == 0)
+ p *= 1024 * 1024;
+ if (std::fabs(p) < 1.0e-3)
{
snprintf((char*)aliveSyn8.freeMb, IA_FREEMB_LEN, "---");
}