texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Gavin D. Smith
Date: Sun, 20 Mar 2022 04:55:20 -0400 (EDT)

branch: master
commit ac9373b6e495096e2cfb508e9b143064b18ff544
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Oct 17 12:03:41 2019 +0100

    Do not create socket file in web process
    
    It is supposed to be deleted with atexit, but this doesn't work.
---
 js/infog/extension.c | 53 +++-------------------------------------------------
 js/infog/main.c      |  2 +-
 2 files changed, 4 insertions(+), 51 deletions(-)

diff --git a/js/infog/extension.c b/js/infog/extension.c
index 77cfd33898..82e79d9bfd 100644
--- a/js/infog/extension.c
+++ b/js/infog/extension.c
@@ -41,19 +41,10 @@ debug (int level, char *fmt, ...)
 static struct sockaddr_un main_name;
 static size_t main_name_size;
 
-/* Name of the socket that we create in this process to send to the socket
+/* The socket that we create in this process to send to the socket
    of the main process. */
-static char *our_socket_file;
 static int socket_id;
 
-static void
-remove_our_socket (void)
-{
-  if (our_socket_file)
-    unlink (our_socket_file);
-}
-
-
 void
 send_datagram (GString *s)
 {
@@ -443,12 +434,9 @@ web_page_created_callback (WebKitWebExtension *extension,
                       NULL, 0);
 }
 
-static void
-make_named_socket (const char *filename)
+void
+initialize_socket (const char *main_socket_file)
 {
-  struct sockaddr_un name;
-  size_t size;
-
   /* Create the socket. */
   socket_id = socket (PF_LOCAL, SOCK_DGRAM, 0);
   if (socket_id < 0)
@@ -457,41 +445,6 @@ make_named_socket (const char *filename)
       exit (EXIT_FAILURE);
     }
 
-  /* Bind a name to the socket. */
-  name.sun_family = AF_LOCAL;
-  strncpy (name.sun_path, filename, sizeof (name.sun_path));
-  name.sun_path[sizeof (name.sun_path) - 1] = '\0';
-
-  /* The size of the address is
-     the offset of the start of the filename,
-     plus its length (not including the terminating null byte).
-     Alternatively you can just do:
-     size = SUN_LEN (&name);
-   */
-  size = (offsetof (struct sockaddr_un, sun_path)
-         + strlen (name.sun_path));
-
-  if (bind (socket_id, (struct sockaddr *) &name, size) < 0)
-    {
-      perror ("bind (web process)");
-      exit (EXIT_FAILURE);
-    }
-  /* Do we really need to bind the socket if we are not receiving messages? */
-
-  atexit (&remove_our_socket);
-}
-
-void
-initialize_socket (const char *main_socket_file)
-{
-  if (!our_socket_file)
-    {
-      our_socket_file = tmpnam (0);
-      make_named_socket (our_socket_file);
-    }
-  else
-    g_print ("bug: web process initialized twice\n");
-
   /* Set the address of the socket in the main Gtk process. */
   main_name.sun_family = AF_LOCAL;
   strcpy (main_name.sun_path, main_socket_file);
diff --git a/js/infog/main.c b/js/infog/main.c
index 17c172ae53..cc8f6631f6 100644
--- a/js/infog/main.c
+++ b/js/infog/main.c
@@ -53,7 +53,7 @@ int socket_id;
 static void
 remove_socket (void)
 {
-  debug (1, "removing socket\n");
+  debug (1, "removing socket %s\n", socket_file);
   if (socket_file)
     unlink (socket_file);
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]