summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorKarolin Seeger <kseeger@samba.org>2008-09-23 16:54:05 -0700
committerKarolin Seeger <kseeger@samba.org>2008-09-23 16:57:58 -0700
commit765e5d2282959770ea9648e0f2b72e51e5b4cdd8 (patch)
treebf59bcd16948792db4fad6e8fad5be03f13fd286 /source3/printing
parent61a45c85dec8e65ba9782c3ec4af0e9a42895eb3 (diff)
downloadsamba-765e5d2282959770ea9648e0f2b72e51e5b4cdd8.tar.gz
samba-765e5d2282959770ea9648e0f2b72e51e5b4cdd8.tar.bz2
samba-765e5d2282959770ea9648e0f2b72e51e5b4cdd8.zip
printing: Add new parameter "cups timeout".
The default timeout for connections to CUPS servers is set to 5 minutes in the CUPS libraries. The smbd hangs on startup until the timeout is reached if the CUPS server is unreachable. This parameter makes the timeout configurable. The default value is set to 30 seconds. Karolin
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/print_cups.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 593c5c7a1f..2b2cf159fb 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -24,6 +24,17 @@
#include <cups/cups.h>
#include <cups/language.h>
+static SIG_ATOMIC_T gotalarm;
+
+/***************************************************************
+ Signal function to tell us we timed out.
+****************************************************************/
+
+static void gotalarm_sig(void)
+{
+ gotalarm = 1;
+}
+
extern userdom_struct current_user_info;
/*
@@ -45,7 +56,15 @@ static http_t *cups_connect(void)
http_t *http;
char *server, *p;
int port;
-
+ int timeout = lp_cups_timeout();
+
+ gotalarm = 0;
+
+ if (timeout) {
+ CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
+ alarm(timeout);
+ }
+
if (lp_cups_server() != NULL && strlen(lp_cups_server()) > 0) {
server = smb_xstrdup(lp_cups_server());
} else {
@@ -59,15 +78,18 @@ static http_t *cups_connect(void)
} else {
port = ippPort();
}
-
+
DEBUG(10, ("connecting to cups server %s:%d\n",
server, port));
- if ((http = httpConnect(server, port)) == NULL) {
- DEBUG(0,("Unable to connect to CUPS server %s:%d - %s\n",
+ http = httpConnect(server, port);
+
+ CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
+ alarm(0);
+
+ if (http == NULL) {
+ DEBUG(0,("Unable to connect to CUPS server %s:%d - %s\n",
server, port, strerror(errno)));
- SAFE_FREE(server);
- return NULL;
}
SAFE_FREE(server);