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

83 Commits

Author SHA1 Message Date
Ralph Boehme
dfb712a03c s3:messages: check tevent_fd_get_flags() == 0 before using stale event context pointer
If the event context got deleted, tevent_fd_get_flags() will return 0
for the stale fde.  In that case we should not use fde_ev->ev anymore.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2018-04-24 11:13:17 +02:00
Volker Lendecke
05647d4723 messaging_dgm: Use messaging_dgm_forall in dgm_wipe
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-12-05 00:56:12 +01:00
Volker Lendecke
6b5b999d2f messaging: Add messaging_dgm_forall
This factors out the traversal function from _wipe. It will be used to
replace message_send_all soon.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-12-05 00:56:12 +01:00
Volker Lendecke
2dac8eb277 messaging_dgm: Protect against fork without reinit
In the wake of bug 13150 we've discussed that this could happen even
without clustering. This adds code to make sure that whenever messaging
is used the pid and the files used match.

It's pretty heavy-weight, thus I made it DEVELOPER only. My gut feeling
is that the getsockname is cheap, but the stat call might be a bit too
expensive.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-12-05 00:56:12 +01:00
Volker Lendecke
d1c96dc0ac messaging: Avoid a socket leak after fork
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13006

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): Tue Sep  5 19:12:34 CEST 2017 on sn-devel-144
2017-09-05 19:12:34 +02:00
Volker Lendecke
d7ccf0d977 messaging: Fix queueing on FreeBSD
FreeBSD does not do the nice blocking send that Linux does. Instead,
it returns ENOBUFS if the dst socket is full. According to the
manpage you have to do polling. Try with exponential backoff, at
the end try once a second forever.

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 Jun 20 23:03:11 CEST 2017 on sn-devel-144
2017-06-20 23:03:11 +02:00
Volker Lendecke
ccd4f81488 lib: Remove use of MSG_NOSIGNAL
According to susv4 sendmsg, NOSIGAL is effective for stream-oriented sockets.
Datagram sockets won't send SIGPIPE anyway. Looking at Linux kernel sources,
this is only looked at in stream functions. I guess this is a left-over from my
tmsgd attempts, which was based on stream sockets. messaging_dgm still only
uses datagram sockets, so MSG_NOSIGNAL is not needed here.

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

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue May 30 16:39:12 CEST 2017 on sn-devel-144
2017-05-30 16:39:12 +02:00
Andrew Bartlett
34b0ee8328 messaging_dgm: avoid GCC snprintf warnings in messaging_dgm_out_create
We are trying to put something that (in theory) could be 109 bytes
long, into the sockaddr_un.sun_path field which has a fixed size of
108 bytes. The "in theory" part is that one of the components is a
pid, which although stored as 32 bits is in practice 16 bits, so the
maximum size is not actually hit.

This is all very annoying, because the length is checked anyway and
all this achieves is silencing a warning.

Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Feb 10 09:05:31 CET 2017 on sn-devel-144
2017-02-10 09:05:31 +01:00
Volker Lendecke
1ecea454e5 messaging: Fix CID 1373622 Extra high-order bits
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-14 21:45:08 +02:00
Jeremy Allison
d02909f3e0 s3: lib: messaging. Add function comments I needed to understand this code.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Oct  6 02:29:41 CEST 2016 on sn-devel-144
2016-10-06 02:29:41 +02:00
Volker Lendecke
d05dfe3807 messaging: Add an indirection for messaging_dgm_register_tevent_context
Only one tevent_fd is possible for every file descriptor.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-10-05 11:47:17 +02:00
Volker Lendecke
34292d0b4b messages_dgm: Avoid an unnecessary declaration
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-10-05 11:47:17 +02:00
Volker Lendecke
4ce599dcd2 messaging: Avoid a default tevent_fd
Instead, rely on messaging_dgm_ref to always request a tevent_handle.

Signed-off-by: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-05 00:06:23 +02:00
Volker Lendecke
6c21d9977f messaging: Disable the correct fde on error
We might be called from different event contexts and thus
via different fde's

Signed-off-by: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-05 00:06:23 +02:00
Volker Lendecke
7099ba8770 messaging: Make messaging_dgm_register_tevent_context return a tevent_fd
Signed-off-by: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-05 00:06:23 +02:00
Volker Lendecke
fc0b35b41c messages_dgm: Pass receiving "ev" to recv_cb
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-05 00:06:22 +02:00
Volker Lendecke
88cdb233d3 messages_dgm: Pass down event_ctx one level
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-05 00:06:22 +02:00
Volker Lendecke
56de9c53fb messages_dgm: Drop a segment if we can't ship it for 60 seconds
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-05 00:06:22 +02:00
Volker Lendecke
40bbf9494f messages_dgm: Convert to pthreadpool_tevent
This itself adds a lot of code, however it removes the unix_msg library.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-10-05 00:06:22 +02:00
Volker Lendecke
bad738cbc4 messaging_dgm: Fix signed/unsigned hickups
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 Aug 23 10:46:17 CEST 2016 on sn-devel-144
2016-08-23 10:46:17 +02:00
Volker Lendecke
a2086e9973 lib: Cleanup includes in messages_dgm
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Aug 20 09:41:33 CEST 2016 on sn-devel-144
2016-08-20 09:41:33 +02:00
Volker Lendecke
f1c49d7656 messaging: Fix creating the dgm lockfile
There might be situations where the lock directory moves to a
location where a previous installation left the datagram sockets
(Yes, I just came across this). We can't really deal with it except
by just removing the socket without properly checking.

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

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Oct 22 02:14:29 CEST 2015 on sn-devel-104
2015-10-22 02:14:29 +02:00
Volker Lendecke
01d7e26f7f lib: Push down unique generation one level
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2015-10-19 12:09:10 +02:00
Volker Lendecke
37f01c869d messages_dgm: Add messaging_dgm_get_unique
To be able to read, we need to open the lockfile O_RDWR instead of O_WRONLY

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-09-30 23:51:13 +02:00
Volker Lendecke
edd18f7a1d messages_dgm: Fix an incorrect cast
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Sep 30 17:36:32 CEST 2015 on sn-devel-104
2015-09-30 17:36:32 +02:00
Volker Lendecke
cfca46a565 messages_dgm: No includes.h necessary
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2015-09-30 14:35:20 +02:00
Volker Lendecke
69f9ff7d82 unix_msg: remove cookie from unix_msg_init
"pid" and "sock" are sufficient I guess as randomizers to distinguish messages.
In theory, a pid could be recycled very quickly, which might mix up in-flight
messages. But once a few messages have passed, "cookie" would be incremented as
another indicator of a fresh message.

Why? Remove messages_dgm dependency on samba-util

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-02-13 23:32:06 +01:00
Volker Lendecke
a3efb70c87 messages_dgm: Move directory handling up
When we want to use messages_dgm in source4, we need to find better
places for the lock and socket directories. Source4 does not have the
concept of a cache directory. So I chose "private dir"/sock and "lock
dir"/msg as subdirectories.

This moves directory creation from messages_dgm.c to messages.c,
source4/lib/messaging will have its own way of doing this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-02-13 23:32:06 +01:00
Volker Lendecke
293a602b33 messages_dgm: Only pass "unique" to messaging_dgm_init
We have only one context per pid, so messaging_dgm_init can do getpid()
itself.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-02-13 23:32:06 +01:00
Michael Adam
00d9ee04dd s3:messaging: allow the messaging receive callback to change the fds
This allows the callback to consume the fds and e.g. set
them to -1 so that the caller can then treat (close) only those
fds that have not been consumed.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-30 16:36:10 +02:00
Michael Adam
1667839192 s3:messaging: add fds-array to message-backend send function
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:12 +02:00
Stefan Metzmacher
64d140197e s3:messaging: make it possible to receive a fd array from another process
In order to receive the fd array the caller needs to use
messaging_filtered_read_send/recv(). For all higher level
methods we silently close/ignore the fd array.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Michael Adam
1b35d2ed63 s3:unix_msg: add fds-array to unix_msg_send() for fd passing
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Stefan Metzmacher
c689547c93 s3:unix_msg: pass the fd array to the unix_msg recv_callback function
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-24 08:44:11 +02:00
Volker Lendecke
7bc2e2d0d4 messaging_dgm: Don't expose the messaging_dgm_context
Right now we can only support one messaging_dgm_context per process
anyway, the code has checks for this. I would like to keep it that
way, in the future we will have multiple messaging_context's or
imessaging_context's filtering based upon the dst server_id.

