From ca4c584fb553c650753e6c621d58c1fa71e8adc8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 16 Oct 2001 23:52:14 +0000 Subject: Optimisation to send only to correct processid. Jeremy (This used to be commit 3807c747a4522c719fe67b876e4a3bd92bffcf7f) --- source3/printing/printing.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source3/printing') diff --git a/source3/printing/printing.c b/source3/printing/printing.c index db67585332..acdaed46ae 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -477,14 +477,24 @@ static void print_queue_receive(int msg_type, pid_t src, void *buf, size_t len) 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 @@ void start_background_queue(void) 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 @@ 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); + message_send_pid(background_lpq_updater_pid, MSG_PRINTER_UPDATE, &snum, sizeof(snum), False); } /**************************************************************************** -- cgit