From 47955b2f6cd10ac690705d322a8862c23f18072c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Nov 2002 02:38:42 +0000 Subject: Merge of scalable printing code fix... Needs testing. Also tidied up some of Richard's code (I don't think he uses the compiler flags -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual like I do :-) :-). Jeremy. (This used to be commit 10024ed06e9d91f24fdc78d59eef2f76bf395438) --- source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a5e464f73b..245df2003f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -178,10 +178,18 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) Disconnect from the client ****************************************************************************/ -static void srv_spoolss_replycloseprinter(POLICY_HND *handle) +static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) { WERROR result; + /* + * Tell the specific printing tdb we no longer want messages for this printer + * by deregistering our PID. + */ + + if (!print_notify_deregister_pid(snum)) + DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", lp_const_servicename(snum) )); + /* weird if the test succeds !!! */ if (smb_connections==0) { DEBUG(0,("srv_spoolss_replycloseprinter:Trying to close non-existant notify backchannel !\n")); @@ -219,7 +227,8 @@ static void free_printer_entry(void *ptr) Printer_entry *Printer = (Printer_entry *)ptr; if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); + srv_spoolss_replycloseprinter(print_queue_snum(Printer->dev.handlename), + &Printer->notify.client_hnd); Printer->notify.flags=0; Printer->notify.options=0; @@ -2305,7 +2314,7 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_machine) +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine) { extern pstring global_myname; @@ -2396,7 +2405,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma Connect to the client. ****************************************************************************/ -static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) +static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { WERROR result; @@ -2418,6 +2427,14 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin register_message_flags( True, FLAG_MSG_PRINTING ); } + /* + * Tell the specific printing tdb we want messages for this printer + * by registering our PID. + */ + + if (!print_notify_register_pid(snum)) + DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", printer )); + smb_connections++; result = cli_spoolss_reply_open_printer(¬ify_cli, notify_cli.mem_ctx, printer, localprinter, @@ -2448,6 +2465,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 options = q_u->options; UNISTR2 *localmachine = &q_u->localmachine; uint32 printerlocal = q_u->printerlocal; + int snum; SPOOL_NOTIFY_OPTION *option = q_u->option; /* store the notify value in the printer struct */ @@ -2459,6 +2477,9 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + Printer->notify.flags=flags; Printer->notify.options=options; Printer->notify.printerlocal=printerlocal; @@ -2473,7 +2494,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE /* Connect to the client machine and send a ReplyOpenPrinter */ - if(!srv_spoolss_replyopenprinter(Printer->notify.localmachine, + if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) return WERR_SERVER_UNAVAILABLE; @@ -5832,7 +5853,7 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; - + int snum; Printer_entry *Printer= find_printer_index_by_hnd(p, handle); if (!Printer) { @@ -5840,8 +5861,11 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); + srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); Printer->notify.flags=0; Printer->notify.options=0; -- cgit