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

46 Commits

Author SHA1 Message Date
Jeremy Allison
17bc0fab76 Revert "s3: smbd: Tear down global_smbXsrv_client in the correct order."
Wrong fix for the problem that was actually fixed in the dbwrap_rbt
code with commits:

590507951f
0f46da08e1

This reverts commit 8024e19b70.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Dec  7 21:09:04 CET 2015 on sn-devel-104
2015-12-07 21:09:04 +01:00
Jeremy Allison
8024e19b70 s3: smbd: Tear down global_smbXsrv_client in the correct order.
The talloc heirarchy looks like this:

global_smbXsrv_client
    |                 |
    V                 V
    session_table    sconn
       |
       V
      session (destructor references global_smbXsrv_client->sconn)

So don't free global_smbXsrv_client->sconn before the
session destructor fires.

------------------------------------------------
6 <signal handler called>
7 0x00007f47ba82da1a in file_close_user (sconn=0x0, vuid=1584077283) at ../source3/smbd/files.c:250
8 0x00007f47ba922a74 in smbXsrv_session_logoff (session=0x7f47be8bbf80) at ../source3/smbd/smbXsrv_session.c:1404
9 0x00007f47ba921912 in smbXsrv_session_destructor (session=0x7f47be8bbf80) at ../source3/smbd/smbXsrv_session.c:1068
10 0x00007f47b784e2fc in _talloc_free_internal () from /usr/lib/libtalloc.so.2
11 0x00007f47b784f495 in _talloc_free_children_internal () from /usr/lib/libtalloc.so.2
12 0x00007f47b784e49f in _talloc_free_internal () from /usr/lib/libtalloc.so.2
13 0x00007f47b784f495 in _talloc_free_children_internal () from /usr/lib/libtalloc.so.2
14 0x00007f47b784e49f in _talloc_free_internal () from /usr/lib/libtalloc.so.2
15 0x00007f47b784f88e in _talloc_free () from /usr/lib/libtalloc.so.2
16 0x00007f47ba92b2f1 in exit_server_common (how=SERVER_EXIT_NORMAL, reason=0x0) at ../source3/smbd/server_exit.c:234
------------------------------------------------

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11375

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Nov 25 03:40:46 CET 2015 on sn-devel-104
2015-11-25 03:40:46 +01:00
Volker Lendecke
c4267ce124 smbd: Remove dead code
94f0716fff has removed the dcelogin_atmost_once variable.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-11-12 22:39:07 +01:00
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
Ralph Boehme
b4a0864f64 s3:smbd: add wrapper around reinit_after_fork
smbd_reinit_after_fork is a simple wrapper around reinit_after_fork that
should be used after forking from the main smbd.

At the moment the only additional step it performs is resetting
am_parent to NULL.

A subsequent commit will make use of this function.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-04-22 23:00:20 +02:00
Volker Lendecke
74a16a1094 s3:smbprofile: Replace sysv shmem with tdb
What?

This patch gets rid of the central shared memory segment referenced by
"profile_p". Instead, every smbd gets a static profile_area where it collects
profiling data. Once a second, every smbd writes this profiling data into a
record of its own in a "smbprofile.tdb". smbstatus -P does a tdb_traverse on this
database and sums up what it finds.

Why?

At least in my perception sysv IPC has not the best reputation on earth. The
code before this patch uses shmat(). Samba ages ago has developed a good
abstraction of shared memory: It's called tdb.

The main reason why I started this is that I have a request to become
more flexible with profiling data. Samba should be able to collect data
per share or per user, something which is almost impossible to do with
a fixed structure. My idea is to for example install a profile area per
share and every second marshall this into one tdb record indexed by share
name. smbstatus -P would then also collect the data and either aggregate
them or put them into individual per-share statistics. This flexibility
in the data model is not really possible with one fixed structure.

But isn't it slow?

Well, I don't think so. I can't really prove it, but I do believe that on large
boxes atomically incrementing a shared memory value for every SMB does show up
due to NUMA effects. With this patch the hot code path is completely
process-local. Once a second every smbd writes into a central tdb, this of
course does atomic operations. But it's once a second, not on every SMB2 read.

There's two places where I would like to improve things: With the current code
all smbds wake up once a second. With 10,000 potentially idle smbds this will
become noticable. That's why the current only starts the timer when something has
changed.

