Skip to content

Commit 5de4ab8

Browse files
committed
opal hotel: only delete events that have not yet fired
The opal_hotel_checkout() function (and _checkout_and_return_occupant()) can be called manually or it can be invoked by the eviction callback. When it is invoked by the eviction callback, we do not want to opal_event_del() the eviction callback.
1 parent ac34c0e commit 5de4ab8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

opal/class/opal_hotel.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012-2013 Cisco Systems, Inc. All rights reserved.
2+
* Copyright (c) 2012-2016 Cisco Systems, Inc. All rights reserved.
33
* Copyright (c) 2012 Los Alamos National Security, LLC. All rights reserved
44
* Copyright (c) 2015 Intel, Inc. All rights reserved.
55
* $COPYRIGHT$
@@ -245,7 +245,11 @@ static inline void opal_hotel_checkout(opal_hotel_t *hotel, int room_num)
245245
room = &(hotel->rooms[room_num]);
246246
if (OPAL_LIKELY(NULL != room->occupant)) {
247247
room->occupant = NULL;
248-
if (NULL != hotel->evbase) {
248+
/* Only delete the eviction event if it has not already fired.
249+
Specifically: don't delete the event if this function was
250+
invoked by the eviction timeout! */
251+
if (NULL != hotel->evbase &&
252+
opal_event_evtimer_pending(&room->eviction_timer_event, NULL)) {
249253
opal_event_del(&(room->eviction_timer_event));
250254
}
251255
hotel->last_unoccupied_room++;
@@ -282,7 +286,14 @@ static inline void opal_hotel_checkout_and_return_occupant(opal_hotel_t *hotel,
282286
opal_output (10, "checking out occupant %p from room num %d", room->occupant, room_num);
283287
*occupant = room->occupant;
284288
room->occupant = NULL;
285-
if (NULL != hotel->evbase) {
289+
/* Only delete the eviction event if it has not already fired.
290+
Specifically: don't delete the event if this function was
291+
invoked by the eviction timeout! (this check is somewhat
292+
redundant because as of this writing, the eviction timeout
293+
does not call this function, but this is good defensive
294+
programming). */
295+
if (NULL != hotel->evbase &&
296+
opal_event_evtimer_pending(&room->eviction_timer_event, NULL)) {
286297
opal_event_del(&(room->eviction_timer_event));
287298
}
288299
hotel->last_unoccupied_room++;

0 commit comments

Comments
 (0)