diff options
author | Jeremy Allison <jra@samba.org> | 2002-10-26 00:29:04 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-10-26 00:29:04 +0000 |
commit | 0e7938ab5dc666d83a490210d35fee03f6483e49 (patch) | |
tree | e42943a73eafe2ed5993ee24865e9dfffdcae962 | |
parent | 35357e85891f24636bb563ae23569ac83517cbae (diff) | |
download | samba-0e7938ab5dc666d83a490210d35fee03f6483e49.tar.gz samba-0e7938ab5dc666d83a490210d35fee03f6483e49.tar.bz2 samba-0e7938ab5dc666d83a490210d35fee03f6483e49.zip |
Fix problem where an fd would be left open for every printer queue.
Jeremy.
(This used to be commit e240c7a428659bce392d47f2eda16bdcf32863c1)
-rw-r--r-- | source3/printing/printing.c | 27 |
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) |