diff options
author | Ken Brown <kbrown@cornell.edu> | 2021-05-09 01:28:50 +0300 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2021-06-04 19:36:45 +0300 |
commit | 8ce83c452b153434e2bb86846293f7d55d09ca91 (patch) | |
tree | 1e9463925b5f8b572c8047e326a70b74f055a178 | |
parent | f1f66706a3b205ad6c30add24956d51092226d4f (diff) |
Cygwin: AF_UNIX: adapt send_sock_info to mqueues
The socket info is sent as an administrative packet, for which we use
a higher priority "af_un_prio_admin" than for normal packets.
-rw-r--r-- | winsup/cygwin/fhandler_socket_unix.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc index b1786b4f2..19483b168 100644 --- a/winsup/cygwin/fhandler_socket_unix.cc +++ b/winsup/cygwin/fhandler_socket_unix.cc @@ -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 |