diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2009-10-02 11:47:29 +0200 |
---|---|---|
committer | Johannes Schindelin <johannes.schindelin@gmx.de> | 2009-10-02 11:50:08 +0200 |
commit | 0c061f2a2757384fb4f43c2462f649a1ba5a6c9e (patch) | |
tree | de8d4b12e7efb17d458016ba96b9abe60b0ba69b | |
parent | 2a2a60b007e6d21f75a803162f85ee36acf043aa (diff) | |
download | libtdevnc-0c061f2a2757384fb4f43c2462f649a1ba5a6c9e.tar.gz libtdevnc-0c061f2a2757384fb4f43c2462f649a1ba5a6c9e.zip |
encodingstest: fix multi-threading issue
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
-rw-r--r-- | test/encodingstest.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/test/encodingstest.c b/test/encodingstest.c index fc82348..bef30a8 100644 --- a/test/encodingstest.c +++ b/test/encodingstest.c @@ -191,11 +191,13 @@ static void* clientLoop(void* data) { return NULL; } +static pthread_t all_threads[NUMBER_OF_ENCODINGS_TO_TEST]; +static int thread_counter; + static void startClient(int encodingIndex,rfbScreenInfo* server) { rfbClient* client=rfbGetClient(8,3,4); clientData* cd; - pthread_t clientThread; - + client->clientData=malloc(sizeof(clientData)); client->MallocFrameBuffer=resize; client->GotFrameBufferUpdate=update; @@ -210,7 +212,7 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) { lastUpdateRect.x2=server->width; lastUpdateRect.y2=server->height; - pthread_create(&clientThread,NULL,clientLoop,(void*)client); + pthread_create(&all_threads[thread_counter++],NULL,clientLoop,(void*)client); } /* Here begin the server functions */ @@ -334,8 +336,10 @@ int main(int argc,char** argv) } #endif - free(server->frameBuffer); rfbScreenCleanup(server); + for(i=0;i<thread_counter;i++) + pthread_join(all_threads[i], NULL); + free(server->frameBuffer); rfbLog("Statistics:\n"); for(i=0;i<NUMBER_OF_ENCODINGS_TO_TEST;i++) |