Commit e5bae0a5 authored by reimar's avatar reimar

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.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@20565 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent c8aed7d8
...@@ -48,16 +48,17 @@ static unsigned WINAPI attribute_align_arg thread_func(void *v){ ...@@ -48,16 +48,17 @@ static unsigned WINAPI attribute_align_arg thread_func(void *v){
int ret, jobnr; int ret, jobnr;
//printf("thread_func %X enter wait\n", (int)v); fflush(stdout); //printf("thread_func %X enter wait\n", (int)v); fflush(stdout);
WaitForSingleObject(c->work_sem, INFINITE); WaitForSingleObject(c->work_sem, INFINITE);
// avoid trying to access jobnr if we should quit
if (!c->func && !c->func2)
break;
WaitForSingleObject(c->job_sem, INFINITE); WaitForSingleObject(c->job_sem, INFINITE);
jobnr = (*c->jobnr)++; jobnr = (*c->jobnr)++;
ReleaseSemaphore(c->job_sem, 1, 0); ReleaseSemaphore(c->job_sem, 1, 0);
//printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout); //printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout);
if(c->func) if(c->func)
ret= c->func(c->avctx, (uint8_t *)c->arg + jobnr*c->argsize); ret= c->func(c->avctx, (uint8_t *)c->arg + jobnr*c->argsize);
else if (c->func2)
ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr);
else else
return 0; ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr);
if (c->ret) if (c->ret)
c->ret[jobnr] = ret; c->ret[jobnr] = ret;
//printf("thread_func %X signal complete\n", (int)v); fflush(stdout); //printf("thread_func %X signal complete\n", (int)v); fflush(stdout);
......
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