summaryrefslogtreecommitdiff
path: root/source3/printing/notify.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/printing/notify.c')
-rw-r--r--source3/printing/notify.c120
1 files changed, 16 insertions, 104 deletions
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index 003718ed72..925d49a21d 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -22,99 +22,21 @@
#include "printing.h"
-static TALLOC_CTX *send_ctx;
-
-static struct notify_queue {
- struct notify_queue *next, *prev;
- void *buf;
- size_t buflen;
-} *notify_queue_head = NULL;
-
-/*******************************************************************
- Used to decide if we need a short select timeout.
-*******************************************************************/
-
-BOOL print_notify_messages_pending(void)
-{
- return (notify_queue_head != NULL);
-}
-
-/*******************************************************************
- Actually send the batched messages.
-*******************************************************************/
-
-void print_notify_send_messages(void)
-{
- TDB_CONTEXT *tdb;
- char *buf;
- struct notify_queue *pq;
- size_t msg_count = 0, offset = 0;
-
- if (!print_notify_messages_pending())
- return;
-
- if (!send_ctx)
- return;
-
- tdb = conn_tdb_ctx();
-
- if (!tdb) {
- DEBUG(3, ("Failed to open connections database in send_spoolss_notify2_msg\n"));
- return;
- }
-
- /* Count the space needed to send the messages. */
- for (pq = notify_queue_head; pq; pq = pq->next, msg_count++)
- offset += (pq->buflen + 4);
-
- offset += 4; /* For count. */
-
- buf = talloc(send_ctx, offset);
- if (!buf) {
- DEBUG(0,("print_notify_send_messages: Out of memory\n"));
- talloc_destroy_pool(send_ctx);
- return;
- }
-
- offset = 0;
- SIVAL(buf,offset,msg_count);
- offset += 4;
- for (pq = notify_queue_head; pq; pq = pq->next) {
- SIVAL(buf,offset,pq->buflen);
- offset += 4;
- memcpy(buf + offset, pq->buf, pq->buflen);
- offset += pq->buflen;
- }
-
- DEBUG(5, ("print_notify_send_messages: sending %d print notify message%s\n",
- msg_count, msg_count != 1 ? "s" : ""));
-
- message_send_all(tdb, MSG_PRINTER_NOTIFY2, buf, offset, False, NULL);
- talloc_destroy_pool(send_ctx);
- notify_queue_head = NULL;
-}
-
-/*******************************************************************
- Batch up print notify messages.
-*******************************************************************/
+/*
+ * Print notification routines
+ */
static void send_spoolss_notify2_msg(struct spoolss_notify_msg *msg)
{
char *buf = NULL;
- size_t buflen = 0, len;
- struct notify_queue *pnqueue, *tmp_ptr;
+ int buflen = 0, len;
+ TDB_CONTEXT *tdb;
/* Let's not waste any time with this */
if (lp_disable_spoolss())
return;
- if (!send_ctx)
- send_ctx = talloc_init_named("print notify queue");
-
- if (!send_ctx)
- goto fail;
-
/* Flatten data into a message */
again:
@@ -137,34 +59,24 @@ again:
msg->len, msg->notify.data);
if (buflen != len) {
- buf = talloc_realloc(send_ctx, buf, len);
- if (!buf)
- goto fail;
+ buf = Realloc(buf, len);
buflen = len;
goto again;
}
- /* Store the message on the pending queue. */
-
- pnqueue = talloc(send_ctx, sizeof(*pnqueue));
- if (!pnqueue)
- goto fail;
-
- pnqueue->buf = buf;
- pnqueue->buflen = buflen;
-
- DEBUG(5, ("send_spoolss_notify2_msg: appending message 0x%02x/0x%02x to notify_queue_head\n", msg->type, msg->field));
-
- /* Note we add to the end of the list to ensure
- * the messages are sent in the order they were received. JRA.
- */
- DLIST_ADD_END(notify_queue_head, pnqueue, tmp_ptr);
+ /* Send message */
- return;
+ tdb = conn_tdb_ctx();
- fail:
+ if (!tdb) {
+ DEBUG(3, ("Failed to open connections database in send_spoolss_notify2_msg\n"));
+ goto done;
+ }
+
+ message_send_all(tdb, MSG_PRINTER_NOTIFY2, buf, buflen, False, NULL);
- DEBUG(0,("send_spoolss_notify2_msg: Out of memory.\n"));
+done:
+ SAFE_FREE(buf);
}
static void send_notify_field_values(const char *printer_name, uint32 type,