Commit 0c061f2a authored by Johannes Schindelin's avatar Johannes Schindelin

encodingstest: fix multi-threading issue

Signed-off-by: 's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
parent 2a2a60b0
...@@ -191,11 +191,13 @@ static void* clientLoop(void* data) { ...@@ -191,11 +191,13 @@ static void* clientLoop(void* data) {
return NULL; return NULL;
} }
static pthread_t all_threads[NUMBER_OF_ENCODINGS_TO_TEST];
static int thread_counter;
static void startClient(int encodingIndex,rfbScreenInfo* server) { static void startClient(int encodingIndex,rfbScreenInfo* server) {
rfbClient* client=rfbGetClient(8,3,4); rfbClient* client=rfbGetClient(8,3,4);
clientData* cd; clientData* cd;
pthread_t clientThread;
client->clientData=malloc(sizeof(clientData)); client->clientData=malloc(sizeof(clientData));
client->MallocFrameBuffer=resize; client->MallocFrameBuffer=resize;
client->GotFrameBufferUpdate=update; client->GotFrameBufferUpdate=update;
...@@ -210,7 +212,7 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) { ...@@ -210,7 +212,7 @@ static void startClient(int encodingIndex,rfbScreenInfo* server) {
lastUpdateRect.x2=server->width; lastUpdateRect.x2=server->width;
lastUpdateRect.y2=server->height; 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 */ /* Here begin the server functions */
...@@ -334,8 +336,10 @@ int main(int argc,char** argv) ...@@ -334,8 +336,10 @@ int main(int argc,char** argv)
} }
#endif #endif
free(server->frameBuffer);
rfbScreenCleanup(server); rfbScreenCleanup(server);
for(i=0;i<thread_counter;i++)
pthread_join(all_threads[i], NULL);
free(server->frameBuffer);
rfbLog("Statistics:\n"); rfbLog("Statistics:\n");
for(i=0;i<NUMBER_OF_ENCODINGS_TO_TEST;i++) for(i=0;i<NUMBER_OF_ENCODINGS_TO_TEST;i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment