summaryrefslogtreecommitdiffstats
path: root/source3/lib/unix_msg
Commit message (Collapse)AuthorAgeFilesLines
* lib: Move "iov_buf.[ch]" to lib/utilVolker Lendecke2015-02-241-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: remove cookie from unix_msg_initVolker Lendecke2015-02-135-12/+8
| | | | | | | | | | | | "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>
* unix_msg: Fix 80-line formattingVolker Lendecke2015-01-091-2/+4
| | | | | | | | This is pretty fresh code, so hope this change does not fall under the "no reformatting" rule yet Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Use msghdr_prep_recv_fds in unix_msgVolker Lendecke2015-01-061-7/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: Use msghdr_extract_fds in unix_msgVolker Lendecke2015-01-061-56/+19
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: Use msghdr in unix_msgVolker Lendecke2015-01-062-121/+60
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: unix_dgram_msg does not need "num_fds"Volker Lendecke2015-01-061-2/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: Use iov_buf in unix_msgVolker Lendecke2014-12-092-24/+3
| | | | | | | Now that iov_buf does not pull in talloc we can use it Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Fix unix_msg_test_drainVolker Lendecke2014-12-041-0/+7
| | | | | | | | | | | | poll_funcs_init_tevent does not register a tevent context by default. This used to be the case in an early development stage, but apparently I haven't tested this for a while :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Thu Dec 4 18:55:08 CET 2014 on sn-devel-104
* lib: Fix header include protection #defineVolker Lendecke2014-11-251-2/+2
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Tue Nov 25 15:38:22 CET 2014 on sn-devel-104
* messaging3: Fix sending large messages on FreeBSDVolker Lendecke2014-11-241-0/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Reformat unix_dgram_send a bitVolker Lendecke2014-11-241-1/+3
| | | | | | | This makes the next commit a bit more readable Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: lib, s3: modules: Fix compilation on Solaris.Jeremy Allison2014-10-061-9/+10
| | | | | | | | | | | | | | | | Based on work from YOUZHONG YANG <youzhong@gmail.com>. Code needs fixing when HAVE_STRUCT_MSGHDR_MSG_CONTROL is not defined. Also Solaris doesn't have msg_flags field (which we set to zero anyway, so if we initialize the entire struct to zero, we never need to refer to it). https://bugzilla.samba.org/show_bug.cgi?id=10849 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): Mon Oct 6 12:33:36 CEST 2014 on sn-devel-104
* s3:unix_msg: document closing of fds in the receive handlerMichael Adam2014-09-301-0/+7
| | | | | | | Pair-Programmed-With: Volker Lendecke <vl@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org>
* s3:unix_msg: close the fds in unix_dgram_recv_handler() after the callback ↵Michael Adam2014-09-301-0/+6
| | | | | | | | | | | has run If the caller wants to use passed fds, he should copy them away and set them to -1. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:unix_msg: don't fill cmsg buffer in unix_dgram_send_job()Michael Adam2014-09-301-66/+61
| | | | | | | | | | | | | | | | Do this in queue_msg, instead. This renders unix_dgram_send_job() as simple as it was before we introduced fd-passing -- as it is intended. This also changes struct unix_dgram_msg to not contain the fd-array, but the correspondingly filled msghdr and cmsg buf. Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:unix_msg: add close_fd_array_cmsg()Michael Adam2014-09-301-0/+13
| | | | | | | | Variant of close_fd_array() operating on fd_array inside msghdr. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:unix_msg: factor extract_fd_array_from_msghdr() out of ↵Michael Adam2014-09-301-19/+27
| | | | | | | | | | unix_dgram_recv_handler() For re-use. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:unix_msg: simplify queue_msg() by moving space calculations up.Michael Adam2014-09-301-19/+17
| | | | | | | | | | | | This allows for early direct return instead of the goto invalid, since the fds_copy array is filled later. Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:unix_msg: use an iov in unix_dgram_msg/queue_msg instead of buffer and lengthMichael Adam2014-09-301-10/+12
| | | | | | | | | | | | This is equivalent, reads more easily and makes extraction more obvious. Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:unix_msg: rename a variable buflen->data_len in queue_msg()Michael Adam2014-09-301-6/+6
| | | | | | | | | Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:unix_msg: use a buffer pointer instead of array indexes for the iov bufferMichael Adam2014-09-301-4/+7
| | | | | | | | | | | This is more obvious to read and a preparation for following commits. Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:unix_msg: remember errno in unix_dgram_send_job in case of send error.Michael Adam2014-09-301-0/+4
| | | | | | | | | Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:unix_msg: don't close the fd-array at the end of unix_dgram_send_job()Michael Adam2014-09-301-2/+0
| | | | | | | | | | | | These pthread-pool-jobs should be minimal and ideally only do one syscall. The closing of the fds is done in unix_dgram_job_finished(). Pair-Programmed-With: Volker Lendecke <vl@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:unix_msg: add "close_fds" exit point to unix_msg_recv()Michael Adam2014-09-301-10/+10
| | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:unix_msg: fix a tab<->space mixup in unix_msg_recv()Michael Adam2014-09-271-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:unix_msg: add fds-array to unix_msg_send() for fd passingMichael Adam2014-09-244-13/+38
| | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org>
* s3:unix_msg: pass the fd array to the unix_msg recv_callback functionStefan Metzmacher2014-09-244-5/+14
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:unix_msg: add fds-array to unix_dgram_send() for fd-passingMichael Adam2014-09-241-12/+161
| | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org>
* s3:unix_msg: pass the fd array to the unix_dgram recv_callback functionStefan Metzmacher2014-09-241-7/+13
| | | | | | | | For now unix_msg_recv() will just close the fds, but they will be passed to the unix_msg recv_callback in the next commits. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:unix_msg: read fds from recvmsg in unix_dgram_recv_handler()Michael Adam2014-09-241-3/+52
| | | | | | | | | For now we directly close the fds, the next commits will pass them to the recv_callback 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>
* s3:unix_msg: add close_fd_array()Stefan Metzmacher2014-09-241-0/+14
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:unix_msg: use sendmsg() in unix_dgram_send_job()Stefan Metzmacher2014-09-241-3/+11
| | | | | | | This prepares fd-passing. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* Remove a few #ifdef EWOULDBLOCkVolker Lendecke2014-09-181-6/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* unix_msg: simplify unix_msg_sendVolker Lendecke2014-07-281-12/+5
| | | | | | | | We have a variable array inside one-fragment fast path anyway. Moving that to the toplevel of the function saves us a malloc/free pair. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Use struct initializersVolker Lendecke2014-07-281-32/+32
| | | | | | | Saves a few lines and bytes of .text Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Use empty arrays in structsVolker Lendecke2014-07-281-3/+3
| | | | | | | Just a simple style update Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Lift sockaddr_un handling from unix_msg_sendVolker Lendecke2014-06-184-21/+16
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Lift sockaddr_un handling from unix_msg_initVolker Lendecke2014-06-184-35/+30
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Lift sockaddr_un handling from unix_dgram_sendVolker Lendecke2014-06-181-19/+17
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Lift sockaddr_un handling from unix_dgram_send_queue_initVolker Lendecke2014-06-181-13/+7
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* unix_msg: Lift sockaddr_un handling from unix_dgram_initVolker Lendecke2014-06-181-16/+23
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:messaging: protect use of msg_control with HAVE_STRUCT_MSGHDR_MSG_CONTROLMichael Adam2014-06-031-0/+4
| | | | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Tue Jun 3 01:14:17 CEST 2014 on sn-devel-104
* s3:messaging: change unix_dgram_recv_handler() to use recvmsg, not recvMichael Adam2014-05-301-1/+15
| | | | | | | | | | This is in preparation of adding fd-passing to messaging. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri May 30 02:28:15 CEST 2014 on sn-devel-104
* unix_msg: Simplify unix_msg_send a bitVolker Lendecke2014-05-241-3/+2
| | | | | | | | | | Now that we settled on variable arrays, remove a fixed one 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): Sat May 24 02:56:31 CEST 2014 on sn-devel-104
* lib: Enhance poll_funcs_tevent for multiple tevent_contextsVolker Lendecke2014-05-083-12/+38
| | | | | | | | | | | | | | | | | | With this patch it will be possible to use nested event contexts with messaging_filtered_read_send/recv. Before this patchset only the one and only event context a messaging_context is initialized with is able to receive datagrams from the unix domain socket. So if you want to code a synchronous RPC-like operation using a nested event context, you will not see the reply, because the nested event context does not have the required tevent_fd's. Unfortunately, this patchset has to add some advanced array voodoo. The idea is that state->watches[] contains what we hand out with watch_new, and state->contexts contains references to the tevent_contexts. For every watch we need a tevent_fd in every event context, and the routines make sure that the arrays are properly maintained. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Add unix_msgVolker Lendecke2014-04-236-0/+1357
This is a messaging layer based on unix domain datagram sockets. Sending to an idle socket is just one single nonblocking sendmsg call. If the recv queue is full, we start a background thread to do a blocking call. The source4 based imessaging uses a polling fallback. In a situation where thousands of senders beat one single blocked socket, this will generate load on the system due to the constant polling. This does not happen with a threaded blocking send call. The threaded approach has another advantage: We save become_root() calls on the retries. The access checks are done when the blocking socket is connected, the threaded blocking send call does not check permissions anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>