git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed ip_queue.h checking.
[stg.git]
/
projects
/
stargazer
/
plugins
/
other
/
rscript
/
rscript.cpp
diff --git
a/projects/stargazer/plugins/other/rscript/rscript.cpp
b/projects/stargazer/plugins/other/rscript/rscript.cpp
index 9e560a5d6062394baa90c3ef19b7dd24a5e8e64c..f7479da67aa8e8636abf3c26f1db78508b2b9452 100644
(file)
--- a/
projects/stargazer/plugins/other/rscript/rscript.cpp
+++ b/
projects/stargazer/plugins/other/rscript/rscript.cpp
@@
-30,6
+30,8
@@
#include <csignal>
#include <cassert>
#include <cstdlib>
#include <csignal>
#include <cassert>
#include <cstdlib>
+#include <cerrno>
+#include <cstring>
#include <algorithm>
#include "stg/common.h"
#include <algorithm>
#include "stg/common.h"
@@
-181,7
+183,8
@@
REMOTE_SCRIPT::REMOTE_SCRIPT()
mutex(),
sock(0),
onAddUserNotifier(*this),
mutex(),
sock(0),
onAddUserNotifier(*this),
- onDelUserNotifier(*this)
+ onDelUserNotifier(*this),
+ logger(GetPluginLogger(GetStgLogger(), "rscript"))
{
pthread_mutex_init(&mutex, NULL);
}
{
pthread_mutex_init(&mutex, NULL);
}
@@
-252,6
+255,7
@@
if (!isRunning)
if (pthread_create(&thread, NULL, Run, this))
{
errorStr = "Cannot create thread.";
if (pthread_create(&thread, NULL, Run, this))
{
errorStr = "Cannot create thread.";
+ logger("Cannot create thread.");
printfd(__FILE__, "Cannot create thread\n");
return -1;
}
printfd(__FILE__, "Cannot create thread\n");
return -1;
}
@@
-290,7
+294,10
@@
users->DelNotifierUserDel(&onDelUserNotifier);
users->DelNotifierUserAdd(&onAddUserNotifier);
if (isRunning)
users->DelNotifierUserAdd(&onAddUserNotifier);
if (isRunning)
+ {
+ logger("Cannot stop thread.");
return -1;
return -1;
+ }
return 0;
}
return 0;
}
@@
-302,6
+309,7
@@
NRMapParser nrMapParser;
if (nrMapParser.ReadFile(rsSettings.GetMapFileName()))
{
errorStr = nrMapParser.GetErrorStr();
if (nrMapParser.ReadFile(rsSettings.GetMapFileName()))
{
errorStr = nrMapParser.GetErrorStr();
+ logger("Map file reading error: %s", errorStr.c_str());
return -1;
}
return -1;
}
@@
-327,6
+335,7
@@
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
errorStr = "Cannot create socket.";
if (sock < 0)
{
errorStr = "Cannot create socket.";
+ logger("Canot create a socket: %s", strerror(errno));
printfd(__FILE__, "Cannot create socket\n");
return true;
}
printfd(__FILE__, "Cannot create socket\n");
return true;
}
@@
-464,6
+473,9
@@
sendAddr.sin_addr.s_addr = routerIP;
int res = sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&sendAddr, sizeof(sendAddr));
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));
}
//-----------------------------------------------------------------------------
return (res != sizeof(buffer));
}
//-----------------------------------------------------------------------------
@@
-472,12
+484,7
@@
bool REMOTE_SCRIPT::GetUsers()
USER_PTR u;
int h = users->OpenSearch();
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))
{
while (!users->SearchNext(h, &u))
{