Skip to content

Commit

Permalink
Avoid popping API context when one wasn't pushed (HDFGroup#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhendersonHDF committed Jul 22, 2021
1 parent 20dd1ce commit 96b6872
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2082,13 +2082,17 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props);
/* Push the API context */ \
if (H5CX_push() < 0) \
HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context") \
else \
api_ctx_pushed = TRUE; \
\
BEGIN_MPE_LOG

/* Use this macro for all "normal" API functions */
#define FUNC_ENTER_API(err) \
{ \
{ \
hbool_t api_ctx_pushed = FALSE; \
\
FUNC_ENTER_API_COMMON \
FUNC_ENTER_API_INIT(err); \
FUNC_ENTER_API_PUSH(err); \
Expand All @@ -2103,6 +2107,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props);
#define FUNC_ENTER_API_NOCLEAR(err) \
{ \
{ \
hbool_t api_ctx_pushed = FALSE; \
\
FUNC_ENTER_API_COMMON \
FUNC_ENTER_API_INIT(err); \
FUNC_ENTER_API_PUSH(err); \
Expand Down Expand Up @@ -2369,14 +2375,17 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props);
H5_API_SET_CANCEL

#define FUNC_LEAVE_API_COMMON(ret_value) \
; \
} /*end scope from end of FUNC_ENTER*/ \
FINISH_MPE_LOG \
H5TRACE_RETURN(ret_value);

#define FUNC_LEAVE_API(ret_value) \
; \
} /*end scope from end of FUNC_ENTER*/ \
FUNC_LEAVE_API_COMMON(ret_value); \
(void)H5CX_pop(TRUE); \
if (api_ctx_pushed) { \
(void)H5CX_pop(TRUE); \
api_ctx_pushed = FALSE; \
} \
H5_POP_FUNC \
if (err_occurred) \
(void)H5E_dump_api_stack(TRUE); \
Expand All @@ -2387,6 +2396,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props);

/* Use this macro to match the FUNC_ENTER_API_NOINIT macro */
#define FUNC_LEAVE_API_NOINIT(ret_value) \
; \
} /*end scope from end of FUNC_ENTER*/ \
FUNC_LEAVE_API_COMMON(ret_value); \
H5_POP_FUNC \
if (err_occurred) \
Expand All @@ -2399,6 +2410,8 @@ H5_DLL herr_t H5CX_pop(hbool_t update_dxpl_props);

/* Use this macro to match the FUNC_ENTER_API_NOINIT_NOERR_NOFS macro */
#define FUNC_LEAVE_API_NOFS(ret_value) \
; \
} /*end scope from end of FUNC_ENTER*/ \
FUNC_LEAVE_API_COMMON(ret_value); \
FUNC_LEAVE_API_THREADSAFE \
return (ret_value); \
Expand Down

0 comments on commit 96b6872

Please sign in to comment.