1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
From: Tim Waugh <twaugh@fedoraproject.org>
Date: Fri, 31 Jan 2020 12:35:31 +0100
Subject: Avoid busy loop in hpcups when backend has exited
Origin: https://src.fedoraproject.org/rpms/hplip/blob/master/f/hplip-hpcups-sigpipe.patch
---
prnt/hpijs/services.cpp | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/prnt/hpijs/services.cpp b/prnt/hpijs/services.cpp
index 026ef1a..2938c8d 100644
--- a/prnt/hpijs/services.cpp
+++ b/prnt/hpijs/services.cpp
@@ -29,6 +29,7 @@
POSSIBILITY OF SUCH DAMAGE.
\*****************************************************************************/
+#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
@@ -385,8 +386,16 @@ DRIVER_ERROR UXServices::ToDevice(const BYTE * pBuffer, DWORD * Count)
if (write(OutputPath, pBuffer, *Count) != (ssize_t)*Count)
{
static int cnt=0;
- if (cnt++ < 5)
+ if (cnt < 5)
+ {
+ cnt++;
BUG("unable to write to output, fd=%d, count=%d: %m\n", OutputPath, *Count);
+ }
+
+ if (errno == EPIPE)
+ /* The backend has exited. There's no recovering from that. */
+ exit (1);
+
return IO_ERROR;
}
|