PostGIS  3.0.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 
65  coreIntHandler = pqsignal(SIGINT, handleInterrupt);
66 
67 #ifdef WIN32
68  GEOS_interruptRegisterCallback(interruptCallback);
69  lwgeom_register_interrupt_callback(interruptCallback);
70 #endif
71 
72  /* install PostgreSQL handlers */
73  pg_install_lwgeom_handlers();
74 }
75 
76 /*
77  * Module unload callback
78  */
79 void _PG_fini(void);
80 void
81 _PG_fini(void)
82 {
83  elog(NOTICE, "Goodbye from PostGIS %s", POSTGIS_VERSION);
84  pqsignal(SIGINT, coreIntHandler);
85 }
86 
87 
88 static void
90 {
91  /* NOTE: printf here would be dangerous, see
92  * https://trac.osgeo.org/postgis/ticket/3644
93  *
94  * TODO: block interrupts during execution, to fix the problem
95  */
96  /* printf("Interrupt requested\n"); fflush(stdout); */
97 
98  GEOS_interruptRequest();
99 
100 #ifdef HAVE_WAGYU
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:670
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
Definition: lwgeom_api.c:680
static void handleInterrupt(int sig)
void _PG_init(void)
PG_MODULE_MAGIC
void _PG_fini(void)
static pqsigfunc coreIntHandler