summaryrefslogtreecommitdiff
path: root/source3/printing/printing.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-10-31 23:41:00 +0000
committerJeremy Allison <jra@samba.org>2002-10-31 23:41:00 +0000
commita63844e10e3e498c1c1e8457d50eb6ab1e6510cf (patch)
treece8d2ee5c9f1c289dd282cba80b0a8f8f1a680e9 /source3/printing/printing.c
parent63eefb36f15c9c823e0a1a33e2fd99f4bb10a993 (diff)
downloadsamba-a63844e10e3e498c1c1e8457d50eb6ab1e6510cf.tar.gz
samba-a63844e10e3e498c1c1e8457d50eb6ab1e6510cf.tar.bz2
samba-a63844e10e3e498c1c1e8457d50eb6ab1e6510cf.zip
Fix slowdown because of enumerating all print queues on every smbd startup.
Jeremy. (This used to be commit 6efd17ef78ebcfed1130312fa019d674e4663a00)
Diffstat (limited to 'source3/printing/printing.c')
-rw-r--r--source3/printing/printing.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 2d75699ac5..2121fb20a3 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -154,6 +154,7 @@ static struct tdb_print_db *get_print_db_byname(const char *printername)
struct tdb_print_db *p = NULL, *last_entry = NULL;
int num_open = 0;
pstring printdb_path;
+ BOOL done_become_root = False;
for (p = print_db_head, last_entry = print_db_head; p; p = p->next) {
/* Ensure the list terminates... JRA. */
@@ -209,9 +210,15 @@ static struct tdb_print_db *get_print_db_byname(const char *printername)
pstrcat(printdb_path, printername);
pstrcat(printdb_path, ".tdb");
- become_root();
+ if (geteuid() != 0) {
+ become_root();
+ done_become_root = True;
+ }
+
p->tdb = tdb_open_log(printdb_path, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
- unbecome_root();
+
+ if (done_become_root)
+ unbecome_root();
if (!p->tdb) {
DEBUG(0,("get_print_db: Failed to open printer backend database %s.\n",
@@ -255,8 +262,7 @@ static void close_all_print_db(void)
}
/****************************************************************************
- Initialise the printing backend. Called once at startup.
- Does not survive a fork
+ Initialise the printing backend. Called once at startup before the fork().
****************************************************************************/
BOOL print_backend_init(void)
@@ -316,16 +322,7 @@ BOOL print_backend_init(void)
void printing_end(void)
{
- struct tdb_print_db *p;
-
- for (p = print_db_head; p; ) {
- struct tdb_print_db *next_p = p->next;
- if (p->tdb)
- tdb_close(p->tdb);
- DLIST_REMOVE(print_db_head, p);
- SAFE_FREE(p);
- p = next_p;
- }
+ close_all_print_db(); /* Don't leave any open. */
}
/****************************************************************************