Source-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/print/cups-base Fix bugs in the non-blocking connect h...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/3ba8a5197d90
branches:  trunk
changeset: 431607:3ba8a5197d90
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Thu May 14 19:45:50 2020 +0000

description:
Fix bugs in the non-blocking connect handling so that the print dialog
in GTK can work even if the CUPS daemon is not running. Bump revision.

diffstat:

 print/cups-base/Makefile                           |   3 +-
 print/cups-base/distinfo                           |   3 +-
 print/cups-base/patches/patch-cups_http-addrlist.c |  90 ++++++++++++++++++++++
 3 files changed, 94 insertions(+), 2 deletions(-)

diffs (126 lines):

diff -r 906e431179f3 -r 3ba8a5197d90 print/cups-base/Makefile
--- a/print/cups-base/Makefile  Thu May 14 19:39:03 2020 +0000
+++ b/print/cups-base/Makefile  Thu May 14 19:45:50 2020 +0000
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile,v 1.32 2020/05/09 12:15:58 maya Exp $
+# $NetBSD: Makefile,v 1.33 2020/05/14 19:45:50 joerg Exp $
 
 .include "../../print/cups/Makefile.common"
 
 DISTNAME=      cups-${CUPS_VERS}-source
 PKGNAME=       cups-base-${CUPS_VERS}
+PKGREVISION=   1
 CATEGORIES=    print
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=apple/}
 
diff -r 906e431179f3 -r 3ba8a5197d90 print/cups-base/distinfo
--- a/print/cups-base/distinfo  Thu May 14 19:39:03 2020 +0000
+++ b/print/cups-base/distinfo  Thu May 14 19:45:50 2020 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.19 2020/05/02 11:47:16 leot Exp $
+$NetBSD: distinfo,v 1.20 2020/05/14 19:45:50 joerg Exp $
 
 SHA1 (cups-2.3.3-source.tar.gz) = 7a01c9fba5d784eb61eda03fd40e513fd2a1b5b8
 RMD160 (cups-2.3.3-source.tar.gz) = e08afd09666e79d0416f46e14fb8c6b0a6beebd7
@@ -19,6 +19,7 @@
 SHA1 (patch-config-scripts_cups-gssapi.m4) = ac2df3e82bc844630af8462a461c7efe1da4b354
 SHA1 (patch-config-scripts_cups-libtool.m4) = a6139fbbbee7038d11654c0a2387af21f48b7412
 SHA1 (patch-cups-tls.c) = f89c25f8089d9e11a983a270adbb2cbde3c22511
+SHA1 (patch-cups_http-addrlist.c) = aa2524ee1c11450cfa3a46b1aa34c12417322241
 SHA1 (patch-cups_thread.c) = e625a2b81f3d831d2a0c02bc0fa9a9d31c1097a7
 SHA1 (patch-doc-help-man-cups-files.conf.html) = c26754104788eb619e69e49d6d51bf84ab047876
 SHA1 (patch-man-cups-files.conf.man.in) = 08c0322fd233c724b7df238df01988500130d1c6
diff -r 906e431179f3 -r 3ba8a5197d90 print/cups-base/patches/patch-cups_http-addrlist.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/print/cups-base/patches/patch-cups_http-addrlist.c        Thu May 14 19:45:50 2020 +0000
@@ -0,0 +1,90 @@
+$NetBSD: patch-cups_http-addrlist.c,v 1.1 2020/05/14 19:45:50 joerg Exp $
+
+Checkout for non-blocking connect is difficult as systems can't agree on
+whether it is a write condition or an error. Check for both with
+poll/select and if either flag is set, use getpeername to determine if
+the socket was really connected. If it wasn't, drop it correctly from the
+poll event list as well as to not check stale event masks.
+
+--- cups/http-addrlist.c.orig  2020-05-09 14:07:20.638266583 +0000
++++ cups/http-addrlist.c
+@@ -73,8 +73,7 @@ httpAddrConnect2(
+ #  ifdef HAVE_POLL
+   struct pollfd               pfds[100];      /* Polled file descriptors */
+ #  else
+-  fd_set              input_set,      /* select() input set */
+-                      output_set,     /* select() output set */
++  fd_set              output_set,     /* select() output set */
+                       error_set;      /* select() error set */
+   struct timeval      timeout;        /* Timeout */
+ #  endif /* HAVE_POLL */
+@@ -280,16 +279,15 @@ httpAddrConnect2(
+       DEBUG_printf(("1httpAddrConnect2: poll() returned %d (%d)", result, errno));
+ 
+ #  else
+-      FD_ZERO(&input_set);
++      FD_ZERO(&output_set);
+       for (i = 0; i < nfds; i ++)
+-      FD_SET(fds[i], &input_set);
+-      output_set = input_set;
+-      error_set  = input_set;
++      FD_SET(fds[i], &output_set);
++      error_set  = output_set;
+ 
+       timeout.tv_sec  = 0;
+       timeout.tv_usec = (addrlist ? 100 : remaining > 250 ? 250 : remaining) * 1000;
+ 
+-      result = select(max_fd + 1, &input_set, &output_set, &error_set, &timeout);
++      result = select(max_fd + 1, NULL, &output_set, &error_set, &timeout);
+ 
+       DEBUG_printf(("1httpAddrConnect2: select() returned %d (%d)", result, errno));
+ #  endif /* HAVE_POLL */
+@@ -308,38 +306,25 @@ httpAddrConnect2(
+       {
+ #  ifdef HAVE_POLL
+       DEBUG_printf(("pfds[%d].revents=%x\n", i, pfds[i].revents));
+-      if (pfds[i].revents && !(pfds[i].revents & (POLLERR | POLLHUP)))
++      if (pfds[i].revents)
+ #  else
+-      if (FD_ISSET(fds[i], &input_set) && !FD_ISSET(fds[i], &error_set))
++      if (FD_ISSET(fds[i], &output_set) || FD_ISSET(fds[i], &error_set))
+ #  endif /* HAVE_POLL */
+       {
+-        *sock    = fds[i];
+-        connaddr = addrs[i];
+-
+-#  ifdef DEBUG
+-        len   = sizeof(peer);
+-        if (!getpeername(fds[i], (struct sockaddr *)&peer, &len))
+-          DEBUG_printf(("1httpAddrConnect2: Connected to %s:%d...", httpAddrString(&peer, temp, sizeof(temp)), httpAddrPort(&peer)));
+-#  endif /* DEBUG */
+-
+-          break;
+-      }
+-#  ifdef HAVE_POLL
+-      else if (pfds[i].revents & (POLLERR | POLLHUP))
+-#  else
+-      else if (FD_ISSET(fds[i], &error_set))
+-#  endif /* HAVE_POLL */
+-        {
+-         /*
+-          * Error on socket, remove from the "pool"...
+-          */
+-
++        if (getpeername(fds[i], NULL, 0) == 0) {
++          *sock    = fds[i];
++          connaddr = addrs[i];
++          break;
++        }
+         httpAddrClose(NULL, fds[i]);
+           nfds --;
+           if (i < nfds)
+           {
+             memmove(fds + i, fds + i + 1, (size_t)(nfds - i) * (sizeof(fds[0])));
+             memmove(addrs + i, addrs + i + 1, (size_t)(nfds - i) * (sizeof(addrs[0])));
++#  ifdef HAVE_POLL
++            memmove(pfds + i, pfds + i + 1, (size_t)(nfds - i) * (sizeof(pfds[0])));
++#  endif /* HAVE_POLL */
+           }
+           i --;
+         }



Home | Main Index | Thread Index | Old Index