summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/printing.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 9135cb2d5e..db67585332 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -311,10 +311,10 @@ static void set_updating_pid(fstring printer_name, BOOL delete)
}
/****************************************************************************
-update the internal database from the system print queue for a queue
+update the internal database from the system print queue for a queue in the background
****************************************************************************/
-static void print_queue_update(int snum)
+static void print_queue_update_background(int snum)
{
int i, qcount;
print_queue_struct *queue = NULL;
@@ -468,6 +468,54 @@ static void print_queue_update(int snum)
}
/****************************************************************************
+this is the receive function of the background lpq updater
+****************************************************************************/
+static void print_queue_receive(int msg_type, pid_t src, void *buf, size_t len)
+{
+ int snum;
+ snum=*((int *)buf);
+ print_queue_update_background(snum);
+}
+
+/****************************************************************************
+main thread of the background lpq updater
+****************************************************************************/
+void start_background_queue(void)
+{
+ DEBUG(3,("Starting background LPQ thread\n"));
+ if(sys_fork()==0) {
+ DEBUG(5,("background LPQ thread started\n"));
+
+ claim_connection(NULL,"smbd lpq backend",MAXSTATUS,False);
+
+ if (!locking_init(0)) {
+ exit(1);
+ }
+
+ if (!print_backend_init()) {
+ exit(1);
+ }
+
+ message_register(MSG_PRINTER_UPDATE, print_queue_receive);
+
+ DEBUG(5,("background LPQ thread waiting for messages\n"));
+ while (1) {
+ pause();
+ DEBUG(10,("background LPQ thread got a message\n"));
+ message_dispatch();
+ }
+ }
+}
+
+/****************************************************************************
+update the internal database from the system print queue for a queue
+****************************************************************************/
+static void print_queue_update(int snum)
+{
+ message_send_all(conn_tdb_ctx(), MSG_PRINTER_UPDATE, &snum, sizeof(snum), False);
+}
+
+/****************************************************************************
check if a jobid is valid. It is valid if it exists in the database
****************************************************************************/
BOOL print_job_exists(int jobid)