summaryrefslogtreecommitdiffstats
path: root/source3/lib/messages.c
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>
* messaging4: Use messages_dgmVolker Lendecke2015-02-131-1/+1
| | | | | | | | | | | | | This replaces the transport mechanism in source4 with calls to the messages_dgm code. It is supposed to enable "smbcontrol samba pool-usage" as an example without having to rewrite smbcontrol using the source4 based messaging subsystem. This moves the source3 based names.tdb (which is unused so far) to the lock directory, source4 does not have a cache directory. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* messaging3: Use message_hdr_[put|get]Volker Lendecke2015-02-131-32/+16
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* messaging3: Use messaging_dgm_refVolker Lendecke2015-02-131-11/+15
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* messages_dgm: Move directory handling upVolker Lendecke2015-02-131-2/+36
| | | | | | | | | | | | | 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>
* messages_dgm: Only pass "unique" to messaging_dgm_initVolker Lendecke2015-02-131-2/+2
| | | | | | | | 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>
* lib: Use talloc_memdup in messaging_rec_dupVolker Lendecke2014-12-281-2/+1
| | | | | | | | 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): Sun Dec 28 04:20:48 CET 2014 on sn-devel-104
* messaging3: Add messaging_handler_send/recvVolker Lendecke2014-12-161-0/+81
| | | | | | | | | This repeatedly listens on msg_type. It's similar to messaging_register with talloc based autocleanup. The handler is free to talloc_move a way the record for later use. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add messaging_send_iov_fromVolker Lendecke2014-12-161-10/+20
| | | | | | | In the notifyd code it will be very helpful to fake source server_ids Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add messaging_names_dbVolker Lendecke2014-12-161-0/+19
| | | | | | | | This will enable messaging3 users to more easily register themselves under a name Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Avoid self-send complexityVolker Lendecke2014-12-091-110/+3
| | | | | | | | | | | | | | | | | With the notify code I've hit another case where self-sends caused a problem. This time messages were lost because we tried to do multiple dispatch_rec calls from within a single inotify callback. Only the first one was being taken care of, the others did not find receivers. This patch makes self-sends go through the kernel as well, the kernel queues everything nicely for us. With dgram messaging this should be pretty fast. If it turns out to be a performance problem, we can solve it later by doing proper queueing in user space. We need to completely decouple any processing from callbacks. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Split out iov_buf[len]Volker Lendecke2014-12-071-0/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Fix running down a messaging_contextVolker Lendecke2014-10-241-0/+16
| | | | | | | | | | | | When you do a talloc_free(msg_ctx), existing waiters can't and don't have to clean up behind themselves properly anymore. The msg_ctx the cleanup function refers to is just gone. 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 Oct 24 04:01:32 CEST 2014 on sn-devel-104
* s3:messaging: upon receiving fds, dup them so the caller can safely close them.Michael Adam2014-09-301-0/+5
| | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:messaging: allow the messaging receive callback to change the fdsMichael Adam2014-09-301-1/+1
| | | | | | | | | | 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>
* s3:messaging: msg_type int->uint32_t in struct messaging_hdrMichael Adam2014-09-301-1/+1
| | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:messaging: fix uninitialized data introduced by paddingMichael Adam2014-09-301-0/+1
| | | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:messaging: add fds-array to messaging_send_iov()Michael Adam2014-09-241-3/+16
| | | | | | 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:messaging: add fds-array to message-backend send functionMichael Adam2014-09-241-1/+2
| | | | | | 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:messaging: make it possible to receive a fd array from another processStefan Metzmacher2014-09-241-5/+72
| | | | | | | | | 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>
* s3:messaging: use struct initializers for 'struct messaging_rec'Stefan Metzmacher2014-09-241-5/+8
| | | | | | | | This makes sure new struct members will always be initialized, without explicitly finding all users. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* messaging_dgm: Don't expose the messaging_dgm_contextVolker Lendecke2014-09-141-15/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* messaging3: Avoid messaging_is_self_sendVolker Lendecke2014-08-231-9/+6
| | | | | | | | | | | This was a bad API, and it was used in a buggy way: In messaging_dispatch_rec we always did the defer, we referenced the destination pid, not the source. In messaging_send_iov this is the right thing to do to reference the destination, but when we have arrived in messaging_dispatch_rec we should compare source and destination. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Include messages_dgm.h only in messages.cVolker Lendecke2014-08-121-0/+1
| | | | | | | | 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 12 02:21:32 CEST 2014 on sn-devel-104
* messaging3: Move messaging_hdr handling to messages.c.Volker Lendecke2014-08-111-10/+39
| | | | | | | | 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>
* messaging3: Remove one-context protection from messages.cVolker Lendecke2014-08-111-22/+0
| | | | | | | messages_dgm.c takes care of it. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Pass dir_owner to messaging_dgm_init()Volker Lendecke2014-08-111-2/+2
|
* messaging3: Pass cache_dir to messaging_dgm_init()Volker Lendecke2014-08-111-2/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Move [un]become_root() calls out of messaging_dgm_send()Volker Lendecke2014-08-111-0/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Move sec_init() call out of messaging_dgm_init()Volker Lendecke2014-08-111-0/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Directly refer to messaging_dgm in messages.cVolker Lendecke2014-08-111-16/+11
| | | | | | | | | | | | | This removes the messaging_backend abstraction layer from messages_dgm.c. That layer was introduced for ctdb and is still used there. But as the messaging_dgm interface is very slim anyway, I don't think directly calling it is too bad. Why this commit? It is another step towards making messages_dgm independent of messages.[ch], thus it might become usable in other contexts like ctdb and source4 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add messaging_cleanupVolker Lendecke2014-08-111-0/+13
| | | | | | | | Rename smbcontrol's dgm-cleanup to msg-cleanup. We haven't published this UI yet :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging_dgm: Remove unused "messaging_context"Volker Lendecke2014-08-111-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Explicitly pass server_id to messaging_dgm_initVolker Lendecke2014-08-111-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Explicitly pass tevent_context to messaging_dgm_initVolker Lendecke2014-08-111-2/+3
| | | | | | | One dependency less on messaging_context() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging_dgm: Receive through a cb functionVolker Lendecke2014-08-111-2/+25
| | | | | | | This avoids calling messaging_dispatch_rec directly from messaging_dgm.c Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Remove an unnecessary variableVolker Lendecke2014-07-251-4/+1
| | | | | | | | | | We can inspect rec.buf with a debugger, no separate variable needed Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Jul 25 00:03:48 CEST 2014 on sn-devel-104
* messaging3: Simplify ping_message()Volker Lendecke2014-07-241-10/+4
| | | | | | | | The talloc_strnup was only used to \0-terminate the data for printing. The same can be achieved by %.* in the printf format. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* messaging3: Remove two procid_str_static callsVolker Lendecke2014-07-241-3/+6
| | | | | | | ... and thus implicit talloc_tos() calls Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* messaging3: Make messaging_dgm_init return 0/errnoVolker Lendecke2014-06-181-9/+9
| | | | | | | | 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): Wed Jun 18 21:17:57 CEST 2014 on sn-devel-104
* messaging3: Make messaging_dgm_wipe return 0/errnoVolker Lendecke2014-06-181-3/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Make the _send function return 0/errnoVolker Lendecke2014-06-181-5/+15
| | | | | | | This is to eventually make messaging_dgm usable in ctdb Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Enforce just one messaging contextVolker Lendecke2014-05-311-0/+22
| | | | | | | | | | | | The current messaging implementation is based on a tdb indexed by server_id. If we have more than one messaging context in a process, messages might not arrive at the right context and be dropped, depending on which signal handler is triggered first. This is the same patch as bd55fdb lifted to messaging.c Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Make messaging_context privateVolker Lendecke2014-05-311-0/+15
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add and use messaging_tevent_context()Volker Lendecke2014-05-311-0/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Introduce messaging_local_backend()Volker Lendecke2014-05-311-0/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: The backend send_fn doesn't need a messaging_contextVolker Lendecke2014-05-311-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:messaging: change messaging_backend to use iovec instead of data blob in ↵Michael Adam2014-05-301-30/+34
| | | | | | | | | | | | | | | send_fn This also changes the layering messaging_send_iov -> messaging_send_buf -> messaging_send to messaging_send_buf -> messaging_send -> messaging_send_iov Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Remove a pointless return;Volker Lendecke2014-05-271-1/+0
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Tue May 27 04:41:43 CEST 2014 on sn-devel-104
* messaging3: Fix whitespaceVolker Lendecke2014-05-271-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>