summaryrefslogtreecommitdiff
path: root/source3/printing/printing.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-10-26 00:29:21 +0000
committerJeremy Allison <jra@samba.org>2002-10-26 00:29:21 +0000
commit3103303d2a78ef2d530083502280c1bba551c4bb (patch)
tree77e85a036cb356de580178fadd9be8c98ebc2bbc /source3/printing/printing.c
parent71f34ddabd80f3d65d6332e734ce6e20fef31de5 (diff)
downloadsamba-3103303d2a78ef2d530083502280c1bba551c4bb.tar.gz
samba-3103303d2a78ef2d530083502280c1bba551c4bb.tar.bz2
samba-3103303d2a78ef2d530083502280c1bba551c4bb.zip
Fix problem where an fd would be left open for every printer queue.
Jeremy. (This used to be commit 997c234e15a5f8d742320359a53e15a27661d456)
Diffstat (limited to 'source3/printing/printing.c')
-rw-r--r--source3/printing/printing.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index afcf0ee720..2d75699ac5 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -225,12 +225,35 @@ static struct tdb_print_db *get_print_db_byname(const char *printername)
return p;
}
+/***************************************************************************
+ Remove a reference count.
+****************************************************************************/
+
static void release_print_db( struct tdb_print_db *pdb)
{
pdb->ref_count--;
SMB_ASSERT(pdb->ref_count >= 0);
}
+/***************************************************************************
+ Close all open print db entries.
+****************************************************************************/
+
+static void close_all_print_db(void)
+{
+ struct tdb_print_db *p = NULL, *next_p = NULL;
+
+ for (p = print_db_head; p; p = next_p) {
+ next_p = p->next;
+
+ if (p->tdb)
+ tdb_close(p->tdb);
+ DLIST_REMOVE(print_db_head, p);
+ ZERO_STRUCTP(p);
+ SAFE_FREE(p);
+ }
+}
+
/****************************************************************************
Initialise the printing backend. Called once at startup.
Does not survive a fork
@@ -264,6 +287,7 @@ BOOL print_backend_init(void)
continue;
if (tdb_lock_bystring(pdb->tdb, sversion, 0) == -1) {
DEBUG(0,("print_backend_init: Failed to open printer %s database\n", lp_const_servicename(snum) ));
+ release_print_db(pdb);
return False;
}
if (tdb_fetch_int32(pdb->tdb, sversion) != PRINT_DATABASE_VERSION) {
@@ -271,8 +295,11 @@ BOOL print_backend_init(void)
tdb_store_int32(pdb->tdb, sversion, PRINT_DATABASE_VERSION);
}
tdb_unlock_bystring(pdb->tdb, sversion);
+ release_print_db(pdb);
}
+ close_all_print_db(); /* Don't leave any open. */
+
/* select the appropriate printing interface... */
#ifdef HAVE_CUPS
if (strcmp(lp_printcapname(), "cups") == 0)