svn commit: samba r1885 - in branches/SAMBA_3_0/source: include lib
printing rpc_server smbd
jerry at samba.org
jerry at samba.org
Wed Aug 18 13:55:58 GMT 2004
Author: jerry
Date: 2004-08-18 13:55:58 +0000 (Wed, 18 Aug 2004)
New Revision: 1885
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_3_0/source&rev=1885&nolog=1
Log:
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
Modified:
branches/SAMBA_3_0/source/include/messages.h
branches/SAMBA_3_0/source/lib/messages.c
branches/SAMBA_3_0/source/printing/nt_printing.c
branches/SAMBA_3_0/source/printing/printing.c
branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c
branches/SAMBA_3_0/source/smbd/connection.c
branches/SAMBA_3_0/source/smbd/reply.c
branches/SAMBA_3_0/source/smbd/server.c
Changeset:
Modified: branches/SAMBA_3_0/source/include/messages.h
===================================================================
--- branches/SAMBA_3_0/source/include/messages.h 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/include/messages.h 2004-08-18 13:55:58 UTC (rev 1885)
@@ -49,11 +49,13 @@
/* 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
#define MSG_SMB_FORCE_TDIS 3002
@@ -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
Modified: branches/SAMBA_3_0/source/lib/messages.c
===================================================================
--- branches/SAMBA_3_0/source/lib/messages.c 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/lib/messages.c 2004-08-18 13:55:58 UTC (rev 1885)
@@ -576,8 +576,10 @@
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
Modified: branches/SAMBA_3_0/source/printing/nt_printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/nt_printing.c 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/printing/nt_printing.c 2004-08-18 13:55:58 UTC (rev 1885)
@@ -365,7 +365,18 @@
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 @@
#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 @@
*/
invalidate_printer_hnd_cache( printer.info_2->sharename );
+ send_printer_mod_msg( printer.info_2->sharename );
switch (level) {
case 2:
Modified: branches/SAMBA_3_0/source/printing/printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/printing.c 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/printing/printing.c 2004-08-18 13:55:58 UTC (rev 1885)
@@ -1183,7 +1183,7 @@
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);
Modified: branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c 2004-08-18 13:55:58 UTC (rev 1885)
@@ -180,7 +180,7 @@
/* 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 @@
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 @@
}
/********************************************************************
+ 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 @@
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 );
}
/*
Modified: branches/SAMBA_3_0/source/smbd/connection.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/connection.c 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/smbd/connection.c 2004-08-18 13:55:58 UTC (rev 1885)
@@ -222,7 +222,6 @@
}
pcrec = (struct connections_data *)dbuf.dptr;
- pcrec->bcast_msg_flags = msg_flags;
if (doreg)
pcrec->bcast_msg_flags |= msg_flags;
else
Modified: branches/SAMBA_3_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/reply.c 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/smbd/reply.c 2004-08-18 13:55:58 UTC (rev 1885)
@@ -242,7 +242,7 @@
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;
Modified: branches/SAMBA_3_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/server.c 2004-08-18 13:49:22 UTC (rev 1884)
+++ branches/SAMBA_3_0/source/smbd/server.c 2004-08-18 13:55:58 UTC (rev 1885)
@@ -846,6 +846,8 @@
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
More information about the samba-cvs
mailing list