Skip to content

Commit d6daf79

Browse files
committed
Take the lock while accessing transform[] array.
1 parent a7f6b30 commit d6daf79

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/asyncproxy.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,15 @@ asyncproxy_run(void *args)
277277
eidx = i;
278278
goto out;
279279
}
280-
if (ap->transform[i] != NULL) {
280+
pthread_mutex_lock(&ap->mutex);
281+
void (*transform)(void *, int) = ap->transform[i];
282+
pthread_mutex_unlock(&ap->mutex);
283+
if (transform != NULL) {
281284
#if defined(PYTHON_AWARE)
282285
PyGILState_STATE gstate;
283286
gstate = PyGILState_Ensure();
284287
#endif
285-
ap->transform[i](BUF_P(&bufs[i]), r.len);
288+
transform(BUF_P(&bufs[i]), r.len);
286289
#if defined(PYTHON_AWARE)
287290
PyGILState_Release(gstate);
288291
#endif

0 commit comments

Comments
 (0)