]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: AF_UNIX: adapt send_sock_info to mqueues
authorKen Brown <kbrown@cornell.edu>
Sat, 8 May 2021 22:28:50 +0000 (18:28 -0400)
committerKen Brown <kbrown@cornell.edu>
Fri, 4 Jun 2021 16:36:45 +0000 (12:36 -0400)
The socket info is sent as an administrative packet, for which we use
a higher priority "af_un_prio_admin" than for normal packets.

winsup/cygwin/fhandler_socket_unix.cc

index b1786b4f2b23d55dd7998cd0820a028cb675bd1d..19483b1681075f519aca1c6396b04b1e45799d91 100644 (file)
@@ -168,6 +168,14 @@ AF_UNIX_PKT_DATA_APPEND (af_unix_pkt_hdr_t *phdr, void *data, uint16_t dlen)
 /* Default timeout value of connect: 20 secs, as on Linux. */
 #define AF_UNIX_CONNECT_TIMEOUT (-20 * NS100PERSEC)
 
+/* Message queue priorities */
+enum
+{
+  af_un_prio_normal,
+  af_un_prio_admin,
+  af_un_prio_rewrite,          /* For rewritten packet after partial read. */
+};
+
 void
 sun_name_t::set (const struct sockaddr_un *name, socklen_t namelen)
 {
@@ -641,8 +649,7 @@ fhandler_socket_unix::send_sock_info (bool from_bind)
   size_t plen;
   size_t clen = 0;
   af_unix_pkt_hdr_t *packet;
-  NTSTATUS status;
-  IO_STATUS_BLOCK io;
+  int ret;
 
   if (!from_bind)
     {
@@ -677,17 +684,14 @@ fhandler_socket_unix::send_sock_info (bool from_bind)
 
   /* The theory: Fire and forget. */
   io_lock ();
-  set_pipe_non_blocking (true);
-  status = NtWriteFile (get_handle (), NULL, NULL, NULL, &io, packet,
-                       packet->pckt_len, NULL, NULL);
-  set_pipe_non_blocking (is_nonblocking ());
+  set_mqueue_non_blocking (get_mqd_out (), true);
+  ret = mq_send (get_mqd_out (), (const char *) packet, packet->pckt_len,
+                af_un_prio_admin);
+  set_mqueue_non_blocking (get_mqd_out (), is_nonblocking ());
   io_unlock ();
-  if (!NT_SUCCESS (status))
-    {
-      debug_printf ("Couldn't send my name: NtWriteFile: %y", status);
-      return -1;
-    }
-  return 0;
+  if (ret < 0)
+    debug_printf ("Couldn't send my name: mq_send, %E");
+  return ret;
 }
 
 /* Reads an administrative packet from the pipe and handles it.  If
This page took 0.032914 seconds and 5 git commands to generate.