diff options
author | Jeremy Allison <jra@samba.org> | 2008-04-04 11:14:09 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2008-04-04 11:14:09 -0700 |
commit | 40d16fa275888b0dbb5894d484966c858187997c (patch) | |
tree | 81570fd2138c3b1ffc9ff24cd5789858b7ba48ec | |
parent | 0000eeb9b859ef3f9dcc6b659d27c897048c63f6 (diff) | |
download | samba-40d16fa275888b0dbb5894d484966c858187997c.tar.gz samba-40d16fa275888b0dbb5894d484966c858187997c.tar.xz samba-40d16fa275888b0dbb5894d484966c858187997c.zip |
Fix bug #5372. With a large CUPS installation with a remote server, contacting
the server when searching for a name for the location and comment fields can
take so much time the client times out. When searching for a name we don't
use these fields anyway, so add a function get_a_printer_search() which
doesn't contact the CUPS server.
Jeremy.
(This used to be commit 92d9f20852d5384e92a93dd0b051034718840ca8)
-rw-r--r-- | source3/printing/nt_printing.c | 49 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 8 |
2 files changed, 45 insertions, 12 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 68b035962f2..7b03a32fa8c 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -3973,7 +3973,11 @@ static void map_to_os2_driver(fstring drivername) /**************************************************************************** Get a default printer info 2 struct. ****************************************************************************/ -static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info, const char *servername, const char* sharename) + +static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info, + const char *servername, + const char* sharename, + bool get_loc_com) { int snum = lp_servicenumber(sharename); @@ -4000,7 +4004,7 @@ static WERROR get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 *info, const char fstrcpy(info->datatype, "RAW"); #ifdef HAVE_CUPS - if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { + if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { /* Pull the location and comment strings from cups if we don't already have one */ if ( !strlen(info->location) || !strlen(info->comment) ) @@ -4049,7 +4053,11 @@ fail: /**************************************************************************** ****************************************************************************/ -static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, const char *servername, const char *sharename) + +static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, + const char *servername, + const char *sharename, + bool get_loc_com) { int len = 0; int snum = lp_servicenumber(sharename); @@ -4062,7 +4070,8 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, const char *servern dbuf = tdb_fetch(tdb_printers, kbuf); if (!dbuf.dptr) { - return get_a_printer_2_default(info, servername, sharename); + return get_a_printer_2_default(info, servername, + sharename, get_loc_com); } len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "dddddddddddfffffPfffff", @@ -4110,7 +4119,7 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info, const char *servern fstrcpy(info->printername, printername); #ifdef HAVE_CUPS - if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { + if (get_loc_com && (enum printing_types)lp_printing(snum) == PRINT_CUPS ) { /* Pull the location and comment strings from cups if we don't already have one */ if ( !strlen(info->location) || !strlen(info->comment) ) @@ -4694,8 +4703,8 @@ WERROR save_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level, uint8 *dat ****************************************************************************/ -WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, - const char *sharename) +static WERROR get_a_printer_internal( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level, + const char *sharename, bool get_loc_com) { WERROR result; fstring servername; @@ -4723,11 +4732,11 @@ WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_print sizeof(servername)-1 ); } - result = get_a_printer_2( (*pp_printer)->info_2, servername, sharename ); - - + result = get_a_printer_2( (*pp_printer)->info_2, + servername, sharename, get_loc_com); + /* we have a new printer now. Save it with this handle */ - + if ( !W_ERROR_IS_OK(result) ) { TALLOC_FREE( *pp_printer ); DEBUG(10,("get_a_printer: [%s] level %u returning %s\n", @@ -4747,6 +4756,24 @@ WERROR get_a_printer( Printer_entry *print_hnd, NT_PRINTER_INFO_LEVEL **pp_print return WERR_OK; } +WERROR get_a_printer( Printer_entry *print_hnd, + NT_PRINTER_INFO_LEVEL **pp_printer, + uint32 level, + const char *sharename) +{ + return get_a_printer_internal(print_hnd, pp_printer, level, + sharename, true); +} + +WERROR get_a_printer_search( Printer_entry *print_hnd, + NT_PRINTER_INFO_LEVEL **pp_printer, + uint32 level, + const char *sharename) +{ + return get_a_printer_internal(print_hnd, pp_printer, level, + sharename, false); +} + /**************************************************************************** Deletes a NT_PRINTER_INFO_LEVEL struct. ****************************************************************************/ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 403beb6782b..7788e763fa5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -521,7 +521,13 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) fstrcpy(sname, lp_servicename(snum)); printer = NULL; - result = get_a_printer( NULL, &printer, 2, sname ); + + /* This call doesn't fill in the location or comment from + * a CUPS server for efficiency with large numbers of printers. + * JRA. + */ + + result = get_a_printer_search( NULL, &printer, 2, sname ); if ( !W_ERROR_IS_OK(result) ) { DEBUG(0,("set_printer_hnd_name: failed to lookup printer [%s] -- result [%s]\n", sname, dos_errstr(result))); |