[GRASS-SVN] r67369 - in grass/branches/releasebranch_7_0/lib/db: dbmi_client dbmi_driver

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 24 08:16:42 PST 2015


Author: martinl
Date: 2015-12-24 08:16:42 -0800 (Thu, 24 Dec 2015)
New Revision: 67369

Modified:
   grass/branches/releasebranch_7_0/lib/db/dbmi_client/shutdown.c
   grass/branches/releasebranch_7_0/lib/db/dbmi_client/start.c
   grass/branches/releasebranch_7_0/lib/db/dbmi_driver/driver.c
Log:
Hangs when closing db drivers (bugfix #2775)
      (merge r67290, r67367 from trunk)


Modified: grass/branches/releasebranch_7_0/lib/db/dbmi_client/shutdown.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/db/dbmi_client/shutdown.c	2015-12-24 16:09:00 UTC (rev 67368)
+++ grass/branches/releasebranch_7_0/lib/db/dbmi_client/shutdown.c	2015-12-24 16:16:42 UTC (rev 67369)
@@ -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/branches/releasebranch_7_0/lib/db/dbmi_client/start.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/db/dbmi_client/start.c	2015-12-24 16:09:00 UTC (rev 67368)
+++ grass/branches/releasebranch_7_0/lib/db/dbmi_client/start.c	2015-12-24 16:16:42 UTC (rev 67369)
@@ -28,6 +28,13 @@
 #define READ  0
 #define WRITE 1
 
+static 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/branches/releasebranch_7_0/lib/db/dbmi_driver/driver.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/db/dbmi_driver/driver.c	2015-12-24 16:09:00 UTC (rev 67368)
+++ grass/branches/releasebranch_7_0/lib/db/dbmi_driver/driver.c	2015-12-24 16:16:42 UTC (rev 67369)
@@ -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