Why this change? messaging_dgm's lockfile contains the
serverid->unique_id. When designing messaging_dgm, I had in mind to
remove the serverid.tdb and replace it with the dgm lockfiles for server
lookup and enumeration. I have a WIP-patchset that gets rid of almost
all users of serverid.tdb. The problem is serverid_exists. Here we don't
have a messaging_context available, and it would be pretty intrusive
to make it so. This problem has plagued us since ctdb was developed,
see for example the comment

/*
 * This is a Samba3 hack/optimization. Routines like process_exists need to
 * talk to ctdbd, and they don't get handed a messaging context.
 */

in messaging_ctdb.c. This patchset removes this problem in a radical way:
Treat the messaging_dgm context as one globally available structure and
be done with it. The ctdb socket could go the same way in the future.

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): Sun Sep 14 16:29:30 CEST 2014 on sn-devel-104
2014-09-14 16:29:30 +02:00
Volker Lendecke
9269a8e5d4 messaging_dgm: Avoid a talloc
Not really required, but it removes a NULL check

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-09-14 14:04:06 +02:00
Volker Lendecke
55a894c71d messaging_dgm: Avoid a talloc
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-09-14 14:04:06 +02:00
Volker Lendecke
c95d9a55d1 messaging_dgm: messaging_dgm_lockfile_remove does not use tmp_ctx anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-09-14 14:04:06 +02:00
Volker Lendecke
9c5b1eeaf6 messaging_dgm: messaging_dgm_lockfile_create does not use tmp_ctx anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-09-14 14:04:06 +02:00
Volker Lendecke
c3f98b9789 messaging_dgm: Avoid talloc_tos()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-09-14 14:04:06 +02:00
Volker Lendecke
2858c666b5 messaging_dgm: Reformatting
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-09-14 14:04:06 +02:00
Volker Lendecke
188120b08c messaging_dgm: Remove an unnecessary cast
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-09-14 14:04:06 +02:00
Volker Lendecke
8d96a280f6 messaging_dgm: Factor out messaging_dgm_lockfile_name
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): Fri Aug 22 05:20:43 CEST 2014 on sn-devel-104
2014-08-22 05:20:43 +02:00
Volker Lendecke
8deb851200 messaging_dgm: Use %ju to fill lockfile
... much nicer than PRIu64

Also, append a \n. Makes it better readable when looking at the lockfile

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-22 02:53:52 +02:00
Volker Lendecke
12c781b9bf messaging3: Don't print a message if there's nothing to clean up
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ronnie sahlberg <ronniesahlberg@gmail.com>
2014-08-21 12:35:11 +02:00
Volker Lendecke
121d3ddce6 messaging3: Move messaging_hdr handling to messages.c.
This makes messages_dgm a simple byte-transport across processes that
knows almost nothing about server_id etc.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-11 23:57:13 +02:00
Volker Lendecke
bff27ee783 messaging3: Only store the pid in messaging_dgm_context
That's all we need here

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-11 23:57:13 +02:00
Volker Lendecke
6e6342055a messaging3: Save 48 bytes .text 2014-08-11 23:57:13 +02:00
Volker Lendecke
d22bb34b73 messaging3: Protect messaging_dgm against multiple contexts
We can't rely on posix locking within a process

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-11 23:57:13 +02:00
Volker Lendecke
a1529c3302 messaging3: Add messages_dgm.h
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-11 23:57:13 +02:00