PostGIS  2.2.7dev-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  * Copyright (C) 2011 OpenGeo.org
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU General Public Licence. See the COPYING file.
10  *
11  **********************************************************************/
12 
13 #include "postgres.h"
14 #include "fmgr.h"
15 #include "utils/elog.h"
16 #include "utils/guc.h"
17 #include "libpq/pqsignal.h"
18 
19 #include "../postgis_config.h"
20 
21 #include "lwgeom_log.h"
22 #include "lwgeom_pg.h"
23 #include "geos_c.h"
24 #include "lwgeom_backend_api.h"
25 
26 /*
27  * This is required for builds against pgsql
28  */
30 
31 static pqsigfunc coreIntHandler = 0;
32 static void handleInterrupt(int sig);
33 
34 #ifdef WIN32
35 static void interruptCallback() {
36  if (UNBLOCKED_SIGNAL_QUEUE())
37  pgwin32_dispatch_queued_signals();
38 }
39 #endif
40 
41 /*
42  * Module load callback
43  */
44 void _PG_init(void);
45 void
46 _PG_init(void)
47 {
48 
49  coreIntHandler = pqsignal(SIGINT, handleInterrupt);
50 
51 #ifdef WIN32
52 #if POSTGIS_GEOS_VERSION >= 34
53  GEOS_interruptRegisterCallback(interruptCallback);
54 #endif
55  lwgeom_register_interrupt_callback(interruptCallback);
56 #endif
57 
58 #if 0
59  /* Define custom GUC variables. */
60  DefineCustomIntVariable(
61  "postgis.debug.level", /* name */
62  "Sets the debugging level of PostGIS.", /* short_desc */
63  "This is an experimental configuration.", /* long_desc */
64  &postgis_debug_level, /* valueAddr */
65  0, 8, /* min-max */
66  0, /* bootValue */
67  PGC_SUSET, /* GucContext context */
68  GUC_UNIT_MS, /* int flags */
69 #if POSTGIS_PGSQL_VERSION >= 91
70  NULL, /* GucStringCheckHook check_hook */
71 #endif
72  NULL, /* GucStringAssignHook assign_hook */
73  NULL /* GucShowHook show_hook */
74  );
75 #endif
76 
77 #if 0
78  /* Define custom GUC variables. */
79  DefineCustomStringVariable(
80  "postgis.greeting.string", /* name */
81  "Sets the greeting string used on postgis module load.", /* short_desc */
82  "This is an experimental configuration.", /* long_desc */
83  &greeting, /* valueAddr */
84  "Welcome to PostGIS " POSTGIS_VERSION, /* bootValue */
85  PGC_SUSET, /* GucContext context */
86  GUC_UNIT_MS, /* int flags */
87 #if POSTGIS_PGSQL_VERSION >= 91
88  NULL, /* GucStringCheckHook check_hook */
89 #endif
90  NULL, /* GucStringAssignHook assign_hook */
91  NULL /* GucShowHook show_hook */
92  );
93 #endif
94 
95  /* install PostgreSQL handlers */
96  pg_install_lwgeom_handlers();
97 
98  /* initialize geometry backend */
100 }
101 
102 /*
103  * Module unload callback
104  */
105 void _PG_fini(void);
106 void
107 _PG_fini(void)
108 {
109  elog(NOTICE, "Goodbye from PostGIS %s", POSTGIS_VERSION);
110  pqsignal(SIGINT, coreIntHandler);
111 }
112 
113 
114 static void
116 {
117  /* NOTE: printf here would be dangerous, see
118  * https://trac.osgeo.org/postgis/ticket/3644
119  *
120  * TODO: block interrupts during execution, to fix the problem
121  */
122  /* printf("Interrupt requested\n"); fflush(stdout); */
123 
124 #if POSTGIS_GEOS_VERSION >= 34
125  GEOS_interruptRequest();
126 #endif
127 
128  /* request interruption of liblwgeom as well */
130 
131  if ( coreIntHandler ) {
132  (*coreIntHandler)(sig);
133  }
134 }
static pqsigfunc coreIntHandler
void lwgeom_request_interrupt(void)
Request interruption of any running code.
Definition: lwgeom_api.c:824
void _PG_fini(void)
void lwgeom_init_backend()
#define POSTGIS_PGSQL_VERSION
Definition: sqldefines.h:9
void _PG_init(void)
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *)
Definition: lwgeom_api.c:834
PG_MODULE_MAGIC
static void handleInterrupt(int sig)