comparison w32thread.c @ 10548:e68792a12c31 libavcodec

In win32 thread implementation do not access jobnr if the thread is asked to terminate, jobnr it does not point to a valid location in that case.
author reimar
date Fri, 20 Nov 2009 21:08:26 +0000
parents 5458953068fc
children d7ef6611a49e
comparison
equal deleted inserted replaced
10547:8a2d04d5deb9 10548:e68792a12c31
46 46
47 for(;;){ 47 for(;;){
48 int ret, jobnr; 48 int ret, jobnr;
49 //printf("thread_func %X enter wait\n", (int)v); fflush(stdout); 49 //printf("thread_func %X enter wait\n", (int)v); fflush(stdout);
50 WaitForSingleObject(c->work_sem, INFINITE); 50 WaitForSingleObject(c->work_sem, INFINITE);
51 // avoid trying to access jobnr if we should quit
52 if (!c->func && !c->func2)
53 break;
51 WaitForSingleObject(c->job_sem, INFINITE); 54 WaitForSingleObject(c->job_sem, INFINITE);
52 jobnr = (*c->jobnr)++; 55 jobnr = (*c->jobnr)++;
53 ReleaseSemaphore(c->job_sem, 1, 0); 56 ReleaseSemaphore(c->job_sem, 1, 0);
54 //printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout); 57 //printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout);
55 if(c->func) 58 if(c->func)
56 ret= c->func(c->avctx, (uint8_t *)c->arg + jobnr*c->argsize); 59 ret= c->func(c->avctx, (uint8_t *)c->arg + jobnr*c->argsize);
57 else if (c->func2) 60 else
58 ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr); 61 ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr);
59 else
60 return 0;
61 if (c->ret) 62 if (c->ret)
62 c->ret[jobnr] = ret; 63 c->ret[jobnr] = ret;
63 //printf("thread_func %X signal complete\n", (int)v); fflush(stdout); 64 //printf("thread_func %X signal complete\n", (int)v); fflush(stdout);
64 ReleaseSemaphore(c->done_sem, 1, 0); 65 ReleaseSemaphore(c->done_sem, 1, 0);
65 } 66 }