mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-20 22:26:54 +01:00
add check for being on main thread
This commit is contained in:
parent
ec7fde3b62
commit
a65af79953
1 changed files with 10 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include "comtypes.h"
|
#include "comtypes.h"
|
||||||
|
|
||||||
typedef struct _RelayConStorage {
|
typedef struct _RelayConStorage {
|
||||||
|
pthread_t mainThread;
|
||||||
int socket;
|
int socket;
|
||||||
RelayConnProcs procs;
|
RelayConnProcs procs;
|
||||||
void* procsClosure;
|
void* procsClosure;
|
||||||
|
@ -202,6 +203,8 @@ relaycon_init( LaunchParams* params, const RelayConnProcs* procs,
|
||||||
XP_MEMCPY( &storage->procs, procs, sizeof(storage->procs) );
|
XP_MEMCPY( &storage->procs, procs, sizeof(storage->procs) );
|
||||||
storage->procsClosure = procsClosure;
|
storage->procsClosure = procsClosure;
|
||||||
|
|
||||||
|
storage->mainThread = pthread_self();
|
||||||
|
|
||||||
storage->socket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
|
storage->socket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
|
||||||
(*procs->socketAdded)( storage, storage->socket, relaycon_receive );
|
(*procs->socketAdded)( storage, storage->socket, relaycon_receive );
|
||||||
|
|
||||||
|
@ -360,6 +363,12 @@ relaycon_deleted( LaunchParams* params, const XP_UCHAR* devID,
|
||||||
sendIt( storage, tmpbuf, indx );
|
sendIt( storage, tmpbuf, indx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static XP_Bool
|
||||||
|
onMainThread( RelayConStorage* storage )
|
||||||
|
{
|
||||||
|
return storage->mainThread = pthread_self();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sendAckIf( RelayConStorage* storage, const MsgHeader* header )
|
sendAckIf( RelayConStorage* storage, const MsgHeader* header )
|
||||||
{
|
{
|
||||||
|
@ -579,6 +588,7 @@ static void*
|
||||||
postThread( void* arg )
|
postThread( void* arg )
|
||||||
{
|
{
|
||||||
PostArgs* pa = (PostArgs*)arg;
|
PostArgs* pa = (PostArgs*)arg;
|
||||||
|
XP_ASSERT( !onMainThread(pa->storage) );
|
||||||
char* data = g_base64_encode( pa->msgbuf, pa->len );
|
char* data = g_base64_encode( pa->msgbuf, pa->len );
|
||||||
struct json_object* jobj = json_object_new_object();
|
struct json_object* jobj = json_object_new_object();
|
||||||
struct json_object* jstr = json_object_new_string(data);
|
struct json_object* jstr = json_object_new_string(data);
|
||||||
|
|
Loading…
Reference in a new issue