components/cups/patches/7187280.patch
branchs11-update
changeset 2403 a4a5919f480b
equal deleted inserted replaced
2402:21ebf6c9a4fa 2403:a4a5919f480b
       
     1 --- cups/util.c	Mon Jan 19 23:26:36 1970
       
     2 +++ cups/util.c	Mon Jan 19 23:26:36 1970
       
     3 @@ -70,6 +70,9 @@
       
     4  #  include <unistd.h>
       
     5  #endif /* WIN32 || __EMX__ */
       
     6  
       
     7 +#if defined(__sun)
       
     8 +#include <inet/tcp.h>		/* need this for TCPS_ESTABLISHED ... */
       
     9 +#endif
       
    10  
       
    11  /*
       
    12   * Local functions...
       
    13 @@ -1659,6 +1662,38 @@
       
    14        cg->http = NULL;
       
    15      }
       
    16    }
       
    17 +
       
    18 +#if defined(__sun)
       
    19 + /*
       
    20 +  * Check the connection state.
       
    21 +  * If the connection wasn't used for some time, the server could close it.
       
    22 +  * The socket state would change to CLOSE_WAIT in such case.
       
    23 +  */
       
    24 +  if (cg->http)
       
    25 +  {
       
    26 +    struct tcp_info tcpi;
       
    27 +    socklen_t len = sizeof(tcpi);
       
    28 +    memset(&tcpi, 0, sizeof(tcpi));
       
    29 +
       
    30 +   /*
       
    31 +    * Get TCP connection info.
       
    32 +    */
       
    33 +    if (getsockopt(cg->http->fd, IPPROTO_TCP, TCP_INFO, &tcpi, &len) == 0)
       
    34 +    {
       
    35 +     /*
       
    36 +      * Successfully got TCP connection state. Check it.
       
    37 +      */
       
    38 +      if (tcpi.tcpi_state != TCPS_ESTABLISHED)
       
    39 +      {
       
    40 +       /*
       
    41 +        * Need to close the current connection.
       
    42 +        */
       
    43 +        httpClose(cg->http);
       
    44 +        cg->http = NULL;
       
    45 +      }
       
    46 +    }
       
    47 +  }
       
    48 +#endif
       
    49  
       
    50   /*
       
    51    * (Re)connect as needed...