Re: [PATCH] Cygwin: Conditionally build documentation
On 2022-01-14 13:18, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote: Add a configure option '--disable-doc' to disable building of the documentation by the 'all' target. Can you please also add --disable-doc to "configure --help"? It took me awhile to figure out which option I should use to skip the doc from building because it does no longer ignore doc build failure by default (unlike it used to do). Also this fact is not reflected in the FAQ here: https://cygwin.com/faq.html#faq.programming.building-cygwin which still mentions the doc build errors ignored: Normally, building ignores any errors in building the documentation Updated by Jon a month ago: https://cygwin.com/git/?p=newlib-cygwin.git;a=commitdiff;h=f4a26ececa180cec70c41b6dd2082ff730f92065 winsup/configure.ac: ... +AC_ARG_ENABLE(doc, + [AS_HELP_STRING([--enable-doc], [Build documentation])],, + enable_doc=yes) +AM_CONDITIONAL(BUILD_DOC, [test $enable_doc != "no"]) ... winsup/faq-programming.xml: ... +Building the documentation also requires the dblatex, +docbook2X, docbook-xml45, +docbook-xsl, and xmlto packages. Building +the documentation can be disabled with the --disable-doc +option to configure. ... probably won't appear on the web site until the next release. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in binary units and prefixes, physical quantities in SI.]
Re: [PATCH 2/7] Use matching format for NTSTATUS
See fprintf(3p) POSIX: # Specifies that the value is to be converted to an alternative form. ... For x or X conversion specifiers, a non-zero result shall have 0x (or 0X) prefixed to it. On 2022-01-14 15:10, Anton Lavrentiev via Cygwin-patches wrote: --- winsup/cygwin/libc/minires-os-if.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 666a008de..6e17de0b8 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -359,7 +359,7 @@ static void get_registry_dns(res_state statp) status = RtlCheckRegistryKey (RTL_REGISTRY_SERVICES, keyName); if (!NT_SUCCESS (status)) { - DPRINTF (statp->options & RES_DEBUG, "RtlCheckRegistryKey: status %p\n", + DPRINTF (statp->options & RES_DEBUG, "RtlCheckRegistryKey: status 0x%08X\n", DPRINTF (statp->options & RES_DEBUG, "RtlCheckRegistryKey: status %#08x\n", status); return; } @@ -381,7 +381,7 @@ static void get_registry_dns(res_state statp) if (!NT_SUCCESS (status)) { DPRINTF (statp->options & RES_DEBUG, - "RtlQueryRegistryValues: status %p\n", status); + "RtlQueryRegistryValues: status 0x%08x\n", status); "RtlQueryRegistryValues: status %#08x\n", status); return; } -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. [Data in binary units and prefixes, physical quantities in SI.]
[PATCH 6/7] Message consistency
--- winsup/cygwin/libc/minires-os-if.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index f71178b96..6b4c5e33e 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -165,7 +165,7 @@ static unsigned char * write_record(unsigned char * ptr, PDNS_RECORD rr, default: { unsigned int len = rr->wDataLength; -DPRINTF(debug, "No structure for wType %d\n", rr->wType); +DPRINTF(debug, "No structure for wType %u\n", rr->wType); if (ptr + len <= EndPtr) memcpy(ptr, (char *) >Data, len); ptr += len; @@ -210,7 +210,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty #define NO_DATA4 /* Valid name, no data record of requested type */ #endif - DPRINTF(debug, "DnsQuery: %u (Windows)\n", res); + DPRINTF(debug, "DnsQuery for \"%s\" %d: %u (Windows)\n", DomName, Type, res); if (res) { switch (res) { case ERROR_INVALID_NAME: @@ -236,7 +236,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty statp->res_h_errno = NO_DATA; break; default: - DPRINTF(debug, "Unknown code %u for %s %d\n", res, DomName, Type); + DPRINTF(debug, "Unknown code %u\n", res); statp->res_h_errno = NO_RECOVERY; break; } @@ -274,7 +274,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty /* Check the records are in correct section order */ if ((rr->Flags.DW & 0x3) < section) { - DPRINTF(debug, "Unexpected section order %s %d\n", DomName, Type); + DPRINTF(debug, "Unexpected section order for \"%s\" %d\n", DomName, Type); continue; } section = rr->Flags.DW & 0x3; @@ -324,7 +324,7 @@ static void get_registry_dns_items(PUNICODE_STRING in, res_state statp, srch++); *srch++ = 0; if (numAddresses < DIM(statp->nsaddr_list)) { - DPRINTF(debug, "server \"%s\"\n", ap); + DPRINTF(debug, "registry server \"%s\"\n", ap); statp->nsaddr_list[numAddresses].sin_addr.s_addr = cygwin_inet_addr((char *) ap); if ( statp->nsaddr_list[numAddresses].sin_addr.s_addr != 0 ) numAddresses++; @@ -355,7 +355,7 @@ static void get_registry_dns(res_state statp) NTSTATUS status; const PCWSTR keyName = L"Tcpip\\Parameters"; - DPRINTF(statp->options & RES_DEBUG, "key %ls\n", keyName); + DPRINTF(statp->options & RES_DEBUG, "key \"%ls\"\n", keyName); status = RtlCheckRegistryKey (RTL_REGISTRY_SERVICES, keyName); if (!NT_SUCCESS (status)) { @@ -460,7 +460,7 @@ void get_dns_info(res_state statp) pIPAddr; pIPAddr = pIPAddr->Next) { if (numAddresses < DIM(statp->nsaddr_list)) { - DPRINTF(debug, "server \"%s\"\n", pIPAddr->IpAddress.String); + DPRINTF(debug, "params server \"%s\"\n", pIPAddr->IpAddress.String); statp->nsaddr_list[numAddresses].sin_addr.s_addr = cygwin_inet_addr(pIPAddr->IpAddress.String); if (statp->nsaddr_list[numAddresses].sin_addr.s_addr != 0) { numAddresses++; -- 2.33.0
[PATCH 7/7] Added processing of AAAA records
--- winsup/cygwin/libc/minires-os-if.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 6b4c5e33e..fd2e37a31 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -69,15 +69,15 @@ static unsigned char * write_record(unsigned char * ptr, PDNS_RECORD rr, switch(rr->wType) { case DNS_TYPE_A: + case DNS_TYPE_: { u_int8_t * aptr = (u_int8_t *) & rr->Data.A.IpAddress; -if (ptr + 4 <= EndPtr) { - ptr[0] = aptr[0]; - ptr[1] = aptr[1]; - ptr[2] = aptr[2]; - ptr[3] = aptr[3]; +int i, sz = rr->wType == DNS_TYPE_A ? NS_INADDRSZ/*4*/ : NS_IN6ADDRSZ/*16*/; +if (ptr + sz <= EndPtr) { + for (i = 0; i < sz; ++i) +ptr[i] = aptr[i]; } -ptr += 4; +ptr += sz; break; } case DNS_TYPE_NS: -- 2.33.0
[PATCH 5/7] Format consitency for Windows errors
--- winsup/cygwin/libc/minires-os-if.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 6e17de0b8..f71178b96 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -210,7 +210,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty #define NO_DATA4 /* Valid name, no data record of requested type */ #endif - DPRINTF(debug, "DnsQuery: %lu (Windows)\n", res); + DPRINTF(debug, "DnsQuery: %u (Windows)\n", res); if (res) { switch (res) { case ERROR_INVALID_NAME: @@ -236,7 +236,7 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty statp->res_h_errno = NO_DATA; break; default: - DPRINTF(debug, "Unknown code %lu for %s %d\n", res, DomName, Type); + DPRINTF(debug, "Unknown code %u for %s %d\n", res, DomName, Type); statp->res_h_errno = NO_RECOVERY; break; } @@ -442,7 +442,7 @@ void get_dns_info(res_state statp) /* First call to get the buffer length we need */ dwRetVal = GetNetworkParams((FIXED_INFO *) 0, ); if (dwRetVal != ERROR_BUFFER_OVERFLOW) { -DPRINTF(debug, "GetNetworkParams: error %lu (Windows)\n", dwRetVal); +DPRINTF(debug, "GetNetworkParams: error %u (Windows)\n", dwRetVal); goto use_registry; } if ((pFixedInfo = (FIXED_INFO *) alloca(ulOutBufLen)) == 0) { @@ -450,7 +450,7 @@ void get_dns_info(res_state statp) goto use_registry; } if ((dwRetVal = GetNetworkParams(pFixedInfo, & ulOutBufLen))) { -DPRINTF(debug, "GetNetworkParams: error %lu (Windows)\n", dwRetVal); +DPRINTF(debug, "GetNetworkParams: error %u (Windows)\n", dwRetVal); goto use_registry; } -- 2.33.0
[PATCH 4/7] Process options forward (not backwards)
--- winsup/cygwin/libc/minires.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/libc/minires.c b/winsup/cygwin/libc/minires.c index 58c0438d3..2a77098b8 100644 --- a/winsup/cygwin/libc/minires.c +++ b/winsup/cygwin/libc/minires.c @@ -86,12 +86,12 @@ Read options ***/ -static void get_options(res_state statp, int i, char **words) +static void get_options(res_state statp, int n, char **words) { char *ptr; - int value; + int i, value; - while (i-- > 0) { + for (i = 0; i < n; ++i) { if (!strcasecmp("debug", words[i])) { statp->options |= RES_DEBUG; DPRINTF(statp->options & RES_DEBUG, "%s: 1\n", words[i]); @@ -208,8 +208,10 @@ static void get_resolv(res_state statp) } } /* Options line */ - else if (!strncasecmp("options", words[0], sizes[0])) + else if (!strncasecmp("options", words[0], sizes[0])) { get_options(statp, i - 1, [1]); + debug = statp->options & RES_DEBUG; + } } } fclose(fd); -- 2.33.0
[PATCH 3/7] Debug output to show both IP and port # in native b.o., a few little cosmetic improvements for consistency
--- winsup/cygwin/libc/minires.c | 28 ++-- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/libc/minires.c b/winsup/cygwin/libc/minires.c index 0979daae3..58c0438d3 100644 --- a/winsup/cygwin/libc/minires.c +++ b/winsup/cygwin/libc/minires.c @@ -73,7 +73,7 @@ void minires_get_search(char * string, res_state statp) statp->dnsrch[j] = strcpy(ptr, words[j]); statp->dnsrch[j+1] = NULL; ptr += sizes[j]; - DPRINTF(debug, "search \"%s\"\n", words[j]); + DPRINTF(debug, "registry search \"%s\"\n", words[j]); } else if (j < MAXDNSRCH + 1) DPRINTF(debug, "no space for \"%s\"\n", words[j]); @@ -170,7 +170,7 @@ static void get_resolv(res_state statp) have_address = (statp->nscount != 0); while ( fgets(line, sizeof(line), fd) != 0) { -DPRINTF(debug, "resolv.conf %s", line); +DPRINTF(debug, _PATH_RESCONF " line: %s", line); if ((i = scanline(line, words, sizes, DIM(words))) > 0) { if (!have_address && !strncasecmp("nameserver", words[0], sizes[0])) { @@ -186,7 +186,7 @@ static void get_resolv(res_state statp) else { statp->nsaddr_list[ns++].sin_addr.s_addr = address; statp->nscount++; - DPRINTF(debug, "server \"%s\"\n", words[j]); + DPRINTF(debug, "nameserver \"%s\"\n", words[j]); } } } @@ -254,6 +254,8 @@ static int open_sock(struct sockaddr_in *CliAddr, int debug) DPRINTF(debug, "bind: %s\n", strerror(errno)); return -1; } + + DPRINTF(debug, "UDP socket sockfd %d\n", fd); return fd; } @@ -503,8 +505,9 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr, rslt = cygwin_sendto(statp->sockfd, MsgPtr, MsgLength, 0, (struct sockaddr *) >nsaddr_list[wServ], sizeof(struct sockaddr_in)); -DPRINTF(debug, "sendto: server %08x sockfd %d %s\n", - statp->nsaddr_list[wServ].sin_addr.s_addr, +DPRINTF(debug, "sendto: server %08x:%hu sockfd %d %s\n", + ntohl(statp->nsaddr_list[wServ].sin_addr.s_addr), + ntohs(statp->nsaddr_list[wServ].sin_port), statp->sockfd, (rslt == MsgLength)?"OK":strerror(errno)); if (rslt != MsgLength) { statp->res_h_errno = NETDB_INTERNAL; @@ -519,12 +522,14 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr, timeOut.tv_usec = 0; rslt = cygwin_select(statp->sockfd + 1, _read, NULL, NULL, ); if ( rslt == 0 ) { /* Timeout */ - DPRINTF(statp->options & RES_DEBUG, "timeout for server %08x\n", - statp->nsaddr_list[wServ].sin_addr.s_addr); + DPRINTF(statp->options & RES_DEBUG, "timeout for server %08x:%hu sockfd %d\n", + ntohl(statp->nsaddr_list[wServ].sin_addr.s_addr), + ntohs(statp->nsaddr_list[wServ].sin_port), + statp->sockfd); continue; } else if ((rslt != 1) || (FD_ISSET(statp->sockfd, _read) == 0)) { - DPRINTF(debug, "select: %s\n", strerror(errno)); + DPRINTF(debug, "select sockfd %d: %s\n", statp->sockfd, strerror(errno)); statp->res_h_errno = NETDB_INTERNAL; return -1; } @@ -533,11 +538,14 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr, rslt = cygwin_recvfrom(statp->sockfd, AnsPtr, AnsLength, 0, (struct sockaddr *) & dnsSockAddr, & addrLen); if (rslt <= 0) { - DPRINTF(debug, "recvfrom: %s\n", strerror(errno)); + DPRINTF(debug, "recvfrom sockfd %d: %s\n", statp->sockfd, strerror(errno)); statp->res_h_errno = NETDB_INTERNAL; return -1; } -DPRINTF(debug, "recvfrom: %d bytes from %08x\n", rslt, dnsSockAddr.sin_addr.s_addr); +DPRINTF(debug, "recvfrom: %d bytes from %08x:%hu sockfd %d\n", rslt, +ntohl(dnsSockAddr.sin_addr.s_addr), +ntohs(dnsSockAddr.sin_port), +statp->sockfd); /* Prepare to retry with tcp */ -- 2.33.0
[PATCH 2/7] Use matching format for NTSTATUS
--- winsup/cygwin/libc/minires-os-if.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 666a008de..6e17de0b8 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -359,7 +359,7 @@ static void get_registry_dns(res_state statp) status = RtlCheckRegistryKey (RTL_REGISTRY_SERVICES, keyName); if (!NT_SUCCESS (status)) { - DPRINTF (statp->options & RES_DEBUG, "RtlCheckRegistryKey: status %p\n", + DPRINTF (statp->options & RES_DEBUG, "RtlCheckRegistryKey: status 0x%08X\n", status); return; } @@ -381,7 +381,7 @@ static void get_registry_dns(res_state statp) if (!NT_SUCCESS (status)) { DPRINTF (statp->options & RES_DEBUG, - "RtlQueryRegistryValues: status %p\n", status); + "RtlQueryRegistryValues: status 0x%08X\n", status); return; } -- 2.33.0
[PATCH 1/7] Fix format specifier for wide-char string
--- winsup/cygwin/libc/minires-os-if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 565158150..666a008de 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -355,7 +355,7 @@ static void get_registry_dns(res_state statp) NTSTATUS status; const PCWSTR keyName = L"Tcpip\\Parameters"; - DPRINTF(statp->options & RES_DEBUG, "key %s\n", keyName); + DPRINTF(statp->options & RES_DEBUG, "key %ls\n", keyName); status = RtlCheckRegistryKey (RTL_REGISTRY_SERVICES, keyName); if (!NT_SUCCESS (status)) { -- 2.33.0
Cygwin: A few fixes for local resolver
I am sending this patch that has fallen through the cracks almost a year ago, because I switched to a different project and it was forgotten. I just discovered it now, and I also added the record processing as discussed back on Feb 1, 2021. - Use %S (instead of %s) when a wide-character output is due; - Use native byte order for host and add port when doing I/O with DNS server; - Use forward way for resolv.conf's "options" processing, so listing "debug" as a first option, will show all following option(s) as they are read; - Re-evaluate debug output flag after each "options" processing as it may chance. - Added processing of records
RE: [PATCH] Cygwin: Conditionally build documentation
> > Add a configure option '--disable-doc' to disable building of the > documentation by the 'all' target. > Can you please also add --disable-doc to "configure --help"? It took me awhile to figure out which option I should use to skip the doc from building because it does no longer ignore doc build failure by default (unlike it used to do). Also this fact is not reflected in the FAQ here: https://cygwin.com/faq.html#faq.programming.building-cygwin which still mentions the doc build errors ignored: > Normally, building ignores any errors in building the documentation Thanks! Anton Lavrentiev Contractor NIH/NLM/NCBI
[PATCH] Cygwin: pty: Fix race issue between closing and opening master.
- If the from_master is closed before cleaning up other pipes, such as from_slave_nat, the same pty may be allocated and pty master may try to open the pipe which is not closed yet, and it will fail. This patch fixes the issue. --- winsup/cygwin/fhandler_tty.cc | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 1ae4edd63..7bef6958c 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -2146,8 +2146,6 @@ fhandler_pty_master::close () if (!ForceCloseHandle (from_master_nat)) termios_printf ("error closing from_master_nat %p, %E", from_master_nat); - if (!ForceCloseHandle (from_master)) -termios_printf ("error closing from_master %p, %E", from_master); if (!ForceCloseHandle (to_master_nat)) termios_printf ("error closing to_master_nat %p, %E", to_master_nat); from_master_nat = to_master_nat = NULL; @@ -2156,7 +2154,7 @@ fhandler_pty_master::close () from_slave_nat = NULL; if (!ForceCloseHandle (to_master)) termios_printf ("error closing to_master %p, %E", to_master); - to_master = from_master = NULL; + to_master = NULL; ForceCloseHandle (echo_r); ForceCloseHandle (echo_w); echo_r = echo_w = NULL; @@ -2171,6 +2169,12 @@ fhandler_pty_master::close () termios_printf ("CloseHandle (input_available_event<%p>), %E", input_available_event); + /* The from_master must be closed last so that the same pty is not + allocated before cleaning up the other corresponding instances. */ + if (!ForceCloseHandle (from_master)) +termios_printf ("error closing from_master %p, %E", from_master); + from_master = NULL; + return 0; } @@ -3069,12 +3073,14 @@ err: close_maybe (output_mutex); close_maybe (input_mutex); close_maybe (from_master_nat); - close_maybe (from_master); close_maybe (to_master_nat); close_maybe (to_master); close_maybe (echo_r); close_maybe (echo_w); close_maybe (master_ctl); + /* The from_master must be closed last so that the same pty is not + allocated before cleaning up the other corresponding instances. */ + close_maybe (from_master); termios_printf ("pty%d open failed - failed to create %s", unit, errstr); return false; } -- 2.34.1
Re: [PATCH 0/4] Some fixes for console and pty.
Hi Takashi, On Jan 13 21:28, Takashi Yano wrote: > Takashi Yano (4): > Cygwin: pty, console: Fix deadlock in GDB regarding mutex. > Cygwin: pty: Fix memory leak in master_fwd_thread. > Cygwin: pty: Stop closing and recreating attach_mutex. > Cygwin: console: Fix potential deadlock regarding acuqiring mutex. LGTM, but you know, it's your code anyway ;) Corinna