From 3f1d1008428f9563d33dff96d1304e30dae3d0f2 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 16 Oct 2001 23:16:00 +0000 Subject: 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) --- source3/printing/printing.c | 52 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'source3/printing/printing.c') 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; @@ -467,6 +467,54 @@ static void print_queue_update(int snum) set_updating_pid(printer_name, True); } +/**************************************************************************** +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 ****************************************************************************/ -- cgit