[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-4159-g263cacf

Karolin Seeger kseeger at samba.org
Wed Sep 24 01:42:59 GMT 2008


The branch, v3-3-test has been updated
       via  263cacf1f2dd4003862184ea3a2716ace0dbb086 (commit)
      from  d5c490d79024ee41544512f7968999a6b3a313dc (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit 263cacf1f2dd4003862184ea3a2716ace0dbb086
Author: Karolin Seeger <kseeger at samba.org>
Date:   Tue Sep 23 16:54:05 2008 -0700

    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

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/smbdotconf/printing/cupstimeout.xml |   17 +++++++++++++
 source/include/printing.h                    |    1 +
 source/include/proto.h                       |    1 +
 source/param/loadparm.c                      |   13 ++++++++++
 source/printing/print_cups.c                 |   34 +++++++++++++++++++++----
 5 files changed, 60 insertions(+), 6 deletions(-)
 create mode 100644 docs-xml/smbdotconf/printing/cupstimeout.xml


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/printing/cupstimeout.xml b/docs-xml/smbdotconf/printing/cupstimeout.xml
new file mode 100644
index 0000000..727ccce
--- /dev/null
+++ b/docs-xml/smbdotconf/printing/cupstimeout.xml
@@ -0,0 +1,17 @@
+<samba:parameter name="cups timeout"
+                 context="G"
+		 type="integer"
+		 print="1"
+		 advanced="1"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+
+<description>
+    <para>
+    This parameter determines the timeout for connections to a CUPS server
+    in seconds.
+    </para>
+</description>
+
+<value type="default">30</value>
+<value type="example">cups timeout = 10</value>
+</samba:parameter>
diff --git a/source/include/printing.h b/source/include/printing.h
index 2788143..04e30a0 100644
--- a/source/include/printing.h
+++ b/source/include/printing.h
@@ -77,6 +77,7 @@ extern struct printif	iprint_printif;
 #define NEXT_JOBID(j) ((j+1) % PRINT_MAX_JOBID > 0 ? (j+1) % PRINT_MAX_JOBID : 1)
 
 #define MAX_CACHE_VALID_TIME 3600
+#define CUPS_DEFAULT_TIMEOUT 30
 
 #ifndef PRINT_SPOOL_PREFIX
 #define PRINT_SPOOL_PREFIX "smbprn."
diff --git a/source/include/proto.h b/source/include/proto.h
index eeb62e1..3576d0b 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -5933,6 +5933,7 @@ const char **lp_svcctl_list(void);
 char *lp_cups_options(int );
 char *lp_cups_server(void);
 char *lp_iprint_server(void);
+int lp_cups_timeout(void);
 const char *lp_ctdbd_socket(void);
 const char **lp_cluster_addresses(void);
 bool lp_clustering(void);
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 60a1fa4..db9e990 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -52,6 +52,7 @@
  */
 
 #include "includes.h"
+#include "printing.h"
 
 bool bLoaded = False;
 
@@ -340,6 +341,7 @@ struct global {
 	int iKeepalive;
 	int iminreceivefile;
 	struct param_opt_struct *param_opt;
+	int cups_timeout;
 };
 
 static struct global Globals;
@@ -2595,6 +2597,15 @@ static struct parm_struct parm_table[] = {
 		.flags		= FLAG_ADVANCED | FLAG_PRINT | FLAG_GLOBAL,
 	},
 	{
+		.label		= "cups timeout",
+		.type		= P_INTEGER,
+		.p_class	= P_GLOBAL,
+		.ptr		= &Globals.cups_timeout,
+		.special	= NULL,
+		.enum_list	= NULL,
+		.flags		= FLAG_ADVANCED,
+	},
+	{
 		.label		= "iprint server",
 		.type		= P_STRING,
 		.p_class	= P_GLOBAL,
@@ -4794,6 +4805,7 @@ static void init_globals(bool first_time_only)
 	 * to never expire, though, when this runs out the afs client will 
 	 * forget the token. Set to 0 to get NEVERDATE.*/
 	Globals.iAfsTokenLifetime = 604800;
+	Globals.cups_timeout = CUPS_DEFAULT_TIMEOUT;
 
 /* these parameters are set to defaults that are more appropriate
    for the increasing samba install base:
@@ -5235,6 +5247,7 @@ FN_GLOBAL_LIST(lp_svcctl_list, &Globals.szServicesList)
 FN_LOCAL_STRING(lp_cups_options, szCupsOptions)
 FN_GLOBAL_STRING(lp_cups_server, &Globals.szCupsServer)
 FN_GLOBAL_STRING(lp_iprint_server, &Globals.szIPrintServer)
+FN_GLOBAL_INTEGER(lp_cups_timeout, &Globals.cups_timeout)
 FN_GLOBAL_CONST_STRING(lp_ctdbd_socket, &Globals.ctdbdSocket)
 FN_GLOBAL_LIST(lp_cluster_addresses, &Globals.szClusterAddresses)
 FN_GLOBAL_BOOL(lp_clustering, &Globals.clustering)
diff --git a/source/printing/print_cups.c b/source/printing/print_cups.c
index 593c5c7..2b2cf15 100644
--- a/source/printing/print_cups.c
+++ b/source/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);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list