diff options
author | Gerald Carter <jerry@samba.org> | 2004-05-27 15:38:54 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:51:49 -0500 |
commit | 7959cba656133840c37d293ffab6831f3097016f (patch) | |
tree | 356d488c22648f7159a9f32bbc53726645e2309a /source3/printing | |
parent | 73b9376e26e7e16c05cad6bc83ca1235a0436eb3 (diff) | |
download | samba-7959cba656133840c37d293ffab6831f3097016f.tar.gz samba-7959cba656133840c37d293ffab6831f3097016f.tar.bz2 samba-7959cba656133840c37d293ffab6831f3097016f.zip |
r925: add changes frpm trunk (r841 and r842) -- enable background queue update process and allow printers to have different sharenames from printernames
(This used to be commit 066b9c4276a968788a03709a00d4f672ac032df7)
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/notify.c | 9 | ||||
-rw-r--r-- | source3/printing/printing.c | 88 |
2 files changed, 96 insertions, 1 deletions
diff --git a/source3/printing/notify.c b/source3/printing/notify.c index 7750239630..26ef191f87 100644 --- a/source3/printing/notify.c +++ b/source3/printing/notify.c @@ -463,6 +463,15 @@ void notify_printer_sharename(int snum, char *share_name) snum, strlen(share_name) + 1, share_name); } +void notify_printer_printername(int snum, char *printername) +{ + const char *printer_name = SERVICE(snum); + + send_notify_field_buffer( + printer_name, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, + snum, strlen(printername) + 1, printername); +} + void notify_printer_port(int snum, char *port_name) { const char *printer_name = SERVICE(snum); diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 2355dd1450..670e489786 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -23,6 +23,9 @@ #include "includes.h" #include "printing.h" +extern SIG_ATOMIC_T got_sig_term; +extern SIG_ATOMIC_T reload_after_sighup; + /* Current printer interface */ static BOOL remove_from_jobs_changed(int snum, uint32 jobid); @@ -971,7 +974,7 @@ static void check_job_changed(int snum, TDB_DATA data, uint32 jobid) Update the internal database from the system print queue for a queue. ****************************************************************************/ -static void print_queue_update(int snum) +static void print_queue_update_internal(int snum) { int i, qcount; print_queue_struct *queue = NULL; @@ -1151,6 +1154,89 @@ 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_internal(snum); +} + +static pid_t background_lpq_updater_pid = -1; + +/**************************************************************************** +main thread of the background lpq updater +****************************************************************************/ +void start_background_queue(void) +{ + 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", 0, False, + FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINTING ); + + if (!locking_init(0)) { + exit(1); + } + + if (!print_backend_init()) { + exit(1); + } + + message_register(MSG_PRINTER_UPDATE, print_queue_receive); + + DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n")); + while (1) { + pause(); + + /* check for some essential signals first */ + + if (got_sig_term) { + exit_server("Caught TERM signal"); + } + + if (reload_after_sighup) { + change_to_root_user(); + DEBUG(1,("Reloading services after SIGHUP\n")); + reload_services(False); + reload_after_sighup = 0; + } + + /* now check for messages */ + + DEBUG(10,("start_background_queue: 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) +{ + /* + * Make sure that the backgroup queueu process exists. + * Otherwise just do the update ourselves + */ + + if ( background_lpq_updater_pid != -1 ) + message_send_pid(background_lpq_updater_pid, MSG_PRINTER_UPDATE, &snum, sizeof(snum), False); + else + print_queue_update_internal( snum ); +} + +/**************************************************************************** Create/Update an entry in the print tdb that will allow us to send notify updates only to interested smbd's. ****************************************************************************/ |