After reading comment #41 and compare the precise version of cups with upstream HEAD, I was able to (re-) build the prceise package with the following patch:
Index: cups-1.5.3/cups/request.c =================================================================== --- cups-1.5.3.orig/cups/request.c 2011-09-22 00:09:29.000000000 +0200 +++ cups-1.5.3/cups/request.c 2013-08-27 18:23:35.000000000 +0200 @@ -643,11 +643,13 @@ } else if (http->state != HTTP_WAITING) { - DEBUG_printf(("1cupsSendRequest: Unknown HTTP state (%d), bailing.", - http->state)); - _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0); - - return (HTTP_ERROR); + DEBUG_printf(("1cupsSendRequest: Unknown HTTP state (%d), " + "reconnecting.", http->state)); + if (httpReconnect(http)) + { + _cupsSetError(IPP_INTERNAL_ERROR, strerror(EINVAL), 0); + return (HTTP_ERROR); + } }
#ifdef HAVE_SSL @@ -1004,6 +1006,26 @@ httpClose(cg->http); cg->http = NULL; } + else + { + /* + * Same server, see if the connection is still established... + */ + + char ch; /* Connection check byte */ + int n; + + if ( (n = recv(cg->http->fd, &ch, 1, MSG_PEEK | MSG_DONTWAIT) == 0) || + ( n < 0 && errno != EWOULDBLOCK ) ) + { + /* + * Nope, close the connection... + */ + + httpClose(cg->http); + cg->http = NULL; + } + } }
/*
This solved the reconnect issue for us.
After reading comment #41 and compare the precise version of cups with upstream HEAD, I was able to (re-) build the prceise package with the following patch:
Index: cups-1. 5.3/cups/ request. c ======= ======= ======= ======= ======= ======= ======= ======= ==== 5.3.orig/ cups/request. c 2011-09-22 00:09:29.000000000 +0200 5.3/cups/ request. c 2013-08-27 18:23:35.000000000 +0200 ("1cupsSendRequ est: Unknown HTTP state (%d), bailing.", IPP_INTERNAL_ ERROR, strerror(EINVAL), 0); ("1cupsSendRequ est: Unknown HTTP state (%d), " http)) IPP_INTERNAL_ ERROR, strerror(EINVAL), 0);
=======
--- cups-1.
+++ cups-1.
@@ -643,11 +643,13 @@
}
else if (http->state != HTTP_WAITING)
{
- DEBUG_printf(
- http->state));
- _cupsSetError(
-
- return (HTTP_ERROR);
+ DEBUG_printf(
+ "reconnecting.", http->state));
+ if (httpReconnect(
+ {
+ _cupsSetError(
+ return (HTTP_ERROR);
+ }
}
#ifdef HAVE_SSL
httpClose( cg->http) ; cg->http) ;
@@ -1004,6 +1006,26 @@
cg->http = NULL;
}
+ else
+ {
+ /*
+ * Same server, see if the connection is still established...
+ */
+
+ char ch; /* Connection check byte */
+ int n;
+
+ if ( (n = recv(cg->http->fd, &ch, 1, MSG_PEEK | MSG_DONTWAIT) == 0) ||
+ ( n < 0 && errno != EWOULDBLOCK ) )
+ {
+ /*
+ * Nope, close the connection...
+ */
+
+ httpClose(
+ cg->http = NULL;
+ }
+ }
}
/*
This solved the reconnect issue for us.