From: Sandro Santilli Date: Mon, 28 May 2012 08:04:09 +0000 (+0000) Subject: Install a signal handler to request GEOS interruption (#1802) X-Git-Tag: 2.1.0beta2~967 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5234789a1cafb271fb30ec4b3e707b99004eafd9;p=postgis Install a signal handler to request GEOS interruption (#1802) Requires GEOS-3.4.0SVN git-svn-id: http://svn.osgeo.org/postgis/trunk@9824 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/postgis_module.c b/postgis/postgis_module.c index 045386e94..121dff2ef 100644 --- a/postgis/postgis_module.c +++ b/postgis/postgis_module.c @@ -14,16 +14,22 @@ #include "fmgr.h" #include "utils/elog.h" #include "utils/guc.h" +#include "libpq/pqsignal.h" #include "../postgis_config.h" + #include "lwgeom_log.h" #include "lwgeom_pg.h" +#include "geos_c.h" /* * This is required for builds against pgsql */ PG_MODULE_MAGIC; +static pqsigfunc coreIntHandler = 0; +static void handleInterrupt(int sig); + /* * Module load callback */ @@ -31,6 +37,9 @@ void _PG_init(void); void _PG_init(void) { + + coreIntHandler = pqsignal(SIGINT, handleInterrupt); + #if 0 /* Define custom GUC variables. */ DefineCustomIntVariable( @@ -81,4 +90,18 @@ _PG_fini(void) } +static void +handleInterrupt(int sig) +{ + printf("Interrupt requested\n"); fflush(stdout); +#if POSTGIS_GEOS_VERSION >= 34 + GEOS_interruptRequest(); +#endif + + /* TODO: request interruption of liblwgeom as well ? */ + + if ( coreIntHandler ) { + (*coreIntHandler)(sig); + } +}