[FFmpeg-devel] [PATCH 3/5] avfilter/dnn: fix the return value of async_thread_routine

lance.lmwang at gmail.com lance.lmwang at gmail.com
Thu Dec 9 14:35:24 EET 2021


On Thu, Dec 09, 2021 at 11:55:14AM +0000, Guo, Yejun wrote:
> 
> 
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of lance.lmwang at gmail.com
> Sent: 2021年12月9日 9:20
> To: ffmpeg-devel at ffmpeg.org
> Cc: Limin Wang <lance.lmwang at gmail.com>
> Subject: [FFmpeg-devel] [PATCH 3/5] avfilter/dnn: fix the return value of async_thread_routine
> 
> From: Limin Wang <lance.lmwang at gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
>  libavfilter/dnn/dnn_backend_common.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_common.c b/libavfilter/dnn/dnn_backend_common.c
> index 6a9c4cc..8c020e5 100644
> --- a/libavfilter/dnn/dnn_backend_common.c
> +++ b/libavfilter/dnn/dnn_backend_common.c
> @@ -83,10 +83,13 @@ static void *async_thread_routine(void *args)
>      void *request = async_module->args;
>  
>      if (async_module->start_inference(request) != DNN_SUCCESS) {
> -        return DNN_ASYNC_FAIL;
> +        pthread_exit((void*)DNN_ASYNC_FAIL);
> +        return NULL;
> 
> Could you share the reason for this change?
> From man pthread_exit:
> Performing a return from the start function of any thread other than the main  thread  results  in  an  implicit  call  to
> pthread_exit(), using the function's return value as the thread's exit status.
it's void * for the thread function, so I think it's right to return NULL instead of error code. Most of usage is 
pthread_exit(NULL). I want to keep the old code return, so use (void*) for that, I'm not sure it's good idea or not.

> 
>      }
>      async_module->callback(request);
> -    return DNN_ASYNC_SUCCESS;
> +
> +    pthread_exit((void*)DNN_ASYNC_SUCCESS);
> +    return NULL;
>  }
>  
>  DNNReturnType ff_dnn_async_module_cleanup(DNNAsyncExecModule *async_module)
> -- 
> 1.8.3.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang


More information about the ffmpeg-devel mailing list