Skip to content

Commit e5cf2db

Browse files
committed
Merge pull request #1291 from jsquyres/pr/hotel-fix
opal hotel: only delete events that have not yet fired
2 parents eb65b5f + 270cc11 commit e5cf2db

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

opal/class/opal_hotel.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012 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$
@@ -24,12 +24,22 @@ static void local_eviction_callback(int fd, short flags, void *arg)
2424
(opal_hotel_room_eviction_callback_arg_t*) arg;
2525
void *occupant = eargs->hotel->rooms[eargs->room_num].occupant;
2626

27-
/* Remove the occupant from the room and invoke the user callback
28-
to tell them that they were evicted */
29-
opal_hotel_checkout(eargs->hotel, eargs->room_num);
30-
eargs->hotel->evict_callback_fn(eargs->hotel,
31-
eargs->room_num,
32-
occupant);
27+
/* Remove the occurpant from the room.
28+
29+
Do not change this logic without also changing the same logic
30+
in opal_hotel_checkout() and
31+
opal_hotel_checkout_and_return_occupant(). */
32+
opal_hotel_t *hotel = eargs->hotel;
33+
opal_hotel_room_t *room = &(hotel->rooms[eargs->room_num]);
34+
room->occupant = NULL;
35+
hotel->last_unoccupied_room++;
36+
assert(hotel->last_unoccupied_room < hotel->num_rooms);
37+
hotel->unoccupied_rooms[hotel->last_unoccupied_room] = eargs->room_num;
38+
39+
/* Invoke the user callback to tell them that they were evicted */
40+
hotel->evict_callback_fn(hotel,
41+
eargs->room_num,
42+
occupant);
3343
}
3444

3545

opal/class/opal_hotel.h

Lines changed: 12 additions & 1 deletion
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$
@@ -146,6 +146,11 @@ OBJ_CLASS_DECLARATION(opal_hotel_t);
146146
* will be set - occupants will remain checked into the hotel until
147147
* explicitly checked out.
148148
*
149+
* Also note: the eviction_callback_fn should absolutely not call any
150+
* of the hotel checkout functions. Specifically: the occupant has
151+
* already been ("forcibly") checked out *before* the
152+
* eviction_callback_fn is invoked.
153+
*
149154
* @return OPAL_SUCCESS if all initializations were succesful. Otherwise,
150155
* the error indicate what went wrong in the function.
151156
*/
@@ -244,6 +249,9 @@ static inline void opal_hotel_checkout(opal_hotel_t *hotel, int room_num)
244249
/* If there's an occupant in the room, check them out */
245250
room = &(hotel->rooms[room_num]);
246251
if (OPAL_LIKELY(NULL != room->occupant)) {
252+
/* Do not change this logic without also changing the same
253+
logic in opal_hotel_checkout_and_return_occupant() and
254+
opal_hotel.c:local_eviction_callback(). */
247255
room->occupant = NULL;
248256
if (NULL != hotel->evbase) {
249257
opal_event_del(&(room->eviction_timer_event));
@@ -280,6 +288,9 @@ static inline void opal_hotel_checkout_and_return_occupant(opal_hotel_t *hotel,
280288
room = &(hotel->rooms[room_num]);
281289
if (OPAL_LIKELY(NULL != room->occupant)) {
282290
opal_output (10, "checking out occupant %p from room num %d", room->occupant, room_num);
291+
/* Do not change this logic without also changing the same
292+
logic in opal_hotel_checkout() and
293+
opal_hotel.c:local_eviction_callback(). */
283294
*occupant = room->occupant;
284295
room->occupant = NULL;
285296
if (NULL != hotel->evbase) {

0 commit comments

Comments
 (0)