You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

513 lines
17 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef _SERVER_CORE_SERVER_MODULE_
  2. #define _SERVER_CORE_SERVER_MODULE_
  3. #include <stdio.h>
  4. #include <signal.h>
  5. #ifndef __linux__
  6. #ifndef WIN32_LEAN_AND_MEAN
  7. #define WIN32_LEAN_AND_MEAN
  8. // #include <WinSock2.h>
  9. #include <windows.h>
  10. #include <winsock2.h>
  11. #include <ws2tcpip.h>
  12. #endif
  13. #else
  14. #include <sys/socket.h>
  15. #include <netinet/in.h>
  16. #include <netinet/ip.h>
  17. #include <netdb.h>
  18. #include <sys/un.h>
  19. #include <sys/types.h>
  20. #include <fcntl.h>
  21. #include <sys/ioctl.h>
  22. #include <unistd.h>
  23. #include <errno.h>
  24. #endif
  25. #include <stdlib.h>
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <vector>
  29. #include "../../components/base/basicTypes.h"
  30. #include "../../components/base/basicThread.h"
  31. #include "../../components/base/basicLogCollection.h"
  32. #include "../../components/base/basicLogCollection.h"
  33. #include "../../components/base/basicSettingsProvider.h"
  34. #include "../../components/base/basicEngine.h"
  35. #include "../../components/base/basicEventHeap.h"
  36. #include "../protocol/protocol.h"
  37. #include "netClientHandler.h"
  38. #define NWS_SETTINGS_HOST "NW_HOSTNAME_IP"
  39. #define NWS_SETTINGS_PORT "NW_LISTEN_PORT"
  40. //typedef _Primitive_Ring<_Core_Channel> ChannelsRing;
  41. //typedef std::vector<networkClientHandler *> vectorNetHandlers;
  42. #define UNIX_PATH_MAX 108
  43. //void signal_void_handler( int SIG );
  44. template <class HANDLER, class ENGINE> class networkServer : public basicThread, public basicEventHandler{
  45. private:
  46. basicLogCollection * m_pLog;
  47. //vectorNetHandlers m_vHandlersPool;
  48. std::vector<HANDLER *> m_vHandlersPool;
  49. //basicEngine *m_pEngine;
  50. ENGINE * m_pEngine;
  51. config_setting_t * m_pSettings;
  52. struct sockaddr * MainSocketAddress;
  53. CSTR m_pHostName;
  54. uint16_t m_nPortNumber;
  55. #ifdef __linux__
  56. int MainSocket;
  57. #else
  58. SOCKET MainSocket;
  59. #endif
  60. U8 m_bConnectionType;
  61. protected:
  62. void m_fThreadProc( void );
  63. public:
  64. explicit networkServer( config_setting_t *Settings = NULL );
  65. virtual ~networkServer();
  66. bool BootUp( void ); // Config By Settings provided in constructor, on fail uses next BootUp
  67. bool BootUp( U16 Port ); // Uses Default Hostname and Port as parameter, on fail (getlocalhost) uses next Bootup
  68. bool BootUp( CSTR HOST_NAME, U16 Port ); // Uses parameters
  69. #ifdef __linux__
  70. bool BootUp( CSTR UNIX_SOCKET_NAME );
  71. #endif
  72. bool attachEngine(ENGINE *ptr);
  73. void dispatchEvent( basicEvent *Evt );
  74. };
  75. #define LOG( X ) m_pLog->Log( "networkServer", this, X )
  76. #define LOG_ERROR( X ) m_pLog->Log( "networkServer", this, _LOG_ERROR, X )
  77. //void signal_void_handler(int SIG){
  78. //};
  79. template <class HANDLER, class ENGINE> networkServer<HANDLER, ENGINE>::networkServer(config_setting_t *Settings) : basicThread(), basicEventHandler() {
  80. m_pLog = basicLogCollection::getInstance();
  81. m_bConnectionType = 0;
  82. m_vHandlersPool.clear();
  83. MainSocketAddress = NULL;
  84. if (Settings != NULL) {
  85. m_pSettings = Settings;
  86. } else {
  87. m_pSettings = basicSettingsProvider::getInstance()->getSubNode(NULL, "NETWORK_SERVER");
  88. };
  89. };
  90. template <class HANDLER, class ENGINE> networkServer<HANDLER, ENGINE>::~networkServer(){
  91. m_bThreadStatus = TH_ENDED;
  92. if (m_pHostName != NULL) free(m_pHostName);
  93. };
  94. template <class HANDLER, class ENGINE> bool networkServer<HANDLER, ENGINE>::BootUp(void){
  95. config_setting_t *pSetting;
  96. int tVal;
  97. char tBuffer[CTEXT];
  98. m_pHostName = NULL;
  99. if (m_pSettings != NULL) {
  100. LOG("NetServer Getting Settings ...");
  101. if (!config_setting_lookup_string(m_pSettings, NWS_SETTINGS_HOST, (const char**)&m_pHostName)){
  102. m_pHostName = (CSTR)malloc(CTEXT);
  103. sprintf(m_pHostName, "localhost");
  104. pSetting = config_setting_add(m_pSettings, NWS_SETTINGS_HOST, CONFIG_TYPE_STRING);
  105. config_setting_set_string(pSetting, m_pHostName);
  106. basicSettingsProvider::getInstance()->compromise();
  107. LOG("No Host defined");
  108. }
  109. else {
  110. sprintf(tBuffer, "1 Read From Settings: %s", m_pHostName);
  111. LOG(tBuffer);
  112. };
  113. if (!config_setting_lookup_int(m_pSettings, NWS_SETTINGS_PORT, &tVal)){
  114. m_nPortNumber = 2222;
  115. pSetting = config_setting_add(m_pSettings, NWS_SETTINGS_PORT, CONFIG_TYPE_INT);
  116. config_setting_set_int(pSetting, m_nPortNumber);
  117. basicSettingsProvider::getInstance()->compromise();
  118. LOG("No Port defined");
  119. }
  120. else {
  121. m_nPortNumber = tVal;
  122. sprintf(tBuffer, "2 Read From Settings: %d", m_nPortNumber);
  123. LOG(tBuffer);
  124. };
  125. if (basicSettingsProvider::getInstance()->isCompromised()) basicSettingsProvider::getInstance()->validate();
  126. return BootUp(m_pHostName, m_nPortNumber);
  127. } else {
  128. // Last try to bootup by detecting host and default port 2222
  129. return BootUp(2222);
  130. };
  131. };
  132. template <class HANDLER, class ENGINE> bool networkServer<HANDLER, ENGINE>::BootUp(CSTR HOST_NAME, U16 PORT){
  133. char temp[CTEXT];
  134. #ifdef __linux__
  135. int RetCode;
  136. struct hostent *h_info;
  137. LOG("Core BootUp");
  138. MainSocket = socket(AF_INET, SOCK_STREAM, 0);
  139. if (MainSocket == -1){
  140. LOG_ERROR("Some throuble with networking on this machine (Socket Error)!");
  141. return false;
  142. };
  143. MainSocketAddress = NULL;
  144. MainSocketAddress = (struct sockaddr *) malloc(sizeof(struct sockaddr_in));
  145. if (MainSocketAddress == NULL){
  146. LOG_ERROR("Some throuble with networking on this machine (Cannot Alloc Sockaddr Struct)!");
  147. return false;
  148. };
  149. bzero(MainSocketAddress, sizeof(struct sockaddr_in));
  150. h_info = gethostbyname(HOST_NAME);
  151. if (h_info == NULL){
  152. LOG_ERROR("Some throuble with networking on this machine (Cannot Get Hostname)!");
  153. return false;
  154. };
  155. //*****************************************
  156. //* there we building our network address *
  157. //*****************************************
  158. bcopy(h_info->h_addr, &(((struct sockaddr_in *)MainSocketAddress)->sin_addr), h_info->h_length);
  159. ((struct sockaddr_in *)MainSocketAddress)->sin_family = h_info->h_addrtype;
  160. ((struct sockaddr_in *)MainSocketAddress)->sin_port = htons(PORT);
  161. RetCode = bind(MainSocket, MainSocketAddress, sizeof(struct sockaddr_in));
  162. if (RetCode != 0){
  163. LOG_ERROR("Error Binding to Port/Address");
  164. return false;
  165. };
  166. RetCode = listen(MainSocket, 128);
  167. if (RetCode != 0){
  168. LOG_ERROR("Cannot Listen Port/Address");
  169. return false;
  170. };
  171. U8 dontblock;
  172. dontblock = fcntl(MainSocket, F_GETFL, NULL);
  173. dontblock |= O_NONBLOCK | O_NDELAY;
  174. RetCode = ioctl(MainSocket, FIONBIO, (char *)&dontblock);
  175. if (RetCode == 0){
  176. LOG("Set N-Blocking Mode of Accepting Socket");
  177. }
  178. else {
  179. LOG("Can't set N-Blocking Mode of Accepting Socket");
  180. };
  181. #else
  182. WSADATA wsaData;
  183. int iResult;
  184. // Initialize Winsock
  185. iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
  186. if (iResult != 0){
  187. sprintf(temp, "WSAStartup failed with error: %d\n", iResult);
  188. LOG_ERROR(temp);
  189. return false;
  190. };
  191. MainSocket = INVALID_SOCKET;
  192. SOCKET ClientSocket = INVALID_SOCKET;
  193. struct addrinfo *result = NULL;
  194. struct addrinfo hints;
  195. //int iSendResult;
  196. //char recvbuf[512];
  197. //int recvbuflen = 512;
  198. ZeroMemory(&hints, sizeof(hints));
  199. hints.ai_family = AF_INET;
  200. hints.ai_socktype = SOCK_STREAM;
  201. hints.ai_protocol = IPPROTO_TCP;
  202. hints.ai_flags = AI_PASSIVE;
  203. // Resolve the server address and port
  204. sprintf(temp, "%d", PORT);
  205. iResult = getaddrinfo(NULL, temp, &hints, &result);
  206. if (iResult != 0) {
  207. sprintf(temp, "getaddrinfo failed with error: %d\n", iResult);
  208. LOG_ERROR(temp);
  209. WSACleanup();
  210. return false;
  211. };
  212. // Create a SOCKET for connecting to server
  213. MainSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
  214. if (MainSocket == INVALID_SOCKET) {
  215. sprintf(temp, "socket failed with error: %ld\n", WSAGetLastError());
  216. LOG_ERROR(temp);
  217. freeaddrinfo(result);
  218. WSACleanup();
  219. return false;
  220. };
  221. // Setup the TCP listening socket
  222. iResult = bind(MainSocket, result->ai_addr, (int)result->ai_addrlen);
  223. if (iResult == SOCKET_ERROR) {
  224. sprintf(temp, "bind failed with error: %d\n", WSAGetLastError());
  225. LOG_ERROR(temp);
  226. freeaddrinfo(result);
  227. closesocket(MainSocket);
  228. WSACleanup();
  229. return false;
  230. };
  231. freeaddrinfo(result);
  232. iResult = listen(MainSocket, SOMAXCONN);
  233. if (iResult == SOCKET_ERROR) {
  234. sprintf(temp, "listen failed with error: %d\n", WSAGetLastError());
  235. LOG_ERROR(temp);
  236. closesocket(MainSocket);
  237. WSACleanup();
  238. return false;
  239. };
  240. /*
  241. u_long iMode = 1;
  242. iResult = ioctlsocket(MainSocket, FIONBIO, &iMode);
  243. if (iResult != NO_ERROR){
  244. sprintf(temp, "ioctlsocket failed with error: %ld\n", iResult);
  245. LOG_ERROR(temp);
  246. };
  247. */
  248. #endif
  249. m_bConnectionType = 1;
  250. return init();
  251. };
  252. template <class HANDLER, class ENGINE> bool networkServer<HANDLER, ENGINE>::BootUp(U16 Port){
  253. m_nPortNumber = Port;
  254. #ifdef __linux__
  255. int RetCode;
  256. size_t S_NAMLEN = CTEXT;
  257. RetCode = gethostname(m_pHostName, S_NAMLEN);
  258. char temp[CTEXT];
  259. sprintf(temp, "Running on host: %s:%d", m_pHostName, m_nPortNumber);
  260. LOG(temp);
  261. #else
  262. sprintf(m_pHostName, "");
  263. #endif
  264. return BootUp(m_pHostName, m_nPortNumber);
  265. };
  266. template <class HANDLER, class ENGINE> bool networkServer<HANDLER, ENGINE>::attachEngine(ENGINE *ptr){
  267. m_pEngine = ptr;
  268. if (m_vHandlersPool.size()) {
  269. // Pass Kernel to all already connected nodes
  270. for (std::vector<HANDLER *>::iterator index = m_vHandlersPool.begin(); index < m_vHandlersPool.end(); index++) {
  271. ((networkClientHandler *)(*index))->attachEngine((basicEngine *)m_pEngine);
  272. };
  273. };
  274. return true;
  275. };
  276. #ifdef __linux__
  277. bool networkServer::BootUp(CSTR SOCKET_NAME){
  278. struct sockaddr_un MainPort;
  279. size_t S_NAMLEN = CTEXT;
  280. int RetCode;
  281. char localhost[S_NAMLEN];
  282. char temp[CTEXT];
  283. LOG("Core BootUp");
  284. MainSocket = socket(PF_UNIX, SOCK_STREAM, 0);
  285. if (MainSocket == -1){
  286. LOG_ERROR("Some throuble with Kernel on this machine (UnixSocket Error)!");
  287. return false;
  288. };
  289. if (unlink(SOCKET_NAME) == -1){
  290. LOG("Old Socket File was not deleted!");
  291. };
  292. localhost[0] = 0;
  293. //RetCode = gethostname( localhost, S_NAMLEN );
  294. sprintf(temp, "Running Unix Socket: %s::%s", localhost, SOCKET_NAME);
  295. LOG(temp);
  296. MainSocketAddress = (sockaddr *)malloc(sizeof(struct sockaddr_un));
  297. bzero(MainSocketAddress, sizeof(struct sockaddr_un));
  298. //*****************************************
  299. //* there we building our network address *
  300. //*****************************************
  301. ((struct sockaddr_un *) MainSocketAddress)->sun_family = AF_UNIX;
  302. snprintf(((struct sockaddr_un *) MainSocketAddress)->sun_path, UNIX_PATH_MAX, SOCKET_NAME);
  303. RetCode = bind(MainSocket, MainSocketAddress, sizeof(struct sockaddr_un));
  304. if (RetCode != 0){
  305. LOG_ERROR("Error Binding to Port/Address");
  306. return false;
  307. };
  308. RetCode = listen(MainSocket, 128);
  309. if (RetCode != 0){
  310. LOG_ERROR("Cannot Listen UNIX SOCKET");
  311. return false;
  312. };
  313. U8 dontblock;
  314. // Set Socket permitions 666
  315. fchmod(MainSocket, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
  316. dontblock = fcntl(MainSocket, F_GETFL, NULL);
  317. dontblock |= O_NONBLOCK | O_NDELAY;
  318. RetCode = ioctl(MainSocket, FIONBIO, (char *)&dontblock);
  319. if (RetCode == 0){
  320. LOG("Set N-Blocking Mode of Accepting Socket");
  321. }
  322. else {
  323. LOG("Can't set N-Blocking Mode of Accepting Socket");
  324. };
  325. m_bConnectionType = 2;
  326. return init();
  327. };
  328. #endif
  329. template <class HANDLER, class ENGINE> void networkServer<HANDLER, ENGINE>::m_fThreadProc(void){
  330. //struct sockaddr ClientAddress;
  331. //socklen_t size;
  332. #ifdef __linux__
  333. int ClientSocket;
  334. if (m_bConnectionType == 1){
  335. size = (socklen_t) sizeof(struct sockaddr_in);
  336. }
  337. else {
  338. size = (socklen_t) sizeof(struct sockaddr_un);
  339. };
  340. #else
  341. SOCKET ClientSocket;
  342. #endif
  343. LOG("Core Worker Thread Started");
  344. LOG("Ready to Accept Connections");
  345. m_bThreadStatus = TH_WORKING;
  346. while (m_bThreadStatus < TH_ENDED){
  347. #ifdef __linux__
  348. ClientSocket = accept( MainSocket, &ClientAddress, &size);
  349. if (ClientSocket == -1) {
  350. #else
  351. ClientSocket = accept( MainSocket, NULL, NULL);
  352. if (ClientSocket == INVALID_SOCKET) {
  353. #endif
  354. switch (errno){
  355. case EAGAIN:{
  356. // Checkup client disconnection
  357. if (m_vHandlersPool.size()) {
  358. for (std::vector<HANDLER *>::iterator index = m_vHandlersPool.begin(); index < m_vHandlersPool.end(); index++) {
  359. networkClientHandler *tClient = (networkClientHandler *)(*index);
  360. if (tClient->getConnectionStatus() == CS_DISCONNECTED){
  361. // Remove Client Handler
  362. LOG("Remove Client");
  363. delete(tClient);
  364. m_vHandlersPool.erase(index);
  365. LOG("Client Stoped");
  366. LOG("Remove Client Done");
  367. };
  368. };
  369. };
  370. SLEEP(10);
  371. continue;
  372. };
  373. case EWOULDBLOCK: LOG_ERROR("The socket is marked non-blocking and no connections are present to be accepted."); break;
  374. case EBADF: LOG_ERROR("The descriptor is invalid."); break;
  375. case ECONNABORTED: LOG_ERROR("A connection has been aborted."); break;
  376. case EINTR: LOG_ERROR("The system call was interrupted by a signal that was caught before a valid connection arrived."); break;
  377. case EINVAL: LOG_ERROR("Socket is not listening for connections, or addrlen is invalid (e.g., is negative)."); break;
  378. case EMFILE: LOG_ERROR("The per-process limit of open file descriptors has been reached."); break;
  379. case ENFILE: LOG_ERROR("The system limit on the total number of open files has been reached."); break;
  380. case ENOTSOCK: LOG_ERROR("The descriptor references a file, not a socket."); break;
  381. case EOPNOTSUPP: LOG_ERROR("The referenced socket is not of type SOCK_STREAM."); break;
  382. case EFAULT: LOG_ERROR("The addr argument is not in a writable part of the user address space."); break;
  383. case ENOBUFS:
  384. case ENOMEM: LOG_ERROR("Not enough free memory. This often means that the memory allocation is limited by the socket buffer limits, not by the system memory."); break;
  385. case EPROTO: LOG_ERROR("Protocol error."); break;
  386. case EPERM: LOG_ERROR("Firewall rules forbid connection."); break;
  387. case ENOSR:
  388. #ifdef __linux__
  389. case ESOCKTNOSUPPORT:
  390. #endif
  391. case EPROTONOSUPPORT:
  392. case ETIMEDOUT: LOG_ERROR("Unusual error in Kernel (Timeout, No Socket Support in Kernel, Unsupported Protocol)"); break;
  393. #ifdef __linux__
  394. case ERESTARTSYS: LOG_ERROR("Unusual error by Kernel"); break;
  395. #endif
  396. default: LOG_ERROR("Unhandled error in Kernel"); break;
  397. };
  398. m_bThreadStatus = TH_ENDED;
  399. } else {
  400. if (ClientSocket >= 0) {
  401. if (m_bConnectionType == 1){
  402. //char tstr[CQUERY];
  403. #ifdef __linux__
  404. inet_ntop(AF_INET, &(((struct sockaddr_in*) &(ClientAddress))->sin_addr), tstr, size);
  405. #else
  406. //strcpy(tstr, inet_ntoa(((struct sockaddr_in*)&ClientAddress)->sin_addr));
  407. //InetNtop(AF_INET, &(((struct sockaddr_in*) &(ClientAddress ))->sin_addr ), (PWSTR)tstr, size );
  408. #endif
  409. };
  410. LOG("Client Connection Accepted");
  411. HANDLER *tHandle;
  412. tHandle = new HANDLER(ClientSocket, m_pSettings);//networkClientHandler(ClientSocket);
  413. if (tHandle != NULL) {
  414. tHandle->attachEngine(m_pEngine);
  415. m_vHandlersPool.push_back(tHandle);
  416. };
  417. } else {
  418. LOG_ERROR("Client Socket Error");
  419. switch (errno){
  420. //case EAGAIN: continue;
  421. case EWOULDBLOCK: LOG_ERROR(" The socket is marked non-blocking and no connections are present to be accepted."); break;
  422. case EBADF: LOG_ERROR(" The descriptor is invalid."); break;
  423. case ECONNABORTED: LOG_ERROR(" A connection has been aborted."); break;
  424. case EINTR:{// If Interrupted by Signal - No Harm was done
  425. LOG_ERROR(" The system call was interrupted by a signal that was caught before a valid connection arrived.");
  426. continue;
  427. };
  428. case EINVAL: LOG_ERROR(" Socket is not listening for connections, or addrlen is invalid (e.g., is negative)."); break;
  429. case EMFILE: LOG_ERROR(" The per-process limit of open file descriptors has been reached."); break;
  430. case ENFILE: LOG_ERROR(" The system limit on the total number of open files has been reached."); break;
  431. case ENOTSOCK: LOG_ERROR(" The descriptor references a file, not a socket."); break;
  432. case EOPNOTSUPP: LOG_ERROR(" The referenced socket is not of type SOCK_STREAM."); break;
  433. case EFAULT: LOG_ERROR(" The addr argument is not in a writable part of the user address space."); break;
  434. case ENOBUFS:
  435. case ENOMEM: LOG_ERROR(" Not enough free memory. This often means that the memory allocation is limited by the socket buffer limits, not by the system memory."); break;
  436. case EPROTO: LOG_ERROR(" Protocol error."); break;
  437. case EPERM: LOG_ERROR(" Firewall rules forbid connection."); break;
  438. case ENOSR:
  439. #ifdef __linux__
  440. case ESOCKTNOSUPPORT:
  441. #endif
  442. case EPROTONOSUPPORT:
  443. case ETIMEDOUT: LOG_ERROR(" Unusual error in Kernel (Timeout, No Socket Support in Kernel, Unsupported Protocol)"); break;
  444. #ifdef __linux__
  445. case ERESTARTSYS: LOG_ERROR(" Unusual error by Kernel"); break;
  446. #endif
  447. default: LOG_ERROR(" Unhandled error in Kernel"); break;
  448. };
  449. m_bThreadStatus = TH_ENDED;
  450. };
  451. };
  452. };
  453. LOG("Core Worker Thread Ended");
  454. };
  455. template <class HANDLER, class ENGINE> void networkServer<HANDLER, ENGINE>::dispatchEvent(basicEvent *Evt){
  456. if (Evt == NULL) return;
  457. if (Evt->m_eClass == EVT_CLASS_SYSTEM) {
  458. // Handle System Events
  459. };
  460. };
  461. #undef LOG
  462. #undef LOG_ERROR
  463. #endif