From f8ff5df2f37f6208e0bfd70b250afcecf3404721 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Fri, 13 Mar 2015 16:32:35 -0400 Subject: [PATCH] fix race conditions --- src/groupchat.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/groupchat.c b/src/groupchat.c index 1e782a9..fe23739 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -783,7 +783,9 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m) mvwvline(ctx->sidebar, 0, 0, ACS_VLINE, y2 - CHATBOX_HEIGHT); mvwaddch(ctx->sidebar, y2 - CHATBOX_HEIGHT, 0, ACS_BTEE); + pthread_mutex_lock(&Winthread.lock); int num_peers = groupchats[self->num].num_peers; + pthread_mutex_unlock(&Winthread.lock); wmove(ctx->sidebar, 0, 1); wattron(ctx->sidebar, A_BOLD); @@ -803,11 +805,16 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m) /* truncate nick to fit in side panel without modifying list */ char tmpnck[TOX_MAX_NAME_LENGTH]; int maxlen = SIDEBAR_WIDTH - 2; + pthread_mutex_lock(&Winthread.lock); memcpy(tmpnck, &groupchats[self->num].peer_names[peer * TOX_MAX_NAME_LENGTH], maxlen); + pthread_mutex_unlock(&Winthread.lock); tmpnck[maxlen] = '\0'; /* TODO: Make this not poll */ + pthread_mutex_lock(&Winthread.lock); uint8_t status = tox_group_get_status(m, self->num, i); + pthread_mutex_unlock(&Winthread.lock); + int colour = WHITE; if (status == TOX_GS_AWAY)