Revision: 2244 http://geany.svn.sourceforge.net/geany/?rev=2244&view=rev Author: eht16 Date: 2008-02-10 04:36:32 -0800 (Sun, 10 Feb 2008)
Log Message: ----------- Use a random integer as part of socket file name instead of current time stamp. Before creating a new socket, delete a maybe existing socket and its symlink.
Modified Paths: -------------- trunk/ChangeLog trunk/src/socket.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-02-10 12:35:38 UTC (rev 2243) +++ trunk/ChangeLog 2008-02-10 12:36:32 UTC (rev 2244) @@ -1,3 +1,19 @@ +2008-02-10 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/navqueue.c, src/navqueue.h, src/symbols.c, src/treeviews.c: + Apply patch from Yura Siamashka to fix wrong navigation queue items + (thanks). + * src/editor.c: + Add workaround for a Scintilla bug in HTML/PHP lexer which styles the + last line of document wrong when in PHP mode. + * README.Packagers: Add some notes for package maintainers. + * src/socket.c: + Use a random integer as part of socket file name instead of current + time stamp. + Before creating a new socket, delete a maybe existing socket and its + symlink. + + 2008-02-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/project.c: @@ -6,7 +22,7 @@ Remove prefix from win32_get_file_filters() and win32_get_filters(). Fix some encoding problems with filenames retrieved from the native Windows file dialogs. - * src/sci_wrappers.c: + * src/sciwrappers.c: Fix wrong placement of long line marker (closes #1889392).
Modified: trunk/src/socket.c =================================================================== --- trunk/src/socket.c 2008-02-10 12:35:38 UTC (rev 2243) +++ trunk/src/socket.c 2008-02-10 12:36:32 UTC (rev 2244) @@ -40,6 +40,14 @@ * to mark the end of data send a single '.'. Each message should be ended with \n. * * At the moment the commands open, line and column are available. + * + * About the socket files on Unix-like systems: + * Geany creates a socket in /tmp(or any other directory returned by g_get_tmp_dir()) and it creates + * a symlink in the current configuration to the created socket file. The symlink is named + * geany_socket.dispnum (dispnum is the number of the active X display). + * If the socket file in the temporara directory could not be created, Geany creates the socket file + * directly in the configuration directory as a fallback. + * */
@@ -151,6 +159,25 @@ }
+static void remove_socket_link_full() +{ + gchar real_path[512]; + gsize len; + + real_path[0] = '\0'; + + // read the contents of the symbolic link socket_info.file_name and delete it + // readlink should return something like "/tmp/geany_socket.1202396669" + len = readlink(socket_info.file_name, real_path, sizeof(real_path) - 1); + if ((gint) len > 0) + { + real_path[len] = '\0'; + g_unlink(real_path); + } + g_unlink(socket_info.file_name); +} + + /* (Unix domain) socket support to replace the old FIFO code * (taken from Sylpheed, thanks) */ gint socket_init(gint argc, gchar **argv) @@ -199,7 +226,7 @@ sock = socket_fd_connect_unix(socket_info.file_name); if (sock < 0) { - g_unlink(socket_info.file_name); + remove_socket_link_full(); // deletes the socket file and the symlink return socket_fd_open_unix(socket_info.file_name); } #endif @@ -233,20 +260,7 @@ #else if (socket_info.file_name != NULL) { - gchar real_path[512]; - gsize len; - - real_path[0] = '\0'; - - // read the contents of the symbolic link socket_info.file_name and delete it - // readlink should return something like "/tmp/geany_socket.1202396669" - len = readlink(socket_info.file_name, real_path, sizeof(real_path) - 1); - if ((gint) len > 0) - { - real_path[len] = '\0'; - g_unlink(real_path); - } - g_unlink(socket_info.file_name); + remove_socket_link_full(); // deletes the socket file and the symlink g_free(socket_info.file_name); } #endif @@ -309,8 +323,8 @@ // in case the configuration directory is located on a network file system or any other // file system which doesn't support sockets, we just link the socket there and create the // real socket in the system's tmp directory assuming it supports sockets - real_path = g_strdup_printf("%s%cgeany_socket.%d", - g_get_tmp_dir(), G_DIR_SEPARATOR, (gint) time(NULL)); + real_path = g_strdup_printf("%s%cgeany_socket.%08x", + g_get_tmp_dir(), G_DIR_SEPARATOR, g_random_int());
if (utils_is_file_writeable(real_path) != 0) { // if real_path is not writable for us, fall back to /home/user/.geany/geany_socket
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.