#include <csignal>
#include <cassert>
#include <cstdlib>
+#include <cerrno>
+#include <cstring>
#include <algorithm>
#include "stg/common.h"
mutex(),
sock(0),
onAddUserNotifier(*this),
- onDelUserNotifier(*this)
+ onDelUserNotifier(*this),
+ logger(GetPluginLogger(GetStgLogger(), "rscript"))
{
pthread_mutex_init(&mutex, NULL);
}
if (pthread_create(&thread, NULL, Run, this))
{
errorStr = "Cannot create thread.";
+ logger("Cannot create thread.");
printfd(__FILE__, "Cannot create thread\n");
return -1;
}
users->DelNotifierUserAdd(&onAddUserNotifier);
if (isRunning)
+ {
+ logger("Cannot stop thread.");
return -1;
+ }
return 0;
}
if (nrMapParser.ReadFile(rsSettings.GetMapFileName()))
{
errorStr = nrMapParser.GetErrorStr();
+ logger("Map file reading error: %s", errorStr.c_str());
return -1;
}
if (sock < 0)
{
errorStr = "Cannot create socket.";
+ logger("Canot create a socket: %s", strerror(errno));
printfd(__FILE__, "Cannot create socket\n");
return true;
}
int res = sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&sendAddr, sizeof(sendAddr));
+if (res < 0)
+ logger("sendto error: %s", strerror(errno));
+
return (res != sizeof(buffer));
}
//-----------------------------------------------------------------------------
USER_PTR u;
int h = users->OpenSearch();
-if (!h)
- {
- errorStr = "users->OpenSearch() error.";
- printfd(__FILE__, "OpenSearch() error\n");
- return true;
- }
+assert(h && "USERS::OpenSearch is always correct");
while (!users->SearchNext(h, &u))
{