]> granicus.if.org Git - postgis/commitdiff
Turn custom allocators into an occasion for interruption (#1802)
authorSandro Santilli <strk@keybit.net>
Fri, 4 May 2012 11:21:18 +0000 (11:21 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 4 May 2012 11:21:18 +0000 (11:21 +0000)
This change allows interrupting any function at allocation time.
Doesn't allow interrupting loops not invoking custom allocators
(includes GEOS, so far).

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

libpgcommon/lwgeom_pg.c

index 308f1d136d6024832b6c8aec5c43bc56c25e87f1..2afd8cf60ee56850c0a82c108670a7df41ae105c 100644 (file)
@@ -17,6 +17,7 @@
 #include <postgres.h>
 #include <fmgr.h>
 #include <executor/spi.h>
+#include <miscadmin.h>
 
 #include "../postgis_config.h"
 #include "liblwgeom.h"
@@ -116,6 +117,8 @@ pg_alloc(size_t size)
 {
        void * result;
 
+       CHECK_FOR_INTERRUPTS(); /* give interrupter a chance */
+
        POSTGIS_DEBUGF(5, "  pg_alloc(%d) called", (int)size);
 
        result = palloc(size);
@@ -135,6 +138,8 @@ pg_realloc(void *mem, size_t size)
 {
        void * result;
 
+       CHECK_FOR_INTERRUPTS(); /* give interrupter a chance */
+
        POSTGIS_DEBUGF(5, "  pg_realloc(%p, %d) called", mem, (int)size);
 
        result = repalloc(mem, size);