Commit a44c53d6 authored by Xin Zhao's avatar Xin Zhao
Browse files

Bug-fix: first dequeue lock entry from queue, then perform op in this entry

Here we should first dequeue the current lock queue entry from
lock queue then performing the operation in it. This is because
when performing op in current lock entry, we may trigger
release_lock() function, which go to check the lock queue again.
If we did not remove current entry from the queue, release_lock()
will try to process it for the second time, which leads to the wrong
execution.

No reviewer.
parent 68984ea9
......@@ -1408,14 +1408,13 @@ int MPIDI_CH3I_Release_lock(MPID_Win *win_ptr)
if (lock_entry->all_data_recved) {
MPIDI_CH3_PKT_RMA_GET_LOCK_TYPE(lock_entry->pkt, requested_lock, mpi_errno);
if (MPIDI_CH3I_Try_acquire_win_lock(win_ptr, requested_lock) == 1) {
/* perform this OP */
/* dequeue entry from lock queue */
MPL_LL_DELETE(win_ptr->lock_queue, win_ptr->lock_queue_tail, lock_entry);
/* perform this OP */
mpi_errno = perform_op_in_lock_queue(win_ptr, lock_entry);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
/* dequeue entry from lock queue */
MPL_LL_DELETE(win_ptr->lock_queue, win_ptr->lock_queue_tail, lock_entry);
/* free this entry */
mpi_errno = MPIDI_CH3I_Win_lock_entry_free(win_ptr, lock_entry);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
......@@ -1476,13 +1475,13 @@ int MPIDI_CH3_ReqHandler_PiggybackLockOpRecvComplete( MPIDI_VC_t *vc,
MPID_Win_get_ptr(target_win_handle, win_ptr);
if (MPIDI_CH3I_Try_acquire_win_lock(win_ptr, requested_lock) == 1) {
/* dequeue entry from lock queue */
MPL_LL_DELETE(win_ptr->lock_queue, win_ptr->lock_queue_tail, lock_queue_entry);
/* perform this OP */
mpi_errno = perform_op_in_lock_queue(win_ptr, lock_queue_entry);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
/* dequeue entry from lock queue */
MPL_LL_DELETE(win_ptr->lock_queue, win_ptr->lock_queue_tail, lock_queue_entry);
/* free this entry */
mpi_errno = MPIDI_CH3I_Win_lock_entry_free(win_ptr, lock_queue_entry);
if (mpi_errno != MPI_SUCCESS) MPIU_ERR_POP(mpi_errno);
......
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