SF.net SVN: geany: [432] trunk/src

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Jun 11 19:03:44 UTC 2006


Revision: 432
Author:   eht16
Date:     2006-06-11 12:03:39 -0700 (Sun, 11 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=432&view=rev

Log Message:
-----------
Improved the handling of GIOChannels(for named pipes), ensure they are closed in a proper way.

Modified Paths:
--------------
    trunk/src/callbacks.c
    trunk/src/geany.h
    trunk/src/main.c
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-06-11 14:08:10 UTC (rev 431)
+++ trunk/src/callbacks.c	2006-06-11 19:03:39 UTC (rev 432)
@@ -101,6 +101,11 @@
 	{
 		gchar *fifo = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL);
 		// delete the fifo early, because we don't accept new files anymore
+		if (app->fifo_ioc != NULL)
+		{
+			g_io_channel_unref(app->fifo_ioc);
+			g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL);
+		}
 		unlink(fifo);
 		g_free(fifo);
 	}

Modified: trunk/src/geany.h
===================================================================
--- trunk/src/geany.h	2006-06-11 14:08:10 UTC (rev 431)
+++ trunk/src/geany.h	2006-06-11 19:03:39 UTC (rev 432)
@@ -60,7 +60,7 @@
 #define GEANY_HOME_DIR					g_get_home_dir()
 #define GEANY_FILEDEFS_SUBDIR			"filedefs"
 #define GEANY_FIFO_NAME					"geany_fifo.0"
-#define GEANY_CODENAME					"Ravik"
+#define GEANY_CODENAME					"Kadir"
 #define GEANY_HOMEPAGE					"http://geany.uvena.de/"
 #define GEANY_MAX_OPEN_FILES			25
 #define GEANY_SESSION_FILES				25
@@ -159,6 +159,7 @@
 	gint				 long_line_column;
 #ifdef HAVE_FIFO
 	gboolean			 ignore_fifo;
+	GIOChannel			*fifo_ioc;
 #endif
 #ifdef HAVE_VTE
 	gboolean			 load_vte;

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2006-06-11 14:08:10 UTC (rev 431)
+++ trunk/src/main.c	2006-06-11 19:03:39 UTC (rev 432)
@@ -335,8 +335,10 @@
 		return TRUE;
 	else
 	{
-		GIOChannel *ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK));
-		g_io_add_watch(ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL);
+		g_io_channel_unref(app->fifo_ioc);
+		g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL);
+		app->fifo_ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK));
+		g_io_add_watch(app->fifo_ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL);
 		return FALSE;
 	}
 }
@@ -362,7 +364,7 @@
 
 /* creates a named pipe in GEANY_FIFO_NAME, to communicate with new instances of Geany
  * to submit filenames and possibly other things */
-static void create_fifo(gint argc, gchar **argv, const gchar *config_dir)
+static GIOChannel *create_fifo(gint argc, gchar **argv, const gchar *config_dir)
 {
 	struct stat st;
 	gchar *tmp;
@@ -400,11 +402,13 @@
 	if ((mkfifo(fifo_name, S_IRUSR | S_IWUSR)) == -1)
 	{
 		if (errno != EEXIST) geany_debug("creating of a named pipe for IPC failed! (%s)", g_strerror(errno));
-		return;
+		return NULL;
 	}
 
 	ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK));
 	g_io_add_watch(ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL);
+
+	return ioc;
 }
 #endif
 
@@ -413,6 +417,9 @@
 {
 	GError *error = NULL;
 	GOptionContext *context;
+#ifdef HAVE_FIFO
+	GIOChannel *ioc = NULL;
+#endif
 	gint mkdir_result = 0;
 	gint idx;
 	gchar *config_dir;
@@ -454,7 +461,7 @@
 	}
 
 #ifdef HAVE_FIFO
-	if (! ignore_fifo) create_fifo(argc, argv, config_dir);
+	if (! ignore_fifo) ioc = create_fifo(argc, argv, config_dir);
 #endif
 	g_free(config_dir);
 
@@ -474,7 +481,9 @@
 	app->have_vte = app->load_vte;
 	if (no_vte) app->have_vte = FALSE;
 #endif
-
+#ifdef HAVE_FIFO
+	app->fifo_ioc = ioc;
+#endif
 	filetypes_init_types();
 	configuration_read_filetype_extensions();
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list