[GRASS-SVN] r67290 - in grass/trunk/lib/db: dbmi_client dbmi_driver

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 20 14:27:33 PST 2015


Author: martinl
Date: 2015-12-20 14:27:33 -0800 (Sun, 20 Dec 2015)
New Revision: 67290

Modified:
   grass/trunk/lib/db/dbmi_client/shutdown.c
   grass/trunk/lib/db/dbmi_client/start.c
   grass/trunk/lib/db/dbmi_driver/driver.c
Log:
Hangs when closing db drivers (#2775)

Modified: grass/trunk/lib/db/dbmi_client/shutdown.c
===================================================================
--- grass/trunk/lib/db/dbmi_client/shutdown.c	2015-12-20 22:13:07 UTC (rev 67289)
+++ grass/trunk/lib/db/dbmi_client/shutdown.c	2015-12-20 22:27:33 UTC (rev 67290)
@@ -37,10 +37,8 @@
 {
     int status;
 
-#ifdef __MINGW32__
     db__set_protocol_fds(driver->send, driver->recv);
     DB_START_PROCEDURE_CALL(DB_PROC_SHUTDOWN_DRIVER);
-#endif
 
     /* close the communication FILEs */
     fclose(driver->send);

Modified: grass/trunk/lib/db/dbmi_client/start.c
===================================================================
--- grass/trunk/lib/db/dbmi_client/start.c	2015-12-20 22:13:07 UTC (rev 67289)
+++ grass/trunk/lib/db/dbmi_client/start.c	2015-12-20 22:27:33 UTC (rev 67290)
@@ -28,6 +28,13 @@
 #define READ  0
 #define WRITE 1
 
+void close_on_exec(int fd)
+{
+#ifndef __MINGW32__
+    int flags = fcntl(fd, F_GETFD);
+    fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+#endif
+}
 
 /*!
   \brief Initialize a new dbDriver for db transaction.
@@ -132,6 +139,11 @@
 	return (dbDriver *) NULL;
     }
 
+    close_on_exec(p1[READ]);
+    close_on_exec(p1[WRITE]);
+    close_on_exec(p2[READ]);
+    close_on_exec(p2[WRITE]);
+
     pid = G_spawn_ex(startup,
 		     SF_BACKGROUND,
 		     SF_REDIRECT_DESCRIPTOR, 0, p1[READ],

Modified: grass/trunk/lib/db/dbmi_driver/driver.c
===================================================================
--- grass/trunk/lib/db/dbmi_driver/driver.c	2015-12-20 22:13:07 UTC (rev 67289)
+++ grass/trunk/lib/db/dbmi_driver/driver.c	2015-12-20 22:27:33 UTC (rev 67290)
@@ -139,12 +139,10 @@
     stat = DB_OK;
     /* get the procedure number */
     while (db__recv_procnum(&procnum) == DB_OK) {
-#ifdef __MINGW32__
 	if (procnum == DB_PROC_SHUTDOWN_DRIVER) {
 	    db__send_procedure_ok(procnum);
 	    break;
 	}
-#endif
 	db_clear_error();
 
 	/* find this procedure */



More information about the grass-commit mailing list