Skip to content

Commit 912a728

Browse files
committed
check and add pending in same critical region
1 parent 8345a74 commit 912a728

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/src/unifyfs_p2p_rpc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ int add_pending_remote_request(int peer_rank,
203203

204204
*preqp = NULL;
205205

206+
ABT_mutex_lock(pending_remote_requests_abt_sync);
207+
206208
bool have_pending = check_pending_remote_request(peer_rank, gfid,
207209
op, &preq);
208210
if (have_pending) {
@@ -228,8 +230,6 @@ int add_pending_remote_request(int peer_rank,
228230
ret = UNIFYFS_SUCCESS;
229231
}
230232

231-
ABT_mutex_lock(pending_remote_requests_abt_sync);
232-
233233
if ((NULL != client_req) && have_pending) {
234234
/* add client request to pending remote */
235235
if (NULL == preq->pending_client_reqs) {
@@ -290,10 +290,11 @@ bool check_pending_remote_request(int peer_rank,
290290
server_rpc_e op,
291291
p2p_request** preqp)
292292
{
293+
// NOTE: this method assumes caller has locked sync mutex
294+
293295
bool is_pending = false;
294296
p2p_request* pending;
295297

296-
ABT_mutex_lock(pending_remote_requests_abt_sync);
297298
if (NULL != pending_remote_requests) {
298299
int num_pending = arraylist_size(pending_remote_requests);
299300
for (int i = 0; i < num_pending; i++) {
@@ -311,7 +312,6 @@ bool check_pending_remote_request(int peer_rank,
311312
} else {
312313
LOGERR("pending_remote_requests is NULL!");
313314
}
314-
ABT_mutex_unlock(pending_remote_requests_abt_sync);
315315

316316
return is_pending;
317317
}

0 commit comments

Comments
 (0)