[GRASS-SVN] r65741 - in grass/trunk: include/defs lib/db/dbmi_client

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 21 02:46:46 PDT 2015


Author: martinl
Date: 2015-07-21 02:46:46 -0700 (Tue, 21 Jul 2015)
New Revision: 65741

Modified:
   grass/trunk/include/defs/dbmi.h
   grass/trunk/lib/db/dbmi_client/handler.c
   grass/trunk/lib/db/dbmi_client/shutdown.c
Log:
attempt to fix #2711 (segfault caused by db error handler)


Modified: grass/trunk/include/defs/dbmi.h
===================================================================
--- grass/trunk/include/defs/dbmi.h	2015-07-21 09:38:35 UTC (rev 65740)
+++ grass/trunk/include/defs/dbmi.h	2015-07-21 09:46:46 UTC (rev 65741)
@@ -332,6 +332,7 @@
 void db_set_error_who(const char *);
 int db_set_handle(dbHandle *, const char *, const char *);
 void db_set_error_handler_driver(dbDriver *);
+void db_unset_error_handler_driver(dbDriver *);
 int db_set_index_column_name(dbIndex *, int,
 			     const char *);
 int db_set_index_name(dbIndex *, const char *);

Modified: grass/trunk/lib/db/dbmi_client/handler.c
===================================================================
--- grass/trunk/lib/db/dbmi_client/handler.c	2015-07-21 09:38:35 UTC (rev 65740)
+++ grass/trunk/lib/db/dbmi_client/handler.c	2015-07-21 09:46:46 UTC (rev 65741)
@@ -19,7 +19,6 @@
     dbDriver *driver;
 
     driver = (dbDriver *) p;
-    
     db_close_database(driver);
     db_shutdown_driver(driver);
 }
@@ -40,3 +39,13 @@
 {
     G_add_error_handler(error_handler_driver, driver);
 }
+
+/*!
+  \brief Remove error handler before closing the driver
+
+  \param driver DB driver
+*/
+void db_unset_error_handler_driver(dbDriver *driver)
+{
+    G_remove_error_handler(error_handler_driver, driver);
+}

Modified: grass/trunk/lib/db/dbmi_client/shutdown.c
===================================================================
--- grass/trunk/lib/db/dbmi_client/shutdown.c	2015-07-21 09:38:35 UTC (rev 65740)
+++ grass/trunk/lib/db/dbmi_client/shutdown.c	2015-07-21 09:46:46 UTC (rev 65741)
@@ -57,6 +57,9 @@
 
     driver->pid = 0;
 
+    /* remove also error handler if defined */
+    db_unset_error_handler_driver(driver);
+    
     /* free the driver structure. THIS IS GOOFY */
     db_free(driver);
 



More information about the grass-commit mailing list