diff options
author | Gerald Carter <jerry@samba.org> | 2004-08-18 13:55:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:52:23 -0500 |
commit | 1842fde7d10a6faccae1a24ebc67f8452a5a828e (patch) | |
tree | 1bb8a33a0ef7bea01532731ccbd965f5590e29a2 | |
parent | 5cd11b7127afed6a1e4e540721fa15d45aec471b (diff) | |
download | samba-1842fde7d10a6faccae1a24ebc67f8452a5a828e.tar.gz samba-1842fde7d10a6faccae1a24ebc67f8452a5a828e.tar.bz2 samba-1842fde7d10a6faccae1a24ebc67f8452a5a828e.zip |
r1885: tighten the cache consistency with the ntprinters.tdb entry an the in memory cache associated with open printer handles; also make sure that register_messages_flags() doesn't overwrite the originally registers flags
(This used to be commit 540daf71d8ad189af5dd6d45aa1ce2b3d67da752)
-rw-r--r-- | source3/include/messages.h | 13 | ||||
-rw-r--r-- | source3/lib/messages.c | 6 | ||||
-rw-r--r-- | source3/printing/nt_printing.c | 33 | ||||
-rw-r--r-- | source3/printing/printing.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 26 | ||||
-rw-r--r-- | source3/smbd/connection.c | 1 | ||||
-rw-r--r-- | source3/smbd/reply.c | 2 | ||||
-rw-r--r-- | source3/smbd/server.c | 2 |
8 files changed, 67 insertions, 18 deletions
diff --git a/source3/include/messages.h b/source3/include/messages.h index 78f19fa0bd..a87659f498 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -49,10 +49,12 @@ /* printing messages */ /* #define MSG_PRINTER_NOTIFY 2001*/ /* Obsolete */ -#define MSG_PRINTER_DRVUPGRADE 2002 -#define MSG_PRINTER_NOTIFY2 2003 -#define MSG_PRINTERDATA_INIT_RESET 2004 -#define MSG_PRINTER_UPDATE 2005 +#define MSG_PRINTER_NOTIFY2 2002 + +#define MSG_PRINTER_DRVUPGRADE 2101 +#define MSG_PRINTERDATA_INIT_RESET 2102 +#define MSG_PRINTER_UPDATE 2103 +#define MSG_PRINTER_MOD 2104 /* smbd messages */ #define MSG_SMB_CONF_UPDATED 3001 @@ -67,6 +69,7 @@ #define FLAG_MSG_GENERAL 0x0001 #define FLAG_MSG_SMBD 0x0002 #define FLAG_MSG_NMBD 0x0004 -#define FLAG_MSG_PRINTING 0x0008 +#define FLAG_MSG_PRINT_NOTIFY 0x0008 +#define FLAG_MSG_PRINT_GENERAL 0x0010 #endif diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 8706ede706..ded3ac95bb 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -576,8 +576,10 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type, msg_all.msg_flag = FLAG_MSG_GENERAL; else if (msg_type > 1000 && msg_type < 2000) msg_all.msg_flag = FLAG_MSG_NMBD; - else if (msg_type > 2000 && msg_type < 3000) - msg_all.msg_flag = FLAG_MSG_PRINTING; + else if (msg_type > 2000 && msg_type < 2100) + msg_all.msg_flag = FLAG_MSG_PRINT_NOTIFY; + else if (msg_type > 2100 && msg_type < 3000) + msg_all.msg_flag = FLAG_MSG_PRINT_GENERAL; else if (msg_type > 3000 && msg_type < 4000) msg_all.msg_flag = FLAG_MSG_SMBD; else diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 1c88bf27a8..b54e1f738d 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -365,6 +365,17 @@ BOOL nt_printing_init(void) message_register( MSG_PRINTERDATA_INIT_RESET, reset_all_printerdata ); + /* + * register callback to handle invalidating the printer cache + * between smbd processes. + */ + + message_register( MSG_PRINTER_MOD, receive_printer_mod_msg); + + /* of course, none of the message callbacks matter if you don't + tell messages.c that you interested in receiving PRINT_GENERAL + msgs. This is done in claim_connection() */ + return True; } @@ -3458,6 +3469,27 @@ static uint32 rev_changeid(void) #endif } +/******************************************************************** + Send a message to all smbds about the printer that just changed + ********************************************************************/ + +static BOOL send_printer_mod_msg( char* printername ) +{ + int len = strlen(printername); + + if (!len) + return False; + + DEBUG(10,("send_printer_mod_msg: Sending message about printer change [%s]\n", + printername)); + + /* spam everyone that we just changed this printer */ + + message_send_all( conn_tdb_ctx(), MSG_PRINTER_MOD, printername, len+1, False, NULL ); + + return True; +} + /* * The function below are the high level ones. * only those ones must be called from the spoolss code. @@ -3481,6 +3513,7 @@ WERROR mod_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level) */ invalidate_printer_hnd_cache( printer.info_2->sharename ); + send_printer_mod_msg( printer.info_2->sharename ); switch (level) { case 2: diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 10ca7e47e7..31cb0faa9b 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1183,7 +1183,7 @@ void start_background_queue(void) DEBUG(5,("start_background_queue: background LPQ thread started\n")); claim_connection( NULL, "smbd lpq backend", 0, False, - FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINTING ); + FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL); if (!locking_init(0)) { exit(1); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ccff65688a..5775b3ab49 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -180,7 +180,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) /* Tell the connections db we're no longer interested in * printer notify messages. */ - register_message_flags( False, FLAG_MSG_PRINTING ); + register_message_flags( False, FLAG_MSG_PRINT_NOTIFY ); } smb_connections--; @@ -1194,12 +1194,6 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz notify2_unpack_msg( ¬ify, &msg_tv, msg_ptr, msg_len ); msg_ptr += msg_len; - /* we don't know if the change was from us or not so kill - any cached printer objects */ - - if ( notify.type == PRINTER_NOTIFY_TYPE ) - invalidate_printer_hnd_cache( notify.printer ); - /* add to correct list in container */ notify_msg_ctr_addmsg( &messages, ¬ify ); @@ -1227,6 +1221,22 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz } /******************************************************************** + callback to MSG_PRINTER_CHANGED. When a printer is changed by + one smbd, all of processes must clear their printer cache immediately. + ********************************************************************/ + +void receive_printer_mod_msg(int msg_type, pid_t src, void *buf, size_t len) +{ + fstring printername; + + fstrcpy( printername, buf ); + + DEBUG(10,("receive_printer_mod_msg: Printer change [%s]\n", printername )); + + invalidate_printer_hnd_cache( printername ); +} + +/******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this driver @@ -2641,7 +2651,7 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); /* Tell the connections db we're now interested in printer * notify messages. */ - register_message_flags( True, FLAG_MSG_PRINTING ); + register_message_flags( True, FLAG_MSG_PRINT_NOTIFY ); } /* diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 5bb76eb3bd..fc5fe9d741 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -222,7 +222,6 @@ BOOL register_message_flags(BOOL doreg, uint32 msg_flags) } pcrec = (struct connections_data *)dbuf.dptr; - pcrec->bcast_msg_flags = msg_flags; if (doreg) pcrec->bcast_msg_flags |= msg_flags; else diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 74872eeea9..611fb04c19 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -242,7 +242,7 @@ int reply_special(char *inbuf,char *outbuf) reload_services(True); reopen_logs(); - claim_connection(NULL,"",0,True,FLAG_MSG_GENERAL|FLAG_MSG_SMBD); + claim_connection(NULL,"",0,True,FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL); already_got_session = True; break; diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 16281dd86c..0fe633bb96 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -846,6 +846,8 @@ void build_options(BOOL screen); exit(1); /* Setup the main smbd so that we can get messages. */ + /* don't worry about general printing messages here */ + claim_connection(NULL,"",0,True,FLAG_MSG_GENERAL|FLAG_MSG_SMBD); /* only start the background queue daemon if we are |