summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJean-François Micouleau <jfm@samba.org>2001-10-16 23:16:00 +0000
committerJean-François Micouleau <jfm@samba.org>2001-10-16 23:16:00 +0000
commit3f1d1008428f9563d33dff96d1304e30dae3d0f2 (patch)
tree584916e758efe652c88ebfe40255c057e9526a15 /source3/printing
parent375dcb9a8b9bd5774fb4a947b07fd4c9f78f8719 (diff)
downloadsamba-3f1d1008428f9563d33dff96d1304e30dae3d0f2.tar.gz
samba-3f1d1008428f9563d33dff96d1304e30dae3d0f2.tar.bz2
samba-3f1d1008428f9563d33dff96d1304e30dae3d0f2.zip
very simple asynchronous "lpq" thread patch
To speed up operations with the lpq command, it's now run in a separate asynchronous process. Opening the Printers folder on NT is now fast ;-) I think even faster than with a ** server Jeremy, you should look at that patch to include it in 2.2.3 J.F. (This used to be commit 8ef9dff3074e7979579ce66a204e8ec7bf62a587)
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)