summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-09-07 17:08:59 +0000
committerGerald Carter <jerry@samba.org>2002-09-07 17:08:59 +0000
commit2968f8a6be77db036bad42e1a8489ca7e8dfd9bc (patch)
treeead4a0f59aecc32df26f56e8b8acae8bcaedfcd8 /source3/rpc_server
parent8352336ad03b543522aa10340c18c74a58cdf874 (diff)
downloadsamba-2968f8a6be77db036bad42e1a8489ca7e8dfd9bc.tar.gz
samba-2968f8a6be77db036bad42e1a8489ca7e8dfd9bc.tar.bz2
samba-2968f8a6be77db036bad42e1a8489ca7e8dfd9bc.zip
merge of printer change notify fix from APP_HEAD
(This used to be commit 6a53a9cb7c56927423dea125c65d66605fae566f)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 3a2bde2d05..795a420a23 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -170,6 +170,41 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp)
SAFE_FREE(*pp);
}
+/****************************************************************************
+ wrapper function to maintain a reference count to the number of
+ open change notification handles we have
+****************************************************************************/
+
+static BOOL spooler_message_flags( BOOL doreg )
+{
+ static uint32 ref_count = 0;
+ BOOL result = True;
+
+ /*
+ * check for boundary counditions ....
+ * if ref_count == 0 and we want to register OR
+ * if ref_count == 1 and we want to deregister, THEN
+ * OK.
+ */
+
+ if ( ((ref_count == 0) && doreg) || ((ref_count == 1) && !doreg) )
+ result = register_message_flags( doreg, FLAG_MSG_PRINTING );
+
+ /* increment/decrement reference count */
+
+ if ( doreg )
+ ref_count++;
+ else {
+ /* minimum is always 0 */
+ if ( ref_count )
+ ref_count--;
+ }
+
+ DEBUG(10,("spooler_message_flags: ref_count == %d\n", ref_count));
+
+ return result;
+}
+
/***************************************************************************
Disconnect from the client
****************************************************************************/
@@ -198,6 +233,11 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle)
message_deregister(MSG_PRINTER_NOTIFY2);
}
+ /* Tell the connections db we're not interested in printer notify messages. */
+ /* reference count is handled by spooler_message_flags() */
+
+ spooler_message_flags( False );
+
smb_connections--;
}
@@ -220,9 +260,6 @@ static void free_printer_entry(void *ptr)
Printer->notify.option=NULL;
Printer->notify.client_connected=False;
- /* Tell the connections db we're not interested in printer notify messages. */
- register_message_flags(False, FLAG_MSG_PRINTING);
-
/* Remove from the internal list. */
DLIST_REMOVE(printers_list, Printer);
@@ -2242,8 +2279,6 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE
&Printer->notify.client_hnd))
return WERR_SERVER_UNAVAILABLE;
- /* Tell the connections db we're interested in printer notify messages. */
- register_message_flags(True, FLAG_MSG_PRINTING);
Printer->notify.client_connected=True;
return WERR_OK;
@@ -5599,9 +5634,6 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u)
free_spool_notify_option(&Printer->notify.option);
Printer->notify.client_connected=False;
- /* Tell the connections db we're not interested in printer notify messages. */
- register_message_flags(False, FLAG_MSG_PRINTING);
-
return WERR_OK;
}