summaryrefslogtreecommitdiff
path: root/source3/printing/queue_process.c
AgeCommit message (Collapse)AuthorFilesLines
2025-11-14s3:printing: Load the shares for [printers] in samba-bgqdAndreas Schneider1-0/+3
One of the main functions of bgqd is: delete_and_reload_printers_full() It isn't able to do its work, if we don't load the shares. Normally bgqd was forked from smbd and this loaded the shares. But with the introduction of samba-dcerpcd it is a standalone service now. As a standalone service it is responsible to load the shares if it needs to work on them. The following message is printed if delete_and_reload_printers_full() tries to do its job: [2025/10/23 09:57:27, 7, pid=41935, effective(0, 0), real(0, 0)] ../../source3/param/loadparm.c:4419(lp_servicenumber) lp_servicenumber: couldn't find printers [2025/10/23 09:57:27, 7, pid=41935, effective(0, 0), real(0, 0)] ../../source3/param/loadparm.c:4419(lp_servicenumber) lp_servicenumber: couldn't find printers BUG: https://bugzilla.samba.org/show_bug.cgi?id=15936 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-09-25s3: SIGHUP handlers use consistent log level 3Jones Syue1-1/+1
When turn-on 'log level = 3', sending SIGHUP to samba processes, for example: smbd parent/children, smbd-notifyd, and smbd-cleanupd. Then monitor log.smbd in order to parse sighup logs, it looks like the log level is inconsistent among these processes: smbd parent/children use level 1, and smbd-notifyd/smbd-cleanupd use level 3. This patch raises sighup handler's log level from level 1 to level 3, which is more consistent with smbd-notifyd by Commit 6e5bff80a0a0b ("s3:notifyd: Handle sigup in notifyd to reparse smb.conf"), and smbd-cleanupd by Commit 57c1e115ecef4 ("smbd: reopen logs on SIGHUP for notifyd and cleanupd"). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15706 Signed-off-by: Jones Syue <jonessyue@qnap.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Wed Sep 25 01:38:02 UTC 2024 on atb-devel-224
2024-03-22lib: Remove timeval_set()Volker Lendecke1-4/+7
We have the same function in tevent, no need to duplicate code. More lines just due to clang-format. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Mar 22 06:07:42 UTC 2024 on atb-devel-224
2022-05-31s3:printing: Start samba-bgqd as soon as possibleAndreas Schneider1-4/+4
We need some time to fill the printcap cache. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15081 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue May 31 21:51:07 UTC 2022 on sn-devel-184
2022-05-31s3:printing: Initialize the printcap cache as soon as the bgqd startsAndreas Schneider1-0/+3
As soon as the background daemon starts, we need to initialize the printcap cache so that rpcd-spoolssd can serve printers. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15081 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-12-10printing: Remove "start_daemons" from printing_subsystem_init()Volker Lendecke1-24/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2021-12-10s3:rpc_server: Activate samba-dcerpcdVolker Lendecke1-31/+4
This is the big switch to use samba-dcerpcd for the RPC services in source3/. It is a pretty big and unordered patch, but I don't see a good way to split this up into more manageable pieces without sacrificing bisectability even more. Probably I could cut out a few small ones, but a major architechtural switch like this will always be messy. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2021-10-13source3/printing/queue_process.c: fix build on macOSAlex Richardson1-2/+0
On macOS environ is defined to (*_NSGetEnviron()) in lib/replace/replace.h and otherwise the `extern char **environ` can be found there. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14862 Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-11printing: Avoid a few references to background_lpq_updater_pidVolker Lendecke1-0/+15
We have the bgqd in the pidfile now Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue May 11 23:45:21 UTC 2021 on sn-devel-184
2021-05-11printing: Introduce samba-bgqdVolker Lendecke1-76/+56
This is a separate binary executed from start_background_queue(). As such it does not really gain much, but the idea is to move all the code this runs out of the smbd and spoolssd binaries to just link here. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-11printing: Factor out register_printing_bq_handlers()Volker Lendecke1-36/+77
The printing background jobs can be provided independently of the start_background_queue() implementation. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-04-27printing: Avoid zombies in the background daemonVolker Lendecke1-8/+14
Whatever you read about waitpid() tells you should should run it in a loop. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-27printing: Reduce indentation in start_background_queue()Volker Lendecke1-46/+43
We don't need the "if(pid==0)" here, we've covered "if(pid!=0)" a few lines above. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-27printing: Remove dead codeVolker Lendecke1-5/+0
This was already covered a few lines above. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-27printing: Remove the pause_pipe[] from queue_process.cVolker Lendecke1-37/+0
Since c80f70390c37 we don't need this explicit pipe anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-03-24printing: Fix typosVolker Lendecke1-2/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-24printing: Passing a fn pointer does not need "&"Volker Lendecke1-6/+6
Just looked a bit weird and different from all other fn pointer references in Samba. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-16printing: Introduce printer_list_printername_exists()Volker Lendecke1-1/+3
Replace pcap_printername_ok(). Slightly different semantics: If the printer list db has a corrupted record, this is not detected. Why this patch? pcap_printername_ok() is a simple wrapper around the tdb accessing function, and this reduces a dependency on pcap.c Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-08lib: give global_contexts.c its own header fileVolker Lendecke1-0/+1
It's a bit shocking how many references we have to global contexts. Make this a bit more obvious. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-10smbd: Give locking/share_mode_lock.c its own header fileVolker Lendecke1-0/+1
To me this is then easier to figure out what is defined there, and where it's exactly used. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-20s3:rpc_server: Reinitialize dcesrv_context in external spoolssd daemonSamuel Cabrero1-1/+2
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-11-27s3:param: make "servicename" a substituted optionRalph Boehme1-0/+1
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-11-27smbdotconf: mark "printername" with substitution="1"Ralph Boehme1-1/+3
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-10-18s3:printing: Add spoolssd header fileSamuel Cabrero1-3/+1
Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-02-01printing: check lp_load_printers() prior to pcap cache updateDavid Disseldorp1-1/+1
Avoid explicit and housekeeping timer triggered printcap cache updates if lp_load_printers() is disabled. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13766 Signed-off-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Fri Feb 1 19:25:03 CET 2019 on sn-devel-144
2019-02-01printing: drop pcap_cache_loaded() guard around load_printers()David Disseldorp1-3/+1
Add the pcap_cache_loaded() check to load_printers() and return early if it returns false. This simplifies callers in preparation for checking lp_load_printers() in the printcap cache update code-path. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13766 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2018-09-07s3: Rename server_event_context() to global_event_context()Christof Schmitt1-2/+2
This reflects that the event context is also used outside of the server processes. The command used for the rename: find . -name '*.[hc]' -print0 | xargs -0 sed -i 's/server_event_context/global_event_context/' Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-06-14printing: remove unused arguments from delete_and_reload_printers()Stefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-06-14printing: remove unused arguments from load_printers()Stefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-04-24lib: #include "util_event.h" only where neededVolker Lendecke1-0/+1
One dependency of includes.h less Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Apr 24 22:26:22 CEST 2018 on sn-devel-144
2017-12-05lib: Remove unused serverid.tdbVolker Lendecke1-7/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Dec 5 04:58:26 CET 2017 on sn-devel-144
2017-12-05lib: Use messaging_send_all instead of message_send_allVolker Lendecke1-1/+1
Just a global search&replace Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-12-05messaging: Remove the "n_sent" arg from message_send_allVolker Lendecke1-1/+1
The only user of this is an informative message in smbcontrol. I don't think that's worth the effort. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-04-19printing: handle "printcap cache time" change on HUPDavid Disseldorp1-33/+46
Reschedule the housekeeping event on SIGHUP and conf reload. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Apr 19 13:14:20 CEST 2016 on sn-devel-144
2016-04-19printing: use housekeeping period that matches cache timeDavid Disseldorp1-13/+8
The printcap housekeeping callback is scheduled to run every 60 seconds, and invokes pcap_cache_reload() to reload of the printcap cache *if* the "printcap cache time" period has expired. Given that pcap_cache_reload() invocation is the only job of the housekeeping callback, it makes much more sense to schedule it every "printcap cache time" seconds, rather than every 60 seconds. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-02-23lib: Remove sys_waitpidVolker Lendecke1-1/+1
We have waitpid in libreplace Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2015-09-24s3: Move call to prctl_set_comment to reinit_after_forkChristof Schmitt1-3/+1
This save a few lines of code. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2015-04-22s3:smbd: use smbd_reinit_after_forkRalph Boehme1-1/+1
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-08smbd: split printer reload processingDavid Disseldorp1-3/+97
All printer inventory updates are currently done via delete_and_reload_printers(), which handles registry.tdb updates for added or removed printers, AD printer unpublishing on removal, as well as share service creation and deletion. This change splits this functionality into two functions such that per-client smbd processes do not perform registry.tdb updates or printer unpublishing. This is now only performed by the process that performs the printcap cache update. This change is similar to ac6604868d1325dd4c872dc0f6ab056d10ebaecf from the 3.6 branch. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10652 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-08printing: return last change time with pcap_cache_loaded()David Disseldorp1-1/+1
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10652 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2014-02-18s3: printing: Fix problem with server taking too long to respond to a ↵Jeremy Allison1-0/+6
MSG_PRINTER_DRVUPGRADE message. Receiving a MSG_PRINTER_DRVUPGRADE causes smbd to iterate over all printers looking for ones that uses the driver. This is a very expensive operation requiring a read of all registry printer parameters. On a system with a large number of printers, this causes the clients to timeout (smbd can take longer than 60 seconds to respond). This patch fixes the problem by forwarding the MSG_PRINTER_DRVUPGRADE to the background lpq queue updater process and allowing it to take care of the updating of the changeid in the registry, allowing the smbd connected to the client to return to processing requests immediately. https://bugzilla.samba.org/show_bug.cgi?id=9942 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Feb 18 17:48:30 CET 2014 on sn-devel-104
2013-03-05s3-daemons: Set the comment field of the daemons.Andreas Schneider1-0/+3
PR_SET_NAME sets the comm field of a process. This way we can give processes a name and they are easier to identify. $ ps afx -o pid,comm 29447 smbd 29452 \_ epmd 29453 \_ lsasd-master 29455 | \_ lsasd-child 29457 | \_ lsasd-child 29459 | \_ lsasd-child 29461 | \_ lsasd-child 29463 | \_ lsasd-child 29454 \_ spoolssd-master 29456 \_ lpqd 29458 \_ spoolssd-child 29460 \_ spoolssd-child 29462 \_ spoolssd-child 29465 \_ spoolssd-child 29466 \_ spoolssd-child 29467 \_ spoolssd-child 29468 \_ spoolssd-child 29469 \_ spoolssd-child 29470 \_ spoolssd-child 29471 \_ spoolssd-child Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-02-19s3:printing: s/struct event_context/struct tevent_contextStefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2012-10-01s3fs-smbd: Move housekeeping to the background process.Andreas Schneider1-0/+9
If you add 200 printers using lpadmin. Then you wait for the printcap cache to expire. As soon as this expires we notify all deamons that they should reload the printers. This mean we need to create the default registry keys for each printer. If you do e.g. a 'smbclient -L' during that time you will get a lot of timeouts. This lets the housekeeping function of the printcap cache do the task of creating the default registry keys in background queue process. When it is done with the task it will tell all smbd childs to reload the printers and the 200 printers appear. Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Oct 1 20:28:23 CEST 2012 on sn-devel-104
2012-06-06s3:printing: use smbd/smbd.h instead of just smbd/proto.h in queue_process.cStefan Metzmacher1-1/+1
This fixes compiler warnings regarding incomplete types. metze
2012-03-24lib/util: Remove obsolete sys_getpid() and sys_fork().Jelmer Vernooij1-1/+1
The performance of these is minimal (these days) and they can return invalid results when used as part of applications that do not use sys_fork(). Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sat Mar 24 21:55:41 CET 2012 on sn-devel-104
2012-01-17s3:printing: avoid messaging_event_context() in print_queue_housekeeping()Stefan Metzmacher1-6/+21
metze
2011-12-13s3: Remove a call to procid_self()Volker Lendecke1-1/+1
2011-12-12s3: Remove a bunch of calls to procid_self()Volker Lendecke1-1/+1
All callers to messaging_[re]init only used procid_self()
2011-09-05s3-smbd: Rename reload_printers() and add documentation.Andreas Schneider1-2/+2
Autobuild-User: Andreas Schneider <asn@cryptomilk.org> Autobuild-Date: Mon Sep 5 17:59:47 CEST 2011 on sn-devel-104