Skip to content

Commit 310d61e

Browse files
author
DvirDukhan
committed
better code style
1 parent 1b97882 commit 310d61e

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/background_workers.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ static void _BGThread_ExecutionFinish(RunQueueInfo *run_queue_info, RedisAI_RunI
154154
}
155155

156156
static void _BGThread_Execute(RunQueueInfo *run_queue_info, RedisAI_RunInfo **batch_rinfo) {
157-
pthread_mutex_unlock(&run_queue_info->run_queue_mutex);
158157
uint n_rinfo = array_len(batch_rinfo);
159158
if(n_rinfo != 0) {
160159
bool batched_run = n_rinfo > 1;
@@ -166,9 +165,6 @@ static void _BGThread_Execute(RunQueueInfo *run_queue_info, RedisAI_RunInfo **ba
166165
RedisAI_DagRunSessionStep(batch_rinfo[0], run_queue_info->devicestr);
167166
}
168167
}
169-
// Lock the queue again: we're done operating on evicted items only.
170-
pthread_mutex_lock(&run_queue_info->run_queue_mutex);
171-
_BGThread_ExecutionFinish(run_queue_info, batch_rinfo);
172168
}
173169

174170
static RedisAI_RunInfo** _BGThread_BatchOperations(RunQueueInfo *run_queue_info, RedisAI_RunInfo *rinfo,RedisAI_RunInfo **batch_rinfo) {
@@ -317,8 +313,11 @@ void *RedisAI_Run_ThreadMain(void *arg) {
317313
// safely unlock the queue mutex, to allow other threads to operate
318314
// on the same queue. The evicted items at this point are only visible
319315
// to this worker.
320-
316+
pthread_mutex_unlock(&run_queue_info->run_queue_mutex);
321317
_BGThread_Execute(run_queue_info, batch_rinfo);
318+
// Lock the queue again: we're done operating on evicted items only.
319+
pthread_mutex_lock(&run_queue_info->run_queue_mutex);
320+
_BGThread_ExecutionFinish(run_queue_info, batch_rinfo);
322321

323322
}
324323
}

src/run_info.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ long long RAI_DagRunInfoFreeShallowCopy(RedisAI_RunInfo *rinfo) {
146146
}
147147

148148
void RAI_FreeRunInfo(struct RedisAI_RunInfo *rinfo) {
149-
if (!rinfo) {
150-
return;
151-
}
149+
RedisModule_Assert(rinfo);
152150
long long ref_count = *rinfo->dagRefCount;
153151
RedisModule_Assert(ref_count == 0);
154152
pthread_rwlock_destroy(rinfo->dagLock);

0 commit comments

Comments
 (0)