| 1021 | } |
| 1022 | |
| 1023 | int CMain::Run() |
| 1024 | { |
| 1025 | if(m_Server.Init(this, m_Config.m_aBindAddr, m_Config.m_Port)) |
| 1026 | return 1; |
| 1027 | |
| 1028 | if(ReadConfig()) |
| 1029 | return 1; |
| 1030 | |
| 1031 | // Start JSON Update Thread |
| 1032 | m_JSONUpdateThreadData.m_ReloadRequired = 2; |
| 1033 | m_JSONUpdateThreadData.pClients = m_aClients; |
| 1034 | m_JSONUpdateThreadData.pConfig = &m_Config; |
| 1035 | m_JSONUpdateThreadData.pWatchDogs = m_aCWatchDogs; |
| 1036 | m_JSONUpdateThreadData.pMain = this; |
| 1037 | void *LoadThread = thread_create(JSONUpdateThread, &m_JSONUpdateThreadData); |
| 1038 | // Start SSL check thread |
| 1039 | static SSLCheckThreadData sslData; sslData.pMain = this; thread_create(SSLCheckThread, &sslData); |
| 1040 | //thread_detach(LoadThread); |
| 1041 | |
| 1042 | while(gs_Running) |
| 1043 | { |
| 1044 | if(gs_ReloadConfig) |
| 1045 | { |
| 1046 | if(ReadConfig()) |
| 1047 | return 1; |
| 1048 | m_Server.NetBan()->UnbanAll(); |
| 1049 | gs_ReloadConfig = 0; |
| 1050 | } |
| 1051 | |
| 1052 | m_Server.Update(); |
| 1053 | |
| 1054 | // wait for incomming data |
| 1055 | net_socket_read_wait(*m_Server.Network()->Socket(), 10); |
| 1056 | } |
| 1057 | |
| 1058 | dbg_msg("server", "Closing."); |
| 1059 | m_Server.Network()->Close(); |
| 1060 | thread_wait(LoadThread); |
| 1061 | |
| 1062 | return 0; |
| 1063 | } |
| 1064 | |
| 1065 | int main(int argc, const char *argv[]) |
| 1066 | { |
no test coverage detected