1616 * Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1717 * reserved.
1818 * Copyright (c) 2013-2015 NVIDIA Corporation. All rights reserved.
19- * Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
19+ * Copyright (c) 2014-2016 Intel, Inc. All rights reserved.
2020 * Copyright (c) 2014-2015 Research Organization for Information Science
2121 * and Technology (RIST). All rights reserved.
2222 * $COPYRIGHT$
@@ -387,8 +387,7 @@ static int mca_btl_tcp_component_open(void)
387387
388388static int mca_btl_tcp_component_close (void )
389389{
390- opal_list_item_t * item ;
391- opal_list_item_t * next ;
390+ mca_btl_tcp_event_t * event , * next ;
392391
393392 if (NULL != mca_btl_tcp_component .tcp_btls ) {
394393 free (mca_btl_tcp_component .tcp_btls );
@@ -407,17 +406,12 @@ static int mca_btl_tcp_component_close(void)
407406 }
408407#endif
409408
410- /* cleanup any pending events */
411- MCA_BTL_TCP_CRITICAL_SECTION_ENTER (& mca_btl_tcp_component .tcp_lock );
412- for (item = opal_list_get_first (& mca_btl_tcp_component .tcp_events );
413- item != opal_list_get_end (& mca_btl_tcp_component .tcp_events );
414- item = next ) {
415- mca_btl_tcp_event_t * event = (mca_btl_tcp_event_t * )item ;
416- next = opal_list_get_next (item );
417- opal_event_del (& event -> event );
418- OBJ_RELEASE (event );
419- }
420- MCA_BTL_TCP_CRITICAL_SECTION_LEAVE (& mca_btl_tcp_component .tcp_lock );
409+ /* remove all pending events. Do not lock the tcp_events list as
410+ * the event themselves will unregister during the destructor. */
411+ OPAL_LIST_FOREACH_SAFE (event , next , & mca_btl_tcp_component .tcp_events , mca_btl_tcp_event_t ) {
412+ opal_event_del (& event -> event );
413+ OBJ_RELEASE (event );
414+ }
421415
422416 /* release resources */
423417 OBJ_DESTRUCT (& mca_btl_tcp_component .tcp_procs );
0 commit comments