The second place is the tdb traverse: Right now traverse is blocking in the
sense that when it has to switch hash chains it will block. With mutexes, this
means a syscall. I have a traverse light in mind that works as follows: It
assumes a locked hash chain and then walks the complete chain in one run
without unlocking in between. This way the caller can do nonblocking locks in
the first round and only do blocking locks in a second round. Also, a lot of
syscall overhead will vanish. This way smbstatus -P will have almost zero
impact on normal operations.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-03-06 12:31:10 +01:00
Stefan Metzmacher
185c6feab7 s3:smbprofile: track connect_count and disconnect_count
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-11-19 20:51:37 +01:00
Volker Lendecke
6d2c8f54e5 smbd: Fix a use-after-free
We can't reference xconn->next after it was talloc_free'ed

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Oct 10 14:32:53 CEST 2014 on sn-devel-104
2014-10-10 14:32:52 +02:00
Stefan Metzmacher
e23785ae37 s3:smbd: introduce 'struct smbXsrv_client' in order to prepare multi-channel support
This structure is supposed to hold the global state shared between
multiple connections from the same client.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:11 +02:00
Stefan Metzmacher
c5ab9557a9 s3:smbd: rename 'conn' to 'xconn' in exit_server_common()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:12 +02:00
Stefan Metzmacher
cd8105484c s3:smbd: move sconn->smb1.negprot.* to xconn->smb1.negprot.*
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
b05b4cab25 s3:smbd: move sconn->status to xconn->transport.status
This prepares the structures for multi-channel support.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-08-06 09:51:11 +02:00
Stefan Metzmacher
52ccb40d59 s3:smbd: maintain smbd_server_connection->status
If this isn't NT_STATUS_OK, we skip any io on the socket.

This avoids possible problems during shutdown.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-02-21 11:48:12 +01:00
Stefan Metzmacher
58c71bee40 s3:smbd: simplify exit_server_common()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-02-21 11:47:18 +01:00
Garming Sam
ca20ddbe91 param: rename lp function and variable from 'piddir' to 'pid_directory'
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-02-07 16:19:11 -08:00
Richard Sharpe
40d783c397 Call smb_panic when we try to exit the server uncleanly. This gives us the normal traceback and memory dump, but also runs the normal panic action.
Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Mar 27 22:58:37 CET 2013 on sn-devel-104
2013-03-27 22:58:36 +01:00
Stefan Metzmacher
8a1c7a0a66 s3:smbd: add exit_server to the smbd_shim hooks
This is in preparation of moving sessionid_tdb and conn_tdb
to smbd exclusively.

metze

Signed-off-by: Michael Adam <obnox@samba.org>
2012-10-19 12:14:58 +02:00
Jeremy Allison
e8dbf2889f Move everything to use the common pidfile functions.
The extra code in source3/lib/pidfile.c is no longer needed.
2012-07-19 16:36:18 -07:00
Jeremy Allison
0d24370c76 Make the s3 pidfile use the common code inside lib/util/pidfile.c 2012-07-19 16:08:49 -07:00
Jeremy Allison
2922fdaaf0 Move source4/smbd/pidfile into lib/util in preparation for making it in common. 2012-07-19 15:41:52 -07:00
Michael Adam
d693ff54db s3:smbd: use smbXsrv_session_logoff_all() and smb1srv_tcon_disconnect_all() in exit_server_common()
This removes the use of conn_close_all() and invalidate_all_vuids()

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
2012-06-25 20:55:06 +02:00
Stefan Metzmacher
9c80b91d8f s3:smbd: make conn_close_all() a void function
metze
2012-06-03 21:33:10 +02:00
Jeremy Allison
f6e41026f8 We are triggering the cleanup_timeout_fn() too often, on exiting when an smbd is idle.
Calls to exit_server_cleanly() should be treated as a "clean" shutdown,
and not trigger the master smbd to call cleanup_timeout_fn.
2012-05-31 12:35:04 -07:00
Stefan Metzmacher
6718747268 s3:smbd: use server_messaging_context() instead of sconn->msg_ctx in exit_server_common()
sconn is not available in the parent anymore.

Thanks to Volker Lendecke <vl@samba.org> for finding this!

metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Thu May 31 18:08:06 CEST 2012 on sn-devel-104
2012-05-31 18:08:05 +02:00
Stefan Metzmacher
b5e9ece1f3 s3:smbd: remove global 'smbd_server_conn' !!!
For now we still use a global 'global_smbXsrv_connection'
in order to pass the connection state to exit_server*().

metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Thu May 24 20:07:20 CEST 2012 on sn-devel-104
2012-05-24 20:07:20 +02:00
Stefan Metzmacher
704cf10645 s3:smbd: avoid using sconn_server_id()
metze
2011-12-16 13:19:32 +01:00
Christian Ambach
ad4a10dd05 s3:smb2 fix smbd crash on premature end of smb2 conn (Bug 8286)
when smbd tries to clean up locks after a premature end of a smb2
connection, lock_db has already been freed and so it crashes

this patch changes the order in which items are freed so that
lock_db is still around when it is needed

Jeremy, Metze, please check

Autobuild-User: Christian Ambach <ambi@samba.org>
Autobuild-Date: Mon Jul  4 20:00:26 CEST 2011 on sn-devel-104
2011-07-04 20:00:26 +02:00
Günther Deschner
0e76eddcc8 s3: include ntdomain.h before including generated srv_ headers.
Guenther
2011-05-02 15:03:44 +02:00
Günther Deschner
ab36d597e7 s3-messages: make ndr_messaging.h part of messages.h.
Guenther
2011-03-30 01:13:09 +02:00
Günther Deschner
8c24ebf371 s3: include smbd/smbd.h where needed.
Guenther
2011-03-30 01:13:08 +02:00
Andrew Tridgell
c8297073db s3-fault: removed the cont_fn from fault_setup()
cont_fn() was supposed to be a way to continue after a seg fault. It
could never be called however, as smb_panic() from fault_report()
could never return, as dump_core() never returns at the end of
smb_panic()

Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Tue Mar 22 05:07:58 CET 2011 on sn-devel-104
2011-03-22 05:07:58 +01:00
Günther Deschner
8643683dd8 s3-server_id: only include server_id where needed.
Guenther
2011-03-02 12:12:31 +01:00
Günther Deschner
8225c0ad6c s3-printing: only include printing where really needed.
Guenther
2011-02-22 21:52:18 +01:00
Günther Deschner
66e040ee0a s3-printing: isolate print notification prototypes better.
Guenther
2011-02-22 21:52:18 +01:00
Andreas Schneider
8925b03b59 s3-rpcecho: Only register rpcecho in the developer build.
Autobuild-User: Andreas Schneider <asn@samba.org>
Autobuild-Date: Tue Jan  4 18:56:38 CET 2011 on sn-devel-104
2011-01-04 18:56:38 +01:00
Andreas Schneider
d4f5bf0c36 s3-smbd: Call the rpc service shutdown functions. 2011-01-04 11:23:21 +01:00
Andrew Bartlett
cf310a4306 s3-smbd Remove manual override of DEBUGELVEL during exit
This code, originally added at the dawn of time (the import into CVS)
does not seem to be required any more, as all the DEBUG() statements
in the intermediate functions are at level 0.

Andrew Bartlett
2010-10-27 04:42:06 +00:00
Volker Lendecke
fb8686962a s3: Remove smbd_server_conn from files_forall 2010-09-28 07:36:16 +02:00
Simo Sorce
e60ed80754 s3-auth: Simplify how we free the auth_context
Turn the freeing function into a destructor and attach it to the
auth_context.
Make all callers TALLOC_FREE() the auth_context instead of calling
the free function.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2010-07-19 14:20:00 +10:00
Volker Lendecke
e6a089484b s3: Remove smbd_messaging_context() from exit_server_common() 2010-07-05 11:06:26 +02:00
Volker Lendecke
f1d6eed962 s3: Remove procid_self() from exit_server_common 2010-07-05 11:06:25 +02:00
Volker Lendecke
b01958b0bd s3: Remove serverid_[de]register_self
This removes some deep references to procid_self()
2010-07-04 16:41:14 +02:00
Volker Lendecke
f8e7077d5c s3: Don't attempt to deregister from serverid twice
The parent has to take care of crashed child processes anyway, so we don't have
to clean up in the child
2010-07-04 13:48:10 +02:00
Simo Sorce
5e576a53ab s3:lib make server contexts generic
Pair-programmed-with: Andreas Schneider <asn@samba.org>
2010-06-10 17:30:45 -04:00
Jeremy Allison
b5638a0560 Don't use the autofree context for the globals. This causes child smbd's forked
by modules to crash due to destructors being called (found when using the vfs_aio_fork
module with smb2).

Jeremy.
2010-06-10 13:17:35 -07:00
Andrew Bartlett
8bc32513da s3:smbd split smbd/server.c into smbd/server.c and smbd/server_exit.c
Andrew Bartlett

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2010-05-28 18:08:25 +02:00