From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 7001638518B5; Sun, 4 Dec 2022 13:27:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7001638518B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670160457; bh=R0bVLq020IliIBzjzfwg1YLC5KBJFhW9IZw+3oXfKys=; h=From:To:Subject:Date:From; b=EyViwSyy+1y8SdXjhnrvE7zD9cV+p5Qy/Pa1GWzMV2q/kgNL272JZhnHg7CqCCv62 ZPcbGTcLi+gJXyaYt3nZI0tCkpfReL7CeH4HzoKEjN6RPRVyEfXlLfpfjDjARqBOmR BoFPU9eqOH/+hNUyOI67oileOvNik0ltZK9LJvMo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: drop wincap::has_query_process_handle_info X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: c3c71e39f901e8b8bb6a8fb0e41eefed1fae1aac X-Git-Newrev: 4e40b214649139623c96923f678f1ee85c90286d Message-Id: <20221204132737.7001638518B5@sourceware.org> Date: Sun, 4 Dec 2022 13:27:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D4e40b214649= 139623c96923f678f1ee85c90286d commit 4e40b214649139623c96923f678f1ee85c90286d Author: Corinna Vinschen AuthorDate: Tue Nov 15 17:22:43 2022 +0100 Commit: Corinna Vinschen CommitDate: Sun Dec 4 14:01:41 2022 +0100 Cygwin: drop wincap::has_query_process_handle_info =20 Only required for Windows 7. =20 This allows to remove fhandler_pipe::get_query_hdl_per_system(), too. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler/pipe.cc | 76 +----------------------------= ---- winsup/cygwin/local_includes/fhandler.h | 1 - winsup/cygwin/local_includes/wincap.h | 2 - winsup/cygwin/wincap.cc | 12 ------ 4 files changed, 1 insertion(+), 90 deletions(-) diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc index 720e4efd39c2..608a78490879 100644 --- a/winsup/cygwin/fhandler/pipe.cc +++ b/winsup/cygwin/fhandler/pipe.cc @@ -1176,10 +1176,7 @@ cache_err: &pipename_key, &pipename_pid, &pipename_id) !=3D 3) return NULL; /* Non cygwin pipe? */ =20 - if (wincap.has_query_process_handle_info ()) - return get_query_hdl_per_process (name, ntfn); /* Since Win8 */ - else - return get_query_hdl_per_system (name, ntfn); /* Win7 */ + return get_query_hdl_per_process (name, ntfn); /* Since Win8 */ } =20 /* This function is faster than get_query_hdl_per_system(), however, @@ -1312,74 +1309,3 @@ close_proc: HeapFree (GetProcessHeap (), 0, proc_pids); return NULL; } - -/* This function is slower than get_query_hdl_per_process(), however, - works even before Windows 8. */ -HANDLE -fhandler_pipe::get_query_hdl_per_system (WCHAR *name, - OBJECT_NAME_INFORMATION *ntfn) -{ - NTSTATUS status; - SIZE_T n_handle =3D 65536; - PSYSTEM_HANDLE_INFORMATION shi; - do - { /* Enumerate handles */ - SIZE_T nbytes =3D - sizeof (ULONG) + n_handle * sizeof (SYSTEM_HANDLE_TABLE_ENTRY_INFO); - shi =3D (PSYSTEM_HANDLE_INFORMATION) HeapAlloc (GetProcessHeap (), - 0, nbytes); - if (!shi) - return NULL; - status =3D NtQuerySystemInformation (SystemHandleInformation, - shi, nbytes, NULL); - if (NT_SUCCESS (status)) - break; - HeapFree (GetProcessHeap (), 0, shi); - n_handle *=3D 2; - } - while (n_handle < (1L<<23) && status =3D=3D STATUS_INFO_LENGTH_MISMATCH); - if (!NT_SUCCESS (status)) - return NULL; - - for (LONG i =3D (LONG) shi->NumberOfHandles - 1; i >=3D 0; i--) - { - /* Check for the peculiarity of cygwin read pipe */ - const ULONG access =3D FILE_READ_DATA | FILE_READ_EA - | FILE_WRITE_EA /* marker */ - | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES - | READ_CONTROL | SYNCHRONIZE; - if (shi->Handles[i].GrantedAccess !=3D access) - continue; - - /* Retrieve handle */ - HANDLE proc =3D OpenProcess (PROCESS_DUP_HANDLE, 0, - shi->Handles[i].UniqueProcessId); - if (!proc) - continue; - HANDLE h =3D (HANDLE)(intptr_t) shi->Handles[i].HandleValue; - BOOL res =3D DuplicateHandle (proc, h, GetCurrentProcess (), &h, - FILE_READ_DATA, 0, 0); - if (!res) - goto close_proc; - - /* Check object name */ - ULONG len; - status =3D NtQueryObject (h, ObjectNameInformation, ntfn, 65536, &le= n); - if (!NT_SUCCESS (status) || !ntfn->Name.Buffer) - goto close_handle; - ntfn->Name.Buffer[ntfn->Name.Length / sizeof (WCHAR)] =3D L'\0'; - if (wcscmp (name, ntfn->Name.Buffer) =3D=3D 0) - { - query_hdl_proc =3D proc; - query_hdl_value =3D (HANDLE)(intptr_t) shi->Handles[i].HandleValue; - HeapFree (GetProcessHeap (), 0, shi); - return h; - } -close_handle: - CloseHandle (h); -close_proc: - CloseHandle (proc); - } - HeapFree (GetProcessHeap (), 0, shi); - return NULL; -} diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_= includes/fhandler.h index bc02eae66d7f..6671d8a05c60 100644 --- a/winsup/cygwin/local_includes/fhandler.h +++ b/winsup/cygwin/local_includes/fhandler.h @@ -1195,7 +1195,6 @@ private: LONG pipename_id; void release_select_sem (const char *); HANDLE get_query_hdl_per_process (WCHAR *, OBJECT_NAME_INFORMATION *); - HANDLE get_query_hdl_per_system (WCHAR *, OBJECT_NAME_INFORMATION *); public: fhandler_pipe (); =20 diff --git a/winsup/cygwin/local_includes/wincap.h b/winsup/cygwin/local_in= cludes/wincap.h index e123b4bd1845..17d2d74293d1 100644 --- a/winsup/cygwin/local_includes/wincap.h +++ b/winsup/cygwin/local_includes/wincap.h @@ -32,7 +32,6 @@ struct wincaps unsigned has_tcp_fastopen : 1; unsigned has_linux_tcp_keepalive_sockopts : 1; unsigned has_tcp_maxrtms : 1; - unsigned has_query_process_handle_info : 1; unsigned has_con_broken_tabs : 1; unsigned has_broken_attach_console : 1; unsigned cons_need_small_input_record_buf : 1; @@ -87,7 +86,6 @@ public: bool IMPLEMENT (has_tcp_fastopen) bool IMPLEMENT (has_linux_tcp_keepalive_sockopts) bool IMPLEMENT (has_tcp_maxrtms) - bool IMPLEMENT (has_query_process_handle_info) bool IMPLEMENT (has_con_broken_tabs) bool IMPLEMENT (has_broken_attach_console) bool IMPLEMENT (cons_need_small_input_record_buf) diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index 52bdda48d876..c52d4154010c 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -39,7 +39,6 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_com= mon"), shared)) =3D { has_tcp_fastopen:false, has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, - has_query_process_handle_info:false, has_con_broken_tabs:false, has_broken_attach_console:true, cons_need_small_input_record_buf:true, @@ -66,7 +65,6 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_com= mon"), shared)) =3D { has_tcp_fastopen:false, has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, - has_query_process_handle_info:true, has_con_broken_tabs:false, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -93,7 +91,6 @@ wincaps wincap_8_1 __attribute__((section (".cygwin_dll_c= ommon"), shared)) =3D { has_tcp_fastopen:false, has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, - has_query_process_handle_info:true, has_con_broken_tabs:false, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -120,7 +117,6 @@ wincaps wincap_10_1507 __attribute__((section (".cygwi= n_dll_common"), shared)) has_tcp_fastopen:false, has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:false, - has_query_process_handle_info:true, has_con_broken_tabs:false, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -147,7 +143,6 @@ wincaps wincap_10_1607 __attribute__((section (".cygwi= n_dll_common"), shared)) has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:false, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -174,7 +169,6 @@ wincaps wincap_10_1703 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:false, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:true, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -201,7 +195,6 @@ wincaps wincap_10_1709 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:true, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -228,7 +221,6 @@ wincaps wincap_10_1803 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:true, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -255,7 +247,6 @@ wincaps wincap_10_1809 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:true, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -282,7 +273,6 @@ wincaps wincap_10_1903 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:true, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -309,7 +299,6 @@ wincaps wincap_10_2004 __attribute__((section (".cygwin= _dll_common"), shared)) =3D has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:true, has_broken_attach_console:false, cons_need_small_input_record_buf:false, @@ -336,7 +325,6 @@ wincaps wincap_11 __attribute__((section (".cygwin_dll_= common"), shared)) =3D { has_tcp_fastopen:true, has_linux_tcp_keepalive_sockopts:true, has_tcp_maxrtms:true, - has_query_process_handle_info:true, has_con_broken_tabs:false, has_broken_attach_console:false, cons_need_small_input_record_buf:false,