mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
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 commit is contained in:
parent
dae084d713
commit
540daf71d8
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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 );
|
||||
@ -1226,6 +1220,22 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz
|
||||
return;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
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
|
||||
@ -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 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user