summaryrefslogtreecommitdiffstats
path: root/source3/lib/messages.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* messaging3: Relax the self-send check a bitVolker Lendecke2014-05-081-1/+2
| | | | | | | | | In the future we will have multiple task id's per process. They should all be able to benefit from the self-send local optimization. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Factor out the self-send checkVolker Lendecke2014-05-081-2/+8
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Push down the self-send callbackVolker Lendecke2014-05-081-52/+94
| | | | | | | | | | | | | | | In the messaging_read receivers we already defer the callback: We need to reply on potentially different tevent contexts, thus the defer_callback. The callback case in messaging_dispatch_rec was direct before this patch. This changes messaging_dispatch_rec to also defer the callback in the self-send case. Now we need only two roundtrips in local-messaging-read1 :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Fix messaging_filtered_read_sendVolker Lendecke2014-05-081-0/+15
| | | | | | | | | | | | | If we register an additional tevent context, we can now properly do nested event contexts, listening for just one message type inside a tevent_req_poll. At this point this only enhances things without ctdb, but I'm working fixing that soon. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add comments about not touching "waiters"Volker Lendecke2014-05-081-0/+16
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Fix 80-char line limitVolker Lendecke2014-05-081-5/+9
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add messaging_filtered_readVolker Lendecke2014-05-081-25/+103
| | | | | | | | This delegates the decision whether to read a message to a callback Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Fix messaging_read_send/recvVolker Lendecke2014-04-301-16/+74
| | | | | | | | | | | | | | | | | | | | | | | | | messaging_read_send/recv was okay for just one handler in the queue. For multiple handlers it was pretty broken. A handler that deletes itself as part of the callback (pretty typical use case...) drops the message for a subsequent handler that responds to the same message type. In messaging_dispatch_rec we walk the array, however messaging_read_cleanup has already changed the array. tevent_req_defer_callback does not help here: It only defers the callback, it does not defer the cleanup function. This also happens when a callback deletes a different handler A handler that re-installs itself in the callback might get a message twice. This patch changes the code such that only messaging_dispatch_rec adds records to msg_ctx->waiters, new waiters are put into a staging area first (msg_ctx->new_waiters). Also messaging_read_cleanup does not move anything around in msg_ctx->waiters, it only nulls out itself. messaging_dispatch_rec is changed to cope with this. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Make "presult" optional in messaging_read_recvVolker Lendecke2014-04-301-1/+3
| | | | | | | | Callers might not be interested in the rec, just the fact that something arrived Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Fix formattingVolker Lendecke2014-04-301-1/+2
| | | | | | | This went over the 80-char limit Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: messaging: Add infrastructure to clean up orphaned sockets every 15 ↵Volker Lendecke2014-04-231-0/+50
| | | | | | | minutes as a background task. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging3: Add messaging_send_iovVolker Lendecke2014-04-231-0/+19
| | | | | | | | This uses a copy, will be replaced by a direct iovec call through to sendmsg on the unix domain socket Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove messages_localVolker Lendecke2014-04-231-17/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Add messaging_dgmVolker Lendecke2014-04-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Messaging based on unix domain datagram sockets This makes every process participating in messaging bind on a unix domain datagram socket, similar to the source4 based messaging. The details are a bit different though: Retry after EWOULDBLOCK is done with a blocking thread, not by polling. This was the only way I could in experiments avoid a thundering herd or high load under Linux in extreme overload situations like many thousands of processes sending to one blocked process. If there are better ideas to do this in a simple way, I'm more than happy to remove the pthreadpool dependency again. There is only one socket per process, not per task. I don't think that per-task sockets are really necessary, we can do filtering in user space. The message contains the destination server_id, which contains the destination task_id. I think we can rebase the source4 based imessaging on top of this, allowing multiple imessaging contexts on top of one messaging_context. I had planned to do this conversion before this goes in, but Jeremy convinced me that this has value in itself :-) Per socket we also create a fcntl-based lockfile to allow race-free cleanup of orphaned sockets. This lockfile contains the unique_id, which in the future will make the server_id.tdb obsolete. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: messages: Implement cleanup of dead records.Jeremy Allison2014-04-031-0/+17
| | | | | | | | | | | | When a smbd process dies, pending messages.tdb records for this process might not get cleaned up. Implement a cleanup for dead records that is triggered after a smbd dies uncleanly; the records for that PID are deleted. Based on a patchset from Christof Schmitt <cs@samba.org>. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* s3:build: remove global CLUSTER_SUPPORT defineStefan Metzmacher2014-03-241-7/+0
| | | | | | | | | | All ctdb specific code is isolated in samba-cluster-support.so now. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Mon Mar 24 19:08:44 CET 2014 on sn-devel-104
* messaging3: Add messaging_read_send/recvVolker Lendecke2014-01-211-0/+126
| | | | | | | | | | | | | | | | | | | This is made to replace the msg_channel abstraction. msg_channel was created to not miss any messages. For this, some complex queueing was installed. This complexity has caused quite a few problems in the past (see bug 10284 for example). messaging_read_send/recv is able to achieve the same goal with a lot less complexity. The messaging_read_send atomically installs the reader into the messaging_context, we will not miss any messages while this installed. messaging_send_recv will deinstall that listener, but in the callback function you can directly call messaging_read_send again without going through the tevent_loop_once. As long as this is always made sure, no messages will be lost. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging: Fix a memleak (master only..)Volker Lendecke2014-01-101-7/+9
| | | | | | | | | | Immediate tevents don't free themselves as timed events do :-) 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 Jan 10 01:20:04 CET 2014 on sn-devel-104
* messaging: Use talloc_pooled_objectVolker Lendecke2014-01-091-6/+3
| | | | | | | ... not as a speed improvement, it saves the second NULL check Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messaging: Move the self-send logic out of messaging_tdbVolker Lendecke2014-01-091-0/+52
| | | | | | | This is not specific to tdb Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* messages: Use uint8_t type.Andreas Schneider2013-02-221-2/+2
| | | | Reviewed-by: Alexander Bokovoy <ab@samba.org>
* s3:lib: s/struct event_context/struct tevent_contextStefan Metzmacher2013-02-191-1/+1
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:lib: make sure we don't try to send messages to server_id's marked as ↵Stefan Metzmacher2012-08-241-0/+4
| | | | | | | | | disconnected metze Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Aug 24 15:54:48 CEST 2012 on sn-devel-104
* s3: Fix a valgrind errorVolker Lendecke2012-03-291-1/+8
| | | | | Autobuild-User: Volker Lendecke <vl@samba.org> Autobuild-Date: Thu Mar 29 15:50:13 CEST 2012 on sn-devel-104
* s3: Add debug when a message is registeredVolker Lendecke2012-01-241-0/+4
| | | | | | | We've always had the corresponding deregister message Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Tue Jan 24 15:27:51 CET 2012 on sn-devel-104
* s3:lib/messages: remove unused messaging_event_context()Stefan Metzmacher2012-01-171-5/+0
| | | | | | | metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Tue Jan 17 09:45:30 CET 2012 on sn-devel-104
* s3: Remove a bunch of calls to procid_self()Volker Lendecke2011-12-121-5/+3
| | | | All callers to messaging_[re]init only used procid_self()
* s3: Fix some nonempty blank linesVolker Lendecke2011-10-311-5/+5
| | | | | Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Mon Oct 31 14:25:14 CET 2011 on sn-devel-104
* s3: Fix a commentVolker Lendecke2011-10-311-1/+4
|
* s3:messages: convert to use only dbwrap wrapper functionsMichael Adam2011-10-111-1/+1
| | | | Avoid direct use of the db_record and db_context structs.
* s3-messaging: Fix messaging classes.Simo Sorce2011-08-111-8/+11
| | | | | | | | | | | | This has been broken since ff0ac5b0 (May 2007). Basically all messages were belonging to the General class except for CTDB messages. This fixed the message_send_all() function to correctly compute the class, and fixes registrations to include all they need to cope with the fact not all messages are of calss general (registrations rotted a bit because as long as FLAG_MSG_GENERAL was defined the process woould receive all messages). Signed-off-by: Andreas Schneider <asn@samba.org>
* s3-messaging: Remove obsolete class.Simo Sorce2011-08-111-2/+0
| | | | | | | 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>
* s3:dbwrap: move all .c and .h files of dbwrap to lib/dbwrap/Michael Adam2011-07-291-1/+1
| | | | | Autobuild-User: Michael Adam <obnox@samba.org> Autobuild-Date: Fri Jul 29 13:34:22 CEST 2011 on sn-devel-104
* s3-talloc Change TALLOC_ZERO_P() to talloc_zero()Andrew Bartlett2011-06-091-1/+1
| | | | | Using the standard macro makes it easier to move code into common, as TALLOC_ZERO_P isn't standard talloc.
* s3: Fix two debug messagesVolker Lendecke2011-06-061-2/+2
| | | | | Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Mon Jun 6 14:11:06 CEST 2011 on sn-devel-104
* More const fixes for compiler warnings from the waf build.Jeremy Allison2011-05-051-1/+1
|
* s3-messages: make ndr_messaging.h part of messages.h.Günther Deschner2011-03-301-2/+0
| | | | Guenther
* s3-messages: only include messages.h where needed.Günther Deschner2011-03-301-0/+1
| | | | Guenther
* s3-server_id: only include server_id where needed.Günther Deschner2011-03-021-0/+1
| | | | Guenther
* Move error reporting of messaging context creation fail intoJeremy Allison2010-11-141-2/+2
| | | | | | | | the daemons themselves. Allows client utilities to silently fail to create a messaging context due to access denied on the messaging tdb (which I need for the following patch). Jeremy.
* s3: messaging_ctdbd_init potentially modifies my_vnnVolker Lendecke2010-08-311-0/+1
| | | | | | | | If we call messaging_ctdbd_connection() we end up with the wrong vnn in our messaging context. This is a bit of a hack, get_my_vnn() needs to go eventually along with procid_self()
* s3: Fix a typoVolker Lendecke2010-08-281-1/+1
|