Browse Source

attempt to fix https://trac.osgeo.org/grass/ticket/2711 (segfault caused by db error handler)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65741 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 years ago
parent
commit
b741de342a
3 changed files with 14 additions and 1 deletions
  1. 1 0
      include/defs/dbmi.h
  2. 10 1
      lib/db/dbmi_client/handler.c
  3. 3 0
      lib/db/dbmi_client/shutdown.c

+ 1 - 0
include/defs/dbmi.h

@@ -332,6 +332,7 @@ int db_set_default_connection(void);
 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 *);

+ 10 - 1
lib/db/dbmi_client/handler.c

@@ -19,7 +19,6 @@ static void error_handler_driver(void *p)
     dbDriver *driver;
 
     driver = (dbDriver *) p;
-    
     db_close_database(driver);
     db_shutdown_driver(driver);
 }
@@ -40,3 +39,13 @@ void db_set_error_handler_driver(dbDriver *driver)
 {
     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);
+}

+ 3 - 0
lib/db/dbmi_client/shutdown.c

@@ -57,6 +57,9 @@ int db_shutdown_driver(dbDriver * driver)
 
     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);