1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 19:23:25 +01:00

fix race conditions

This commit is contained in:
Jfreegman 2015-03-13 16:32:35 -04:00
parent 22acba5aa8
commit f8ff5df2f3
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -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)