CVS update: samba/source/include

Jeremy Allison jra at samba.org
Tue Oct 16 16:49:03 GMT 2001


On Tue, Oct 16, 2001 at 04:16:00PM -0700, jfm at samba.org wrote:
> 
> Date:	Tue Oct 16 16:15:59 2001
> Author:	jfm
> 
> Update of /data/cvs/samba/source/include
> In directory va:/tmp/cvs-serv31833/include
> 
> Modified Files:
> 	messages.h 
> Log Message:
> 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

JF - this looks *brillient* !

Currently though you're doing a message_send_all() to tell
the background lpq smbd to update the queue - you should be
able to just store the processid of the child created in 
start_background_queue() and just send to that process, 
after all every process will inherit this value.

What about this patch. Can you let me know what you think ?

Also, I'm not sure about the use of pause(), I think this needs 
to be a POSIX sigwait(), but I'll look into that.

Cheers & THANKS !!!!!

Jeremy.

Index: printing/printing.c
===================================================================
RCS file: /data/cvs/samba/source/printing/printing.c,v
retrieving revision 1.122
diff -u -r1.122 printing.c
--- printing/printing.c	16 Oct 2001 23:16:00 -0000	1.122
+++ printing/printing.c	16 Oct 2001 23:47:34 -0000
@@ -477,14 +477,24 @@
 	print_queue_update_background(snum);
 }
 
+static pid_t background_lpq_updater_pid;
+
 /****************************************************************************
 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"));
+	DEBUG(3,("start_background_queue: Starting background LPQ thread\n"));
+	background_lpq_updater_pid = sys_fork();
+
+	if (background_lpq_updater_pid == -1) {
+		DEBUG(5,("start_background_queue: background LPQ thread failed to start. %s\n", strerror(errno) ));
+		exit(1);
+	}
+
+	if(background_lpq_updater_pid == 0) {
+		/* Child. */
+		DEBUG(5,("start_background_queue: background LPQ thread started\n"));
 
 		claim_connection(NULL,"smbd lpq backend",MAXSTATUS,False);
 
@@ -498,10 +508,10 @@
 
 		message_register(MSG_PRINTER_UPDATE, print_queue_receive);
 		
-		DEBUG(5,("background LPQ thread waiting for messages\n"));
+		DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
 		while (1) {
 			pause();
-			DEBUG(10,("background LPQ thread got a message\n"));
+			DEBUG(10,("start_background_queue: background LPQ thread got a message\n"));
 			message_dispatch();
 		}
 	}
@@ -512,7 +522,7 @@
 ****************************************************************************/
 static void print_queue_update(int snum)
 {
-	message_send_all(conn_tdb_ctx(), MSG_PRINTER_UPDATE, &snum, sizeof(snum), False);
+	message_send_pid(background_lpq_updater_pid, MSG_PRINTER_UPDATE, &snum, sizeof(snum), False);
 }
 
 /****************************************************************************





More information about the samba-technical mailing list