@@ -175,10 +175,11 @@ void *RedisAI_Run_ThreadMain(void *arg) {
175175 if (timedOut == 1 ) {
176176 queueEvict (run_queue_info -> run_queue , item );
177177
178+ RedisAI_RunInfo * orig = rinfo -> orig_copy ;
178179 long long dagRefCount = RAI_DagRunInfoFreeShallowCopy (rinfo );
179180 if (dagRefCount == 0 ) {
180- RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo * )rinfo ;
181- rinfo -> OnFinish (finish_ctx , rinfo -> private_data );
181+ RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo * )orig ;
182+ orig -> OnFinish (finish_ctx , orig -> private_data );
182183 }
183184
184185 queueItem * evicted_item = item ;
@@ -413,10 +414,11 @@ void *RedisAI_Run_ThreadMain(void *arg) {
413414 // If there was an error and the reference count for the dag
414415 // has gone to zero and the client is still around, we unblock
415416 if (dagError ) {
417+ RedisAI_RunInfo * orig = rinfo -> orig_copy ;
416418 long long dagRefCount = RAI_DagRunInfoFreeShallowCopy (rinfo );
417419 if (dagRefCount == 0 ) {
418- RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo * )rinfo ;
419- rinfo -> OnFinish (finish_ctx , rinfo -> private_data );
420+ RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo * )orig ;
421+ orig -> OnFinish (finish_ctx , orig -> private_data );
420422 }
421423 } else {
422424 rinfo -> dagDeviceCompleteOpCount += 1 ;
@@ -433,22 +435,22 @@ void *RedisAI_Run_ThreadMain(void *arg) {
433435 int dag_complete_after_run = RedisAI_DagComplete (batch_rinfo [0 ]);
434436
435437 long long dagRefCount = -1 ;
436-
438+ RedisAI_RunInfo * orig ;
437439 if (device_complete == 1 || device_complete_after_run == 1 ) {
438- RedisAI_RunInfo * evicted_rinfo = (RedisAI_RunInfo * )(evicted_items [0 ]-> value );
439- // We decrease and get the reference count for the DAG
440+ RedisAI_RunInfo * evicted_rinfo = (RedisAI_RunInfo * )(evicted_items [0 ]-> value );
441+ orig = evicted_rinfo -> orig_copy ;
442+ // We decrease and get the reference count for the DAG.
440443 dagRefCount = RAI_DagRunInfoFreeShallowCopy (evicted_rinfo );
441444 }
442445
443446 // If the DAG was complete, then it's time to unblock the client
444447 if (do_unblock == 1 || dag_complete_after_run == 1 ) {
445- RedisAI_RunInfo * evicted_rinfo = (RedisAI_RunInfo * )(evicted_items [0 ]-> value );
446448
447449 // If the reference count for the DAG is zero and the client is still around,
448450 // then we actually unblock the client
449451 if (dagRefCount == 0 ) {
450- RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo * )evicted_rinfo ;
451- evicted_rinfo -> OnFinish (finish_ctx , evicted_rinfo -> private_data );
452+ RedisAI_OnFinishCtx finish_ctx = (RedisAI_RunInfo * )orig ;
453+ orig -> OnFinish (finish_ctx , orig -> private_data );
452454 }
453455 }
454456
0 commit comments