mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Merge pull request #1509 from ddnet/error-checking
More error checking in system.c (fixes #1317)
This commit is contained in:
commit
8b68a2859a
|
@ -125,7 +125,6 @@ void dbg_msg(const char *sys, const char *fmt, ...)
|
||||||
char str[1024*4];
|
char str[1024*4];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//str_format(str, sizeof(str), "[%08x][%s]: ", (int)time(0), sys);
|
|
||||||
char timestr[80];
|
char timestr[80];
|
||||||
str_timestamp_format(timestr, sizeof(timestr), FORMAT_SPACE);
|
str_timestamp_format(timestr, sizeof(timestr), FORMAT_SPACE);
|
||||||
|
|
||||||
|
@ -364,8 +363,7 @@ int io_close(IOHANDLE io)
|
||||||
|
|
||||||
int io_flush(IOHANDLE io)
|
int io_flush(IOHANDLE io)
|
||||||
{
|
{
|
||||||
fflush((FILE*)io);
|
return fflush((FILE*)io);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -524,7 +522,7 @@ ASYNCIO *aio_new(IOHANDLE io)
|
||||||
aio->finish = ASYNCIO_RUNNING;
|
aio->finish = ASYNCIO_RUNNING;
|
||||||
aio->refcount = 2;
|
aio->refcount = 2;
|
||||||
|
|
||||||
aio->thread = thread_init(aio_thread, aio);
|
aio->thread = thread_init(aio_thread, aio, "aio");
|
||||||
if(!aio->thread)
|
if(!aio->thread)
|
||||||
{
|
{
|
||||||
free(aio->buffer);
|
free(aio->buffer);
|
||||||
|
@ -706,7 +704,7 @@ static unsigned long __stdcall thread_run(void *user)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *thread_init(void (*threadfunc)(void *), void *u)
|
void *thread_init(void (*threadfunc)(void *), void *u, const char *name)
|
||||||
{
|
{
|
||||||
struct THREAD_RUN *data = malloc(sizeof(*data));
|
struct THREAD_RUN *data = malloc(sizeof(*data));
|
||||||
data->threadfunc = threadfunc;
|
data->threadfunc = threadfunc;
|
||||||
|
@ -714,8 +712,10 @@ void *thread_init(void (*threadfunc)(void *), void *u)
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
{
|
{
|
||||||
pthread_t id;
|
pthread_t id;
|
||||||
if(pthread_create(&id, NULL, thread_run, data) != 0)
|
int result = pthread_create(&id, NULL, thread_run, data);
|
||||||
|
if(result != 0)
|
||||||
{
|
{
|
||||||
|
dbg_msg("thread", "creating %s thread failed: %d", name, result);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (void*)id;
|
return (void*)id;
|
||||||
|
@ -744,7 +744,9 @@ void thread_wait(void *thread)
|
||||||
void thread_yield()
|
void thread_yield()
|
||||||
{
|
{
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
sched_yield();
|
int result = sched_yield();
|
||||||
|
if(result != 0)
|
||||||
|
dbg_msg("thread", "yield failed: %d", errno);
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
Sleep(0);
|
Sleep(0);
|
||||||
#else
|
#else
|
||||||
|
@ -755,7 +757,9 @@ void thread_yield()
|
||||||
void thread_sleep(int microseconds)
|
void thread_sleep(int microseconds)
|
||||||
{
|
{
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
usleep(microseconds);
|
int result = usleep(microseconds);
|
||||||
|
if(result == -1)
|
||||||
|
dbg_msg("thread", "sleep failed: %d", errno);
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
Sleep(microseconds/1000);
|
Sleep(microseconds/1000);
|
||||||
#else
|
#else
|
||||||
|
@ -766,7 +770,9 @@ void thread_sleep(int microseconds)
|
||||||
void thread_detach(void *thread)
|
void thread_detach(void *thread)
|
||||||
{
|
{
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
pthread_detach((pthread_t)(thread));
|
int result = pthread_detach((pthread_t)(thread));
|
||||||
|
if(result != 0)
|
||||||
|
dbg_msg("thread", "detach failed: %d", result);
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
CloseHandle(thread);
|
CloseHandle(thread);
|
||||||
#else
|
#else
|
||||||
|
@ -774,6 +780,13 @@ void thread_detach(void *thread)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *thread_init_and_detach(void (*threadfunc)(void *), void *u, const char *name)
|
||||||
|
{
|
||||||
|
void *thread = thread_init(threadfunc, u, name);
|
||||||
|
if(thread)
|
||||||
|
thread_detach(thread);
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -788,9 +801,20 @@ typedef CRITICAL_SECTION LOCKINTERNAL;
|
||||||
LOCK lock_create()
|
LOCK lock_create()
|
||||||
{
|
{
|
||||||
LOCKINTERNAL *lock = (LOCKINTERNAL *)malloc(sizeof(*lock));
|
LOCKINTERNAL *lock = (LOCKINTERNAL *)malloc(sizeof(*lock));
|
||||||
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
|
int result;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!lock)
|
||||||
|
return 0;
|
||||||
|
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
pthread_mutex_init(lock, 0x0);
|
result = pthread_mutex_init(lock, 0x0);
|
||||||
|
if(result != 0)
|
||||||
|
{
|
||||||
|
dbg_msg("lock", "init failed: %d", result);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
InitializeCriticalSection((LPCRITICAL_SECTION)lock);
|
InitializeCriticalSection((LPCRITICAL_SECTION)lock);
|
||||||
#else
|
#else
|
||||||
|
@ -802,7 +826,9 @@ LOCK lock_create()
|
||||||
void lock_destroy(LOCK lock)
|
void lock_destroy(LOCK lock)
|
||||||
{
|
{
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
pthread_mutex_destroy((LOCKINTERNAL *)lock);
|
int result = pthread_mutex_destroy((LOCKINTERNAL *)lock);
|
||||||
|
if(result != 0)
|
||||||
|
dbg_msg("lock", "destroy failed: %d", result);
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
DeleteCriticalSection((LPCRITICAL_SECTION)lock);
|
DeleteCriticalSection((LPCRITICAL_SECTION)lock);
|
||||||
#else
|
#else
|
||||||
|
@ -825,7 +851,9 @@ int lock_trylock(LOCK lock)
|
||||||
void lock_wait(LOCK lock)
|
void lock_wait(LOCK lock)
|
||||||
{
|
{
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
pthread_mutex_lock((LOCKINTERNAL *)lock);
|
int result = pthread_mutex_lock((LOCKINTERNAL *)lock);
|
||||||
|
if(result != 0)
|
||||||
|
dbg_msg("lock", "lock failed: %d", result);
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
EnterCriticalSection((LPCRITICAL_SECTION)lock);
|
EnterCriticalSection((LPCRITICAL_SECTION)lock);
|
||||||
#else
|
#else
|
||||||
|
@ -836,7 +864,9 @@ void lock_wait(LOCK lock)
|
||||||
void lock_unlock(LOCK lock)
|
void lock_unlock(LOCK lock)
|
||||||
{
|
{
|
||||||
#if defined(CONF_FAMILY_UNIX)
|
#if defined(CONF_FAMILY_UNIX)
|
||||||
pthread_mutex_unlock((LOCKINTERNAL *)lock);
|
int result = pthread_mutex_unlock((LOCKINTERNAL *)lock);
|
||||||
|
if(result != 0)
|
||||||
|
dbg_msg("lock", "unlock failed: %d", result);
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
LeaveCriticalSection((LPCRITICAL_SECTION)lock);
|
LeaveCriticalSection((LPCRITICAL_SECTION)lock);
|
||||||
#else
|
#else
|
||||||
|
@ -866,10 +896,28 @@ void sphore_destroy(SEMAPHORE *sem)
|
||||||
sem_unlink(aBuf);
|
sem_unlink(aBuf);
|
||||||
}
|
}
|
||||||
#elif defined(CONF_FAMILY_UNIX)
|
#elif defined(CONF_FAMILY_UNIX)
|
||||||
void sphore_init(SEMAPHORE *sem) { sem_init(sem, 0, 0); }
|
void sphore_init(SEMAPHORE *sem)
|
||||||
void sphore_wait(SEMAPHORE *sem) { sem_wait(sem); }
|
{
|
||||||
void sphore_signal(SEMAPHORE *sem) { sem_post(sem); }
|
if(sem_init(sem, 0, 0) != 0)
|
||||||
void sphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); }
|
dbg_msg("sphore", "init failed: %d", errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sphore_wait(SEMAPHORE *sem)
|
||||||
|
{
|
||||||
|
if(sem_wait(sem) != 0)
|
||||||
|
dbg_msg("sphore", "wait failed: %d", errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sphore_signal(SEMAPHORE *sem)
|
||||||
|
{
|
||||||
|
if(sem_post(sem) != 0)
|
||||||
|
dbg_msg("sphore", "post failed: %d", errno);
|
||||||
|
}
|
||||||
|
void sphore_destroy(SEMAPHORE *sem)
|
||||||
|
{
|
||||||
|
if(sem_destroy(sem) != 0)
|
||||||
|
dbg_msg("sphore", "destroy failed: %d", errno);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int new_tick = -1;
|
static int new_tick = -1;
|
||||||
|
@ -901,7 +949,11 @@ int64 time_get_impl()
|
||||||
return last;
|
return last;
|
||||||
#elif defined(CONF_FAMILY_UNIX)
|
#elif defined(CONF_FAMILY_UNIX)
|
||||||
struct timespec spec;
|
struct timespec spec;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &spec);
|
if(clock_gettime(CLOCK_MONOTONIC, &spec) != 0)
|
||||||
|
{
|
||||||
|
dbg_msg("clock", "gettime failed: %d", errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
last = (int64)spec.tv_sec*(int64)1000000 + (int64)spec.tv_nsec / 1000;
|
last = (int64)spec.tv_sec*(int64)1000000 + (int64)spec.tv_nsec / 1000;
|
||||||
return last;
|
return last;
|
||||||
#elif defined(CONF_FAMILY_WINDOWS)
|
#elif defined(CONF_FAMILY_WINDOWS)
|
||||||
|
@ -1247,7 +1299,8 @@ static void priv_net_close_socket(int sock)
|
||||||
#if defined(CONF_FAMILY_WINDOWS)
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
#else
|
#else
|
||||||
close(sock);
|
if(close(sock) != 0)
|
||||||
|
dbg_msg("socket", "close failed: %d", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1307,7 +1360,8 @@ static int priv_net_create_socket(int domain, int type, struct sockaddr *addr, i
|
||||||
if (domain == AF_INET && type == SOCK_STREAM)
|
if (domain == AF_INET && type == SOCK_STREAM)
|
||||||
{
|
{
|
||||||
int option = 1;
|
int option = 1;
|
||||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
|
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) != 0)
|
||||||
|
dbg_msg("socket", "Setting SO_REUSEADDR failed: %d", errno);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1316,7 +1370,8 @@ static int priv_net_create_socket(int domain, int type, struct sockaddr *addr, i
|
||||||
if(domain == AF_INET6)
|
if(domain == AF_INET6)
|
||||||
{
|
{
|
||||||
int ipv6only = 1;
|
int ipv6only = 1;
|
||||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&ipv6only, sizeof(ipv6only));
|
if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&ipv6only, sizeof(ipv6only)) != 0)
|
||||||
|
dbg_msg("socket", "Setting V6ONLY failed: %d", errno);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1362,13 +1417,15 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
|
||||||
sock.ipv4sock = socket;
|
sock.ipv4sock = socket;
|
||||||
|
|
||||||
/* set broadcast */
|
/* set broadcast */
|
||||||
setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast));
|
if(setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)) != 0)
|
||||||
|
dbg_msg("socket", "Setting BROADCAST on ipv4 failed: %d", errno);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* set DSCP/TOS */
|
/* set DSCP/TOS */
|
||||||
int iptos = 0x10 /* IPTOS_LOWDELAY */;
|
int iptos = 0x10 /* IPTOS_LOWDELAY */;
|
||||||
//int iptos = 46; /* High Priority */
|
//int iptos = 46; /* High Priority */
|
||||||
setsockopt(socket, IPPROTO_IP, IP_TOS, (char*)&iptos, sizeof(iptos));
|
if(setsockopt(socket, IPPROTO_IP, IP_TOS, (char*)&iptos, sizeof(iptos)) != 0)
|
||||||
|
dbg_msg("socket", "Setting TOS on ipv4 failed: %d", errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1407,13 +1464,15 @@ NETSOCKET net_udp_create(NETADDR bindaddr)
|
||||||
sock.ipv6sock = socket;
|
sock.ipv6sock = socket;
|
||||||
|
|
||||||
/* set broadcast */
|
/* set broadcast */
|
||||||
setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast));
|
if(setsockopt(socket, SOL_SOCKET, SO_BROADCAST, (const char*)&broadcast, sizeof(broadcast)) != 0)
|
||||||
|
dbg_msg("socket", "Setting BROADCAST on ipv6 failed: %d", errno);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* set DSCP/TOS */
|
/* set DSCP/TOS */
|
||||||
int iptos = 0x10 /* IPTOS_LOWDELAY */;
|
int iptos = 0x10 /* IPTOS_LOWDELAY */;
|
||||||
//int iptos = 46; /* High Priority */
|
//int iptos = 46; /* High Priority */
|
||||||
setsockopt(socket, IPPROTO_IP, IP_TOS, (char*)&iptos, sizeof(iptos));
|
if(setsockopt(socket, IPPROTO_IP, IP_TOS, (char*)&iptos, sizeof(iptos)) != 0)
|
||||||
|
dbg_msg("socket", "Setting TOS on ipv6 failed: %d", errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1692,7 +1751,8 @@ int net_set_non_blocking(NETSOCKET sock)
|
||||||
#if defined(CONF_FAMILY_WINDOWS)
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
ioctlsocket(sock.ipv4sock, FIONBIO, (unsigned long *)&mode);
|
ioctlsocket(sock.ipv4sock, FIONBIO, (unsigned long *)&mode);
|
||||||
#else
|
#else
|
||||||
ioctl(sock.ipv4sock, FIONBIO, (unsigned long *)&mode);
|
if(ioctl(sock.ipv4sock, FIONBIO, (unsigned long *)&mode) == -1)
|
||||||
|
dbg_msg("socket", "setting ipv4 non-blocking failed: %d", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,7 +1761,8 @@ int net_set_non_blocking(NETSOCKET sock)
|
||||||
#if defined(CONF_FAMILY_WINDOWS)
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
ioctlsocket(sock.ipv6sock, FIONBIO, (unsigned long *)&mode);
|
ioctlsocket(sock.ipv6sock, FIONBIO, (unsigned long *)&mode);
|
||||||
#else
|
#else
|
||||||
ioctl(sock.ipv6sock, FIONBIO, (unsigned long *)&mode);
|
if(ioctl(sock.ipv6sock, FIONBIO, (unsigned long *)&mode) == -1)
|
||||||
|
dbg_msg("socket", "setting ipv6 non-blocking failed: %d", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1716,7 +1777,8 @@ int net_set_blocking(NETSOCKET sock)
|
||||||
#if defined(CONF_FAMILY_WINDOWS)
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
ioctlsocket(sock.ipv4sock, FIONBIO, (unsigned long *)&mode);
|
ioctlsocket(sock.ipv4sock, FIONBIO, (unsigned long *)&mode);
|
||||||
#else
|
#else
|
||||||
ioctl(sock.ipv4sock, FIONBIO, (unsigned long *)&mode);
|
if(ioctl(sock.ipv4sock, FIONBIO, (unsigned long *)&mode) == -1)
|
||||||
|
dbg_msg("socket", "setting ipv4 blocking failed: %d", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1725,7 +1787,8 @@ int net_set_blocking(NETSOCKET sock)
|
||||||
#if defined(CONF_FAMILY_WINDOWS)
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
ioctlsocket(sock.ipv6sock, FIONBIO, (unsigned long *)&mode);
|
ioctlsocket(sock.ipv6sock, FIONBIO, (unsigned long *)&mode);
|
||||||
#else
|
#else
|
||||||
ioctl(sock.ipv6sock, FIONBIO, (unsigned long *)&mode);
|
if(ioctl(sock.ipv6sock, FIONBIO, (unsigned long *)&mode) == -1)
|
||||||
|
dbg_msg("socket", "setting ipv6 blocking failed: %d", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -487,9 +487,9 @@ void thread_sleep(int microseconds);
|
||||||
Parameters:
|
Parameters:
|
||||||
threadfunc - Entry point for the new thread.
|
threadfunc - Entry point for the new thread.
|
||||||
user - Pointer to pass to the thread.
|
user - Pointer to pass to the thread.
|
||||||
|
name - name describing the use of the thread
|
||||||
*/
|
*/
|
||||||
void *thread_init(void (*threadfunc)(void *), void *user);
|
void *thread_init(void (*threadfunc)(void *), void *user, const char *name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: thread_wait
|
Function: thread_wait
|
||||||
|
@ -517,6 +517,20 @@ void thread_yield();
|
||||||
*/
|
*/
|
||||||
void thread_detach(void *thread);
|
void thread_detach(void *thread);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: thread_init_and_detach
|
||||||
|
Creates a new thread and if it succeeded detaches it.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
threadfunc - Entry point for the new thread.
|
||||||
|
user - Pointer to pass to the thread.
|
||||||
|
name - name describing the use of the thread
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Returns the thread if no error occured, 0 on error.
|
||||||
|
*/
|
||||||
|
void *thread_init_and_detach(void (*threadfunc)(void *), void *user, const char *name);
|
||||||
|
|
||||||
/* Group: Locks */
|
/* Group: Locks */
|
||||||
typedef void* LOCK;
|
typedef void* LOCK;
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ void CGraphicsBackend_Threaded::StartProcessor(ICommandProcessor *pProcessor)
|
||||||
{
|
{
|
||||||
m_Shutdown = false;
|
m_Shutdown = false;
|
||||||
m_pProcessor = pProcessor;
|
m_pProcessor = pProcessor;
|
||||||
m_pThread = thread_init(ThreadFunc, this);
|
m_pThread = thread_init(ThreadFunc, this, "CGraphicsBackend_Threaded");
|
||||||
m_BufferDone.signal();
|
m_BufferDone.signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,8 @@ void CGraphicsBackend_Threaded::StopProcessor()
|
||||||
{
|
{
|
||||||
m_Shutdown = true;
|
m_Shutdown = true;
|
||||||
m_Activity.signal();
|
m_Activity.signal();
|
||||||
thread_wait(m_pThread);
|
if(m_pThread)
|
||||||
|
thread_wait(m_pThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphicsBackend_Threaded::RunBuffer(CCommandBuffer *pBuffer)
|
void CGraphicsBackend_Threaded::RunBuffer(CCommandBuffer *pBuffer)
|
||||||
|
|
|
@ -2585,10 +2585,7 @@ void CServer::ConAddSqlServer(IConsole::IResult *pResult, void *pUserData)
|
||||||
apSqlServers[i] = new CSqlServer(pResult->GetString(1), pResult->GetString(2), pResult->GetString(3), pResult->GetString(4), pResult->GetString(5), pResult->GetInteger(6), &pSelf->m_GlobalSqlLock, ReadOnly, SetUpDb);
|
apSqlServers[i] = new CSqlServer(pResult->GetString(1), pResult->GetString(2), pResult->GetString(3), pResult->GetString(4), pResult->GetString(5), pResult->GetInteger(6), &pSelf->m_GlobalSqlLock, ReadOnly, SetUpDb);
|
||||||
|
|
||||||
if(SetUpDb)
|
if(SetUpDb)
|
||||||
{
|
thread_init(CreateTablesThread, apSqlServers[i], "CreateTables");
|
||||||
void *TablesThread = thread_init(CreateTablesThread, apSqlServers[i]);
|
|
||||||
thread_detach(TablesThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
str_format(aBuf, sizeof(aBuf), "Added new Sql%sServer: %d: DB: '%s' Prefix: '%s' User: '%s' IP: '%s' Port: %d", ReadOnly ? "Read" : "Write", i, apSqlServers[i]->GetDatabase(), apSqlServers[i]->GetPrefix(), apSqlServers[i]->GetUser(), apSqlServers[i]->GetIP(), apSqlServers[i]->GetPort());
|
str_format(aBuf, sizeof(aBuf), "Added new Sql%sServer: %d: DB: '%s' Prefix: '%s' User: '%s' IP: '%s' Port: %d", ReadOnly ? "Read" : "Write", i, apSqlServers[i]->GetDatabase(), apSqlServers[i]->GetPrefix(), apSqlServers[i]->GetUser(), apSqlServers[i]->GetIP(), apSqlServers[i]->GetPort());
|
||||||
|
|
|
@ -44,7 +44,10 @@ CJobPool::~CJobPool()
|
||||||
for(int i = 0; i < m_NumThreads; i++)
|
for(int i = 0; i < m_NumThreads; i++)
|
||||||
sphore_signal(&m_Semaphore);
|
sphore_signal(&m_Semaphore);
|
||||||
for(int i = 0; i < m_NumThreads; i++)
|
for(int i = 0; i < m_NumThreads; i++)
|
||||||
thread_wait(m_apThreads[i]);
|
{
|
||||||
|
if(m_apThreads[i])
|
||||||
|
thread_wait(m_apThreads[i]);
|
||||||
|
}
|
||||||
lock_destroy(m_Lock);
|
lock_destroy(m_Lock);
|
||||||
sphore_destroy(&m_Semaphore);
|
sphore_destroy(&m_Semaphore);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +88,7 @@ void CJobPool::Init(int NumThreads)
|
||||||
// start threads
|
// start threads
|
||||||
m_NumThreads = NumThreads > MAX_THREADS ? MAX_THREADS : NumThreads;
|
m_NumThreads = NumThreads > MAX_THREADS ? MAX_THREADS : NumThreads;
|
||||||
for(int i = 0; i < NumThreads; i++)
|
for(int i = 0; i < NumThreads; i++)
|
||||||
m_apThreads[i] = thread_init(WorkerThread, this);
|
m_apThreads[i] = thread_init(WorkerThread, this, "CJobPool worker");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CJobPool::Add(std::shared_ptr<IJob> pJob)
|
void CJobPool::Add(std::shared_ptr<IJob> pJob)
|
||||||
|
|
|
@ -6019,8 +6019,7 @@ void CEditor::DoMapBorder()
|
||||||
|
|
||||||
void CEditor::CreateUndoStep()
|
void CEditor::CreateUndoStep()
|
||||||
{
|
{
|
||||||
void *CreateThread = thread_init(CreateUndoStepThread, this);
|
thread_init_and_detach(CreateUndoStepThread, this, "Editor Undo");
|
||||||
thread_detach(CreateThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEditor::CreateUndoStepThread(void *pUser)
|
void CEditor::CreateUndoStepThread(void *pUser)
|
||||||
|
|
|
@ -95,8 +95,7 @@ void CFileScore::SaveScoreThread(void *pUser)
|
||||||
|
|
||||||
void CFileScore::Save()
|
void CFileScore::Save()
|
||||||
{
|
{
|
||||||
void *pSaveThread = thread_init(SaveScoreThread, this);
|
thread_init_and_detach(SaveScoreThread, this, "FileScore save");
|
||||||
thread_detach(pSaveThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFileScore::Init()
|
void CFileScore::Init()
|
||||||
|
|
|
@ -57,8 +57,7 @@ m_pServer(pGameServer->Server())
|
||||||
|
|
||||||
CSqlConnector::ResetReachable();
|
CSqlConnector::ResetReachable();
|
||||||
|
|
||||||
void* InitThread = thread_init(ExecSqlFunc, new CSqlExecData(Init, new CSqlData()));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(Init, new CSqlData()), "SqlScore constructor");
|
||||||
thread_detach(InitThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,8 +165,7 @@ void CSqlScore::CheckBirthday(int ClientID)
|
||||||
CSqlPlayerData *Tmp = new CSqlPlayerData();
|
CSqlPlayerData *Tmp = new CSqlPlayerData();
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
Tmp->m_Name = Server()->ClientName(ClientID);
|
Tmp->m_Name = Server()->ClientName(ClientID);
|
||||||
void *CheckThread = thread_init(ExecSqlFunc, new CSqlExecData(CheckBirthdayThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(CheckBirthdayThread, Tmp), "birthday check");
|
||||||
thread_detach(CheckThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::CheckBirthdayThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::CheckBirthdayThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -218,8 +216,7 @@ void CSqlScore::LoadScore(int ClientID)
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
Tmp->m_Name = Server()->ClientName(ClientID);
|
Tmp->m_Name = Server()->ClientName(ClientID);
|
||||||
|
|
||||||
void *LoadThread = thread_init(ExecSqlFunc, new CSqlExecData(LoadScoreThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(LoadScoreThread, Tmp), "load score");
|
||||||
thread_detach(LoadThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update stuff
|
// update stuff
|
||||||
|
@ -284,8 +281,7 @@ void CSqlScore::MapVote(int ClientID, const char* MapName)
|
||||||
sqlstr::ClearString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
sqlstr::ClearString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
||||||
sqlstr::FuzzyString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
sqlstr::FuzzyString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
||||||
|
|
||||||
void *VoteThread = thread_init(ExecSqlFunc, new CSqlExecData(MapVoteThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(MapVoteThread, Tmp), "map vote");
|
||||||
thread_detach(VoteThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::MapVoteThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::MapVoteThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -381,8 +377,7 @@ void CSqlScore::MapInfo(int ClientID, const char* MapName)
|
||||||
sqlstr::ClearString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
sqlstr::ClearString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
||||||
sqlstr::FuzzyString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
sqlstr::FuzzyString(Tmp->m_aFuzzyMap, sizeof(Tmp->m_aFuzzyMap));
|
||||||
|
|
||||||
void *InfoThread = thread_init(ExecSqlFunc, new CSqlExecData(MapInfoThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(MapInfoThread, Tmp), "map info");
|
||||||
thread_detach(InfoThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::MapInfoThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::MapInfoThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -484,8 +479,7 @@ void CSqlScore::SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS
|
||||||
for(int i = 0; i < NUM_CHECKPOINTS; i++)
|
for(int i = 0; i < NUM_CHECKPOINTS; i++)
|
||||||
Tmp->m_aCpCurrent[i] = CpTime[i];
|
Tmp->m_aCpCurrent[i] = CpTime[i];
|
||||||
|
|
||||||
void *SaveThread = thread_init(ExecSqlFunc, new CSqlExecData(SaveScoreThread, Tmp, false));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(SaveScoreThread, Tmp, false), "save score");
|
||||||
thread_detach(SaveThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::SaveScoreThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::SaveScoreThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -590,8 +584,7 @@ void CSqlScore::SaveTeamScore(int* aClientIDs, unsigned int Size, float Time)
|
||||||
Tmp->m_Size = Size;
|
Tmp->m_Size = Size;
|
||||||
Tmp->m_Time = Time;
|
Tmp->m_Time = Time;
|
||||||
|
|
||||||
void *SaveTeamThread = thread_init(ExecSqlFunc, new CSqlExecData(SaveTeamScoreThread, Tmp, false));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(SaveTeamScoreThread, Tmp, false), "save team score");
|
||||||
thread_detach(SaveTeamThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::SaveTeamScoreThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::SaveTeamScoreThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -743,8 +736,7 @@ void CSqlScore::ShowRank(int ClientID, const char* pName, bool Search)
|
||||||
Tmp->m_Search = Search;
|
Tmp->m_Search = Search;
|
||||||
str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientID), sizeof(Tmp->m_aRequestingPlayer));
|
str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientID), sizeof(Tmp->m_aRequestingPlayer));
|
||||||
|
|
||||||
void *RankThread = thread_init(ExecSqlFunc, new CSqlExecData(ShowRankThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowRankThread, Tmp), "show rank");
|
||||||
thread_detach(RankThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::ShowRankThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::ShowRankThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -813,8 +805,7 @@ void CSqlScore::ShowTeamRank(int ClientID, const char* pName, bool Search)
|
||||||
Tmp->m_Search = Search;
|
Tmp->m_Search = Search;
|
||||||
str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientID), sizeof(Tmp->m_aRequestingPlayer));
|
str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientID), sizeof(Tmp->m_aRequestingPlayer));
|
||||||
|
|
||||||
void *TeamRankThread = thread_init(ExecSqlFunc, new CSqlExecData(ShowTeamRankThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowTeamRankThread, Tmp), "show team rank");
|
||||||
thread_detach(TeamRankThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::ShowTeamRankThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::ShowTeamRankThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -899,8 +890,7 @@ void CSqlScore::ShowTop5(IConsole::IResult *pResult, int ClientID, void *pUserDa
|
||||||
Tmp->m_Num = Debut;
|
Tmp->m_Num = Debut;
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
|
|
||||||
void *Top5Thread = thread_init(ExecSqlFunc, new CSqlExecData(ShowTop5Thread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowTop5Thread, Tmp), "show top5");
|
||||||
thread_detach(Top5Thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::ShowTop5Thread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::ShowTop5Thread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -960,8 +950,7 @@ void CSqlScore::ShowTeamTop5(IConsole::IResult *pResult, int ClientID, void *pUs
|
||||||
Tmp->m_Num = Debut;
|
Tmp->m_Num = Debut;
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
|
|
||||||
void *TeamTop5Thread = thread_init(ExecSqlFunc, new CSqlExecData(ShowTeamTop5Thread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowTeamTop5Thread, Tmp), "show team top5");
|
||||||
thread_detach(TeamTop5Thread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::ShowTeamTop5Thread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::ShowTeamTop5Thread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -1069,8 +1058,7 @@ void CSqlScore::ShowTimes(int ClientID, int Debut)
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
Tmp->m_Search = false;
|
Tmp->m_Search = false;
|
||||||
|
|
||||||
void *TimesThread = thread_init(ExecSqlFunc, new CSqlExecData(ShowTimesThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowTimesThread, Tmp), "show times");
|
||||||
thread_detach(TimesThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
|
void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
|
||||||
|
@ -1081,8 +1069,7 @@ void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
|
||||||
Tmp->m_Name = pName;
|
Tmp->m_Name = pName;
|
||||||
Tmp->m_Search = true;
|
Tmp->m_Search = true;
|
||||||
|
|
||||||
void *TimesThread = thread_init(ExecSqlFunc, new CSqlExecData(ShowTimesThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowTimesThread, Tmp), "show name's times");
|
||||||
thread_detach(TimesThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::ShowTimesThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::ShowTimesThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -1170,8 +1157,7 @@ void CSqlScore::ShowPoints(int ClientID, const char* pName, bool Search)
|
||||||
Tmp->m_Search = Search;
|
Tmp->m_Search = Search;
|
||||||
str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientID), sizeof(Tmp->m_aRequestingPlayer));
|
str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientID), sizeof(Tmp->m_aRequestingPlayer));
|
||||||
|
|
||||||
void *PointsThread = thread_init(ExecSqlFunc, new CSqlExecData(ShowPointsThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowPointsThread, Tmp), "show points");
|
||||||
thread_detach(PointsThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::ShowPointsThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::ShowPointsThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -1227,8 +1213,7 @@ void CSqlScore::ShowTopPoints(IConsole::IResult *pResult, int ClientID, void *pU
|
||||||
Tmp->m_Num = Debut;
|
Tmp->m_Num = Debut;
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
|
|
||||||
void *TopPointsThread = thread_init(ExecSqlFunc, new CSqlExecData(ShowTopPointsThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(ShowTopPointsThread, Tmp), "show top points");
|
||||||
thread_detach(TopPointsThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::ShowTopPointsThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::ShowTopPointsThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -1285,8 +1270,7 @@ void CSqlScore::RandomMap(int ClientID, int stars)
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
Tmp->m_Name = GameServer()->Server()->ClientName(ClientID);
|
Tmp->m_Name = GameServer()->Server()->ClientName(ClientID);
|
||||||
|
|
||||||
void *RandomThread = thread_init(ExecSqlFunc, new CSqlExecData(RandomMapThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(RandomMapThread, Tmp), "random map");
|
||||||
thread_detach(RandomThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::RandomMapThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::RandomMapThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -1343,8 +1327,7 @@ void CSqlScore::RandomUnfinishedMap(int ClientID, int stars)
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
Tmp->m_Name = GameServer()->Server()->ClientName(ClientID);
|
Tmp->m_Name = GameServer()->Server()->ClientName(ClientID);
|
||||||
|
|
||||||
void *RandomUnfinishedThread = thread_init(ExecSqlFunc, new CSqlExecData(RandomUnfinishedMapThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(RandomUnfinishedMapThread, Tmp), "random unfinished map");
|
||||||
thread_detach(RandomUnfinishedThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::RandomUnfinishedMapThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::RandomUnfinishedMapThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -1414,8 +1397,7 @@ void CSqlScore::SaveTeam(int Team, const char* Code, int ClientID, const char* S
|
||||||
Tmp->m_Code = Code;
|
Tmp->m_Code = Code;
|
||||||
str_copy(Tmp->m_Server, Server, sizeof(Tmp->m_Server));
|
str_copy(Tmp->m_Server, Server, sizeof(Tmp->m_Server));
|
||||||
|
|
||||||
void *SaveThread = thread_init(ExecSqlFunc, new CSqlExecData(SaveTeamThread, Tmp, false));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(SaveTeamThread, Tmp, false), "save team");
|
||||||
thread_detach(SaveThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::SaveTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::SaveTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
@ -1548,8 +1530,7 @@ void CSqlScore::LoadTeam(const char* Code, int ClientID)
|
||||||
Tmp->m_Code = Code;
|
Tmp->m_Code = Code;
|
||||||
Tmp->m_ClientID = ClientID;
|
Tmp->m_ClientID = ClientID;
|
||||||
|
|
||||||
void *LoadThread = thread_init(ExecSqlFunc, new CSqlExecData(LoadTeamThread, Tmp));
|
thread_init_and_detach(ExecSqlFunc, new CSqlExecData(LoadTeamThread, Tmp), "load team");
|
||||||
thread_detach(LoadThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSqlScore::LoadTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
bool CSqlScore::LoadTeamThread(CSqlServer* pSqlServer, const CSqlData *pGameData, bool HandleFailure)
|
||||||
|
|
|
@ -9,7 +9,7 @@ static void Nothing(void *pUser)
|
||||||
|
|
||||||
TEST(Thread, Detach)
|
TEST(Thread, Detach)
|
||||||
{
|
{
|
||||||
void *pThread = thread_init(Nothing, 0);
|
void *pThread = thread_init(Nothing, 0, "detach");
|
||||||
thread_detach(pThread);
|
thread_detach(pThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ static void SetToOne(void *pUser)
|
||||||
TEST(Thread, Wait)
|
TEST(Thread, Wait)
|
||||||
{
|
{
|
||||||
int Integer = 0;
|
int Integer = 0;
|
||||||
void *pThread = thread_init(SetToOne, &Integer);
|
void *pThread = thread_init(SetToOne, &Integer, "wait");
|
||||||
thread_wait(pThread);
|
thread_wait(pThread);
|
||||||
EXPECT_EQ(Integer, 1);
|
EXPECT_EQ(Integer, 1);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ TEST(Thread, SemaphoreMultiThreaded)
|
||||||
SEMAPHORE Semaphore;
|
SEMAPHORE Semaphore;
|
||||||
sphore_init(&Semaphore);
|
sphore_init(&Semaphore);
|
||||||
sphore_signal(&Semaphore);
|
sphore_signal(&Semaphore);
|
||||||
void *pThread = thread_init(SemaphoreThread, &Semaphore);
|
void *pThread = thread_init(SemaphoreThread, &Semaphore, "semaphore");
|
||||||
thread_wait(pThread);
|
thread_wait(pThread);
|
||||||
sphore_destroy(&Semaphore);
|
sphore_destroy(&Semaphore);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ TEST(Thread, Lock)
|
||||||
{
|
{
|
||||||
LOCK Lock = lock_create();
|
LOCK Lock = lock_create();
|
||||||
lock_wait(Lock);
|
lock_wait(Lock);
|
||||||
void *pThread = thread_init(LockThread, &Lock);
|
void *pThread = thread_init(LockThread, &Lock, "lock");
|
||||||
lock_unlock(Lock);
|
lock_unlock(Lock);
|
||||||
thread_wait(pThread);
|
thread_wait(pThread);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue