1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

75 Commits

Author SHA1 Message Date
Christof Schmitt
96c48b3c06 s3: Move call to prctl_set_comment to reinit_after_fork
This save a few lines of code.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-09-24 08:00:16 +02:00
Günther Deschner
4234cbb694 s3-rpc_server: Fix inteface typo.
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Jun  4 03:51:29 CEST 2015 on sn-devel-104
2015-06-04 03:51:29 +02:00
Ralph Boehme
9e7cf87a30 s3:smbd: use smbd_reinit_after_fork
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-04-22 23:00:20 +02:00
Michael Adam
2f889f7951 s3:spoolss: use lp_load() wrapper lp_load_global().
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Ira Cooper <ira@samba.org>
2015-04-22 13:57:29 +02:00
David Disseldorp
30ce835670 printing: return last change time with pcap_cache_loaded()
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-08 14:10:39 +02:00
David Disseldorp
4f4501ac1f printing: only reload printer shares on client enum
Currently, automatic printer share updates are handled in the following
way:
- Background printer process (BPP) forked on startup
- Parent smbd and per-client children await MSG_PRINTER_PCAP messages
- BPP periodically polls the printing backend for printcap data
	- printcap data written to printer_list.tdb
	- MSG_PRINTER_PCAP sent to all smbd processes following update
- smbd processes all read the latest printer_list.tdb data, and update
  their share listings

This procedure is not scalable, as all smbd processes hit
printer_list.tdb in parallel, resulting in a large spike in CPU usage.

This change sees smbd processes only update their printer share lists
only when a client asks for this information, e.g. via NetShareEnum or
EnumPrinters.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10652

Suggested-by: Volker Lendecke <vl@samba.org>
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-08 14:10:38 +02:00
Andreas Schneider
562ade624a s3-spoolssd: Don't register spoolssd if epmd is not running.
https://bugzilla.samba.org/show_bug.cgi?id=10474

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-02-27 16:47:47 +01:00
Volker Lendecke
a93aaec77e spoolssd: Use only one messaging_context per process
After the fork, the code created a fresh messaging_context before doing the
reinit_after_fork. This means to have two initialized messaging contexts in
that process. This patch aligns spoolssd with lsad.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-02-19 16:38:30 -08:00
Christian Ambach
805515b83f s3:printing fix a compiler warning
about a potentially uninitialized variable

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-12-12 14:21:27 -08:00
Andrew Bartlett
cdc062273c spoolssd: Cast getpid() result to unsigned int for GNU/Solaris build
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-15 10:38:50 -07:00
Andreas Schneider
f06a0352e5 s3-daemons: Set the comment field of the daemons.
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-03-05 23:29:48 +01:00
Volker Lendecke
9a2db48e7e s3: Remove some calls to procid_self
The goal is to have procid_self handling completely in the messaging_context.

Signed-off-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Oct 19 20:39:56 CEST 2012 on sn-devel-104
2012-10-19 20:39:56 +02:00
Rusty Russell
fe72740e82 loadparm: make the source3/ lp_ functions take an explicit TALLOC_CTX *.
They use talloc_tos() internally: hoist that up to the callers, some
of whom don't want to us talloc_tos().

A simple patch, but hits a lot of files.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-07-18 15:07:23 +09:30
Jelmer Vernooij
c0288e0612 lib/util: Remove obsolete sys_getpid() and sys_fork().
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-03-24 21:55:40 +01:00
Andrew Bartlett
b07d504ca4 change low FDs are handled in Samba
We now only close fds 0, 1, 2 when we are a forked daemon, and take
care not to close a file descriptor that we might need for foreground
stdin monitoring.

This should fix stdout logging in the lsa and epmapper deamons (ie in
make test).

Andrew Bartlett
2012-03-04 10:14:34 +01:00
Stefan Metzmacher
16bd41b7e7 s3:printing/spoolssd: avoid using server_messaging_context()
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Fri Dec 16 16:29:41 CET 2011 on sn-devel-104
2011-12-16 16:29:41 +01:00
Stefan Metzmacher
5061dd26d3 s3:printing/spoolssd: pass event and messaging context to check_updater_child()
metze
2011-12-15 11:08:52 +01:00
Volker Lendecke
0f9d14820e s3: Remove a bunch of calls to procid_self()
All callers to messaging_[re]init only used procid_self()
2011-12-12 21:50:25 +01:00
Andreas Schneider
3e8c665465 s3-smbd: Rename reload_printers() and add documentation.
Autobuild-User: Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date: Mon Sep  5 17:59:47 CEST 2011 on sn-devel-104
2011-09-05 17:59:47 +02:00
Andreas Schneider
ad37341949 s3-spoolssd: Remove stale printers only on a valid pcap update.
load_printers() removes stale printers and we should only remove them if
we have a CUPS connection and talked to cups. Else we will remove every
configured printer if cups is not available.

Autobuild-User: Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date: Mon Sep  5 11:18:23 CEST 2011 on sn-devel-104
2011-09-05 11:18:23 +02:00
Simo Sorce
a4188aaf7b s3-spoolss: Remove useless check
If we *really* are a bout to exit (PF_WORKER_EXITING) then the event will not
be called as the loop will exit. Otherwise PF_SRV_MSG_EXIT may not  be honoured
for a long time if we have cients connected, therefore keep handling SIGHUP
properly in those cases.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:06 -04:00
Simo Sorce
feadd849ba s3-spoolssd: Listen on parent messages
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:06 -04:00
Simo Sorce
72746498a4 s3-spoolssd: Send a message to the parent when we accept a connection
Every time we accept a connection wanr the parent, so it can run management
routines and reallocate more resources if necessary.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:06 -04:00
Simo Sorce
f07f5c5100 s3-spoolssd: User new prefork helpers to simplify code.
Also stop using the listening as now the prefork code properly sets
the PF_WORKER_ACCEPTING flag and it can be relied upon without having to keep
additional status around.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:05 -04:00
Simo Sorce
e3736f826b s3-prefork: Fix worker flags handling.
We can't have a clear idea of wether the worker is IDLE or BUSY.
The only things we can tell is if it is Alive, whether it is currently
Accepting connections or wether it is Exiting soon.

Remove PF_WORKER_IDLE, PF_WORKER_BUSY and replace their use with
PF_WORKER_ALIVE. Also properly assign PF_WORKER_ACCEPTING so that
users of the API can rely on the flag.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:05 -04:00
Simo Sorce
ee0c69a25e s3-prefork: do not use a lock_fd, just race on accept()
We used a lock mimicking what apache does for preforked children.
But it doesn't work properly in our case because we do not stop once a request
has been served. Clients are allowed to perform multiple requests and keep the
connection open.
This means that if we allow multiple clients per children, then a child could
take the lock and then be asked to do a long or even locking operation by a
client it already is serving. This woulkd cause the whole server to deadlock,
as the child is now busy and also holding on the lock.
Using a race on accept() by having a tevent_fd on the listening socket wait
for read events we never deadlock. At most we cause a bit of contention among
children. But in the generic case connections are much less frequent for us as
clients tend to be long lived. So the little contention we may have is not a
big deal.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:05 -04:00
Simo Sorce
884969ed97 s3-spoolssd: Use prefrok utils to manage children
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:04 -04:00
Simo Sorce
0647a93c64 s3-spoolss: Introduce helper function to manage pool.
We were not properly managing allowed clients and pool management was
duplicated across a few callers.
Concentrate all management heuristics in one single function.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:04 -04:00
Simo Sorce
bfd9624818 s3-spoolssd: Fix spoolss logging.
Use the same code as in lsasd.

Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:04 -04:00
Andreas Schneider
dea21619a2 s3-spoolssd: Check if we were able to create the prefork pool.
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Simo Sorce <idra@samba.org>
2011-08-21 09:05:02 -04:00
Simo Sorce
d52343a967 s3-messaging: Do not register to classes we are not going to use.
Signed-off-by: Andreas Schneider <asn@samba.org>

Autobuild-User: Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date: Thu Aug 11 17:09:30 CEST 2011 on sn-devel-104
2011-08-11 17:09:30 +02:00
Simo Sorce
cb1af61cb1 s3-messaging: Remove obsolete class.
The FLAG_MSG_PRINT_NOTIFY class is actually obsolete and never used, as the
only message belonging to it is not used either.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-11 14:57:55 +02:00
Andreas Schneider
9eafbebf9c s3-spoolss: Fix prototypes warnings.
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:06 +02:00
Simo Sorce
54aaa5a58c s3-spoolss: do not call pcap_cache_reload() directly
The background queue process is repsonsible for that.
Just reload printers if necessary or wait for a message from bq to do that.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
befc539273 s3-spoolss: Fix printers related messaging
Children were not properly receiving messages to reload printers when
the background queue process was dispatching them.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
7a07162558 s3-prefork: Fix use of child id.
Children Ids must start at 1 as 0 represent the father.
Also fix callbacks that restart logs to use a procedd global variable that
holds the Id so that they work correctly both fot the parent process and the
children.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
f00681fe9a s3-printing: make sure to block SIGHUP ...
... until we are ready to handle it.

Also make us ready as early as possible in spoolssd.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
6f682be2ae s3-spoolss: Use a global variable for the pool
This allows for setting up signal handlers earlier which is needed
for the following patch. It also simplify the code in a few places.
After all we never have more than pool active at any time during
spoolssd life span.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
b2f682a8e6 s3-printing: Allow bq process to have own logfile
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
339c106e51 s3-spoolssd: Use the child_id to open log files
This way each child has its own log file and avoid mixing all logs form all
children in the same parent log file.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
fa893e815b s3-prefork: Pass the child a child_id
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:05 +02:00
Simo Sorce
227551a07b s3-prefork: Return tsocket_address for client and server
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
2b33b438ba s3-prefork: Pass messaging context around too
Pair-Programmed-With: Andreas Schneider <asn@samba.org>

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
1155280a48 s3-prefork: Set up a SIGCHLD handler by default
We need to properly handle preforked children so it is better to just do that
automatically.

If the parent needs/wants to intercept SIGCHLD events it can set a callback
that will be called by the prefork code once the internal cleanup function that
checks all prefork children has been executed.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
d36a8dc896 s3:spoolssd Start spoolssd from printing_subsystem_init
Use a child for the background updater process
Forward printer update messages from spoolss to background update process.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
9ce6416673 s3-printing: Rework how the background process is started
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
0a910c9347 s3-prefork: Provide a cleanup function
This way the parent doesn't need to know how to handle dead children and
keeps all of that within the prefork abstraction.

Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
f6ae58f242 s3-prefork: add support for multiple listning file descriptors
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
afde4d8d83 s3-spoolssd: propagate SIGHUP to children
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:04 +02:00
Simo Sorce
de08cd99b2 s3-spoolssd: expand children pool when necessary
Signed-off-by: Andreas Schneider <asn@samba.org>
2011-08-10 18:14:03 +02:00