]> granicus.if.org Git - postgis/commitdiff
Install a signal handler to request GEOS interruption (#1802)
authorSandro Santilli <strk@keybit.net>
Mon, 28 May 2012 08:04:09 +0000 (08:04 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 28 May 2012 08:04:09 +0000 (08:04 +0000)
Requires GEOS-3.4.0SVN

git-svn-id: http://svn.osgeo.org/postgis/trunk@9824 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/postgis_module.c

index 045386e942fc52f78cc0863cd92aacd2efb9bc9d..121dff2efa7ff87f1f4c55f2fe9b695e9dc7f24a 100644 (file)
 #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);
+  }
+}