summaryrefslogtreecommitdiff
path: root/source3/printing/notify.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-10-03 14:18:35 -0700
committerJeremy Allison <jra@samba.org>2008-10-03 14:18:35 -0700
commitf6c883b4b00f4cd751cd312a27bddffb3be9c059 (patch)
tree2f05ee49e052f94b2be2f4783715521e114a7cbc /source3/printing/notify.c
parent4b9cc7d478438e34217add83b2647d47d52268a7 (diff)
downloadsamba-f6c883b4b00f4cd751cd312a27bddffb3be9c059.tar.gz
samba-f6c883b4b00f4cd751cd312a27bddffb3be9c059.tar.bz2
samba-f6c883b4b00f4cd751cd312a27bddffb3be9c059.zip
Simply our main loop processing. A lot :-). Correctly use events for all the previous "special" cases.
A step on the way to adding signals to the events and being able to merge the S3 event system with the S4 one. Jeremy.
Diffstat (limited to 'source3/printing/notify.c')
-rw-r--r--source3/printing/notify.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index 23df17c389..f6599c413d 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -34,6 +34,7 @@ static struct notify_queue {
size_t buflen;
} *notify_queue_head = NULL;
+static struct timed_event *notify_event;
static bool create_send_ctx(void)
{
@@ -214,6 +215,22 @@ void print_notify_send_messages(struct messaging_context *msg_ctx,
num_messages = 0;
}
+/*******************************************************************
+ Event handler to send the messages.
+*******************************************************************/
+
+static void print_notify_event_send_messages(struct event_context *event_ctx,
+ struct timed_event *te,
+ const struct timeval *now,
+ void *private_data)
+{
+ /* Remove this timed event handler. */
+ TALLOC_FREE(notify_event);
+
+ change_to_root_user();
+ print_notify_send_messages(smbd_messaging_context(), 0);
+}
+
/**********************************************************************
deep copy a SPOOLSS_NOTIFY_MSG structure using a TALLOC_CTX
*********************************************************************/
@@ -304,6 +321,15 @@ to notify_queue_head\n", msg->type, msg->field, msg->printer));
DLIST_ADD_END(notify_queue_head, pnqueue, struct notify_queue *);
num_messages++;
+
+ if (smbd_event_context()) {
+ /* Add an event for 1 second's time to send this queue. */
+ notify_event = event_add_timed(smbd_event_context(), NULL,
+ timeval_current_ofs(1,0),
+ "print_notify",
+ print_notify_event_send_messages, NULL);
+ }
+
}
static void send_notify_field_values(const char *sharename, uint32 type,