PostGIS  3.1.6dev-r@@SVN_REVISION@@
postgis_module.c
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * PostGIS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * PostGIS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  **********************************************************************
20  *
21  * Copyright (C) 2011 OpenGeo.org
22  *
23  **********************************************************************/
24 
25 
26 #include "postgres.h"
27 #include "fmgr.h"
28 #include "utils/elog.h"
29 #include "utils/guc.h"
30 #include "libpq/pqsignal.h"
31 
32 #include "../postgis_config.h"
33 
34 #include "lwgeom_log.h"
35 #include "lwgeom_pg.h"
36 #include "geos_c.h"
37 
38 #ifdef HAVE_WAGYU
39 #include "lwgeom_wagyu.h"
40 #endif
41 
42 /*
43  * This is required for builds against pgsql
44  */
46 
47 static pqsigfunc coreIntHandler = 0;
48 static void handleInterrupt(int sig);
49 
50 #ifdef WIN32
51 static void interruptCallback() {
52  if (UNBLOCKED_SIGNAL_QUEUE())
53  pgwin32_dispatch_queued_signals();
54 }
55 #endif
56 
57 /*
58  * Module load callback
59  */
60 void _PG_init(void);
61 void
62 _PG_init(void)
63 {
64  coreIntHandler = pqsignal(SIGINT, handleInterrupt);
65 
66 #ifdef WIN32
67  GEOS_interruptRegisterCallback(interruptCallback);
68  lwgeom_register_interrupt_callback(interruptCallback);
69 #endif
70 
71  /* install PostgreSQL handlers */
72  pg_install_lwgeom_handlers();
73 }
74 
75 /*
76  * Module unload callback
77  */
78 void _PG_fini(void);
79 void
80 _PG_fini(void)
81 {
82  elog(NOTICE, "Goodbye from PostGIS %s", POSTGIS_VERSION);
83  pqsignal(SIGINT, coreIntHandler);
84 }
85 
86 
87 static void
89 {
90  /* NOTE: printf here would be dangerous, see
91  * https://trac.osgeo.org/postgis/ticket/3644
92  *
93  * TODO: block interrupts during execution, to fix the problem
94  */
95  /* printf("Interrupt requested\n"); fflush(stdout); */
96 
97  GEOS_interruptRequest();
98 
99 #ifdef HAVE_WAGYU
100 /* Taking out per #5385 crash */
101  //lwgeom_wagyu_interruptRequest();
102 #endif
103 
104  /* request interruption of liblwgeom as well */
106 
107  if ( coreIntHandler ) {
108  (*coreIntHandler)(sig);
109  }
110 }
void lwgeom_request_interrupt(void)
Request interruption of any running code.
Definition: lwgeom_api.c:664
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
Definition: lwgeom_api.c:674
static void handleInterrupt(int sig)
void _PG_init(void)
PG_MODULE_MAGIC
void _PG_fini(void)
static pqsigfunc coreIntHandler