diff options
author | Jean-François Micouleau <jfm@samba.org> | 2001-10-16 23:16:00 +0000 |
---|---|---|
committer | Jean-François Micouleau <jfm@samba.org> | 2001-10-16 23:16:00 +0000 |
commit | 3f1d1008428f9563d33dff96d1304e30dae3d0f2 (patch) | |
tree | 584916e758efe652c88ebfe40255c057e9526a15 /source3 | |
parent | 375dcb9a8b9bd5774fb4a947b07fd4c9f78f8719 (diff) | |
download | samba-3f1d1008428f9563d33dff96d1304e30dae3d0f2.tar.gz samba-3f1d1008428f9563d33dff96d1304e30dae3d0f2.tar.xz 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')
-rw-r--r-- | source3/include/messages.h | 1 | ||||
-rw-r--r-- | source3/printing/printing.c | 52 | ||||
-rw-r--r-- | source3/smbd/server.c | 2 |
3 files changed, 53 insertions, 2 deletions
diff --git a/source3/include/messages.h b/source3/include/messages.h index cc10f3b90bb..dfbc4862117 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -37,6 +37,7 @@ /* rpc messages */ #define MSG_PRINTER_NOTIFY 2001 +#define MSG_PRINTER_UPDATE 2002 /* smbd messages */ #define MSG_SMB_CONF_UPDATED 3001 diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 9135cb2d5ef..db675853327 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) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index f707a61376e..4599cef41fb 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -791,6 +791,8 @@ static void usage(char *pname) /* Setup the main smbd so that we can get messages. */ claim_connection(NULL,"",MAXSTATUS,True); + start_background_queue(); + if (!open_sockets(is_daemon,port)) exit(1); |