| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Samba internal messaging functions
|
|---|
| 4 | Copyright (C) 2007 by Volker Lendecke
|
|---|
| 5 |
|
|---|
| 6 | This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | /**
|
|---|
| 21 | @defgroup messages Internal messaging framework
|
|---|
| 22 | @{
|
|---|
| 23 | @file messages.c
|
|---|
| 24 |
|
|---|
| 25 | @brief Module for internal messaging between Samba daemons.
|
|---|
| 26 |
|
|---|
| 27 | The idea is that if a part of Samba wants to do communication with
|
|---|
| 28 | another Samba process then it will do a message_register() of a
|
|---|
| 29 | dispatch function, and use message_send_pid() to send messages to
|
|---|
| 30 | that process.
|
|---|
| 31 |
|
|---|
| 32 | The dispatch function is given the pid of the sender, and it can
|
|---|
| 33 | use that to reply by message_send_pid(). See ping_message() for a
|
|---|
| 34 | simple example.
|
|---|
| 35 |
|
|---|
| 36 | @caution Dispatch functions must be able to cope with incoming
|
|---|
| 37 | messages on an *odd* byte boundary.
|
|---|
| 38 |
|
|---|
| 39 | This system doesn't have any inherent size limitations but is not
|
|---|
| 40 | very efficient for large messages or when messages are sent in very
|
|---|
| 41 | quick succession.
|
|---|
| 42 |
|
|---|
| 43 | */
|
|---|
| 44 |
|
|---|
| 45 | #include "includes.h"
|
|---|
| 46 | #include "librpc/gen_ndr/messaging.h"
|
|---|
| 47 | #include "librpc/gen_ndr/ndr_messaging.h"
|
|---|
| 48 |
|
|---|
| 49 | static sig_atomic_t received_signal;
|
|---|
| 50 |
|
|---|
| 51 | static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
|
|---|
| 52 | struct server_id pid, int msg_type,
|
|---|
| 53 | const DATA_BLOB *data,
|
|---|
| 54 | struct messaging_backend *backend);
|
|---|
| 55 |
|
|---|
| 56 | /****************************************************************************
|
|---|
| 57 | Notifications come in as signals.
|
|---|
| 58 | ****************************************************************************/
|
|---|
| 59 |
|
|---|
| 60 | static void sig_usr1(void)
|
|---|
| 61 | {
|
|---|
| 62 | received_signal = 1;
|
|---|
| 63 | sys_select_signal(SIGUSR1);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | static int messaging_tdb_destructor(struct messaging_backend *tdb_ctx)
|
|---|
| 67 | {
|
|---|
| 68 | TDB_CONTEXT *tdb = (TDB_CONTEXT *)tdb_ctx->private_data;
|
|---|
| 69 | tdb_close(tdb);
|
|---|
| 70 | return 0;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | /****************************************************************************
|
|---|
| 74 | Initialise the messaging functions.
|
|---|
|
|---|