Changeset: e80aacbcdea1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e80aacbcdea1
Modified Files:
        cmake/monetdb-defines.cmake
        monetdb_config.h.in
        sql/common/exception_buffer.c
        sql/include/exception_buffer.h
Branch: Jun2023
Log Message:

Use sigsetjmp/siglongjmp when available, and don't save signal mask.
Not saving the mask is default on Linux and the desired behavior, but on
the Mac, it is not the default and causes mserver5 to be unstoppable
after a call to eb_error (longjmp).


diffs (56 lines):

diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake
--- a/cmake/monetdb-defines.cmake
+++ b/cmake/monetdb-defines.cmake
@@ -106,6 +106,7 @@ function(monetdb_configure_defines)
   check_function_exists("setsid" HAVE_SETSID)
   check_function_exists("shutdown" HAVE_SHUTDOWN)
   check_function_exists("sigaction" HAVE_SIGACTION)
+  check_function_exists("siglongjmp" HAVE_SIGLONGJMP)
   check_symbol_exists("stpcpy" "string.h" HAVE_STPCPY)
   check_function_exists("strcasestr" HAVE_STRCASESTR)
   check_symbol_exists("strncasecmp" "strings.h" HAVE_STRNCASECMP)
diff --git a/monetdb_config.h.in b/monetdb_config.h.in
--- a/monetdb_config.h.in
+++ b/monetdb_config.h.in
@@ -158,6 +158,7 @@
 #cmakedefine HAVE_SETSID 1
 #cmakedefine HAVE_SHUTDOWN 1
 #cmakedefine HAVE_SIGACTION 1
+#cmakedefine HAVE_SIGLONGJMP 1
 #cmakedefine HAVE_STPCPY 1
 #cmakedefine HAVE_STRCASESTR 1
 #cmakedefine HAVE_STRNCASECMP 1
diff --git a/sql/common/exception_buffer.c b/sql/common/exception_buffer.c
--- a/sql/common/exception_buffer.c
+++ b/sql/common/exception_buffer.c
@@ -29,5 +29,9 @@ eb_error( exception_buffer *eb, char *ms
        eb->code = val;
        eb->msg = msg;
        eb->enabled = 0;                        /* not any longer... */
+#ifdef HAVE_SIGLONGJMP
+       siglongjmp(eb->state, eb->code);
+#else
        longjmp(eb->state, eb->code);
+#endif
 }
diff --git a/sql/include/exception_buffer.h b/sql/include/exception_buffer.h
--- a/sql/include/exception_buffer.h
+++ b/sql/include/exception_buffer.h
@@ -21,10 +21,14 @@ typedef struct exception_buffer {
        int enabled;
 } exception_buffer;
 
-extern exception_buffer *eb_init( exception_buffer *eb );
+extern exception_buffer *eb_init(exception_buffer *eb);
 
 /* != 0 on when we return to the savepoint */
-#define eb_savepoint(eb) ((eb)->enabled=1,setjmp((eb)->state))
-extern _Noreturn void eb_error( exception_buffer *eb, char *msg, int val );
+#ifdef HAVE_SIGLONGJMP
+#define eb_savepoint(eb) ((eb)->enabled = 1, sigsetjmp((eb)->state, 0))
+#else
+#define eb_savepoint(eb) ((eb)->enabled = 1, setjmp((eb)->state))
+#endif
+extern _Noreturn void eb_error(exception_buffer *eb, char *msg, int val);
 
 #endif /* EXCEPTION_BUFFER_H */
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to