48
48
#include "includes.h"
49
#include "librpc/gen_ndr/messaging.h"
50
#include "librpc/gen_ndr/ndr_messaging.h"
52
53
struct messaging_callback {
53
54
struct messaging_callback *prev, *next;
95
96
Send one of the messages for the broadcast.
96
97
****************************************************************************/
98
static int traverse_fn(struct db_record *rec,
99
const struct connections_key *ckey,
100
const struct connections_data *crec,
99
static int traverse_fn(struct db_record *rec, const struct server_id *id,
100
uint32_t msg_flags, void *state)
103
102
struct msg_all *msg_all = (struct msg_all *)state;
106
if (crec->cnum != -1)
109
105
/* Don't send if the receiver hasn't registered an interest. */
111
if(!(crec->bcast_msg_flags & msg_all->msg_flag))
107
if((msg_flags & msg_all->msg_flag) == 0) {
114
111
/* If the msg send fails because the pid was not found (i.e. smbd died),
115
112
* the msg has already been deleted from the messages.tdb.*/
117
status = messaging_send_buf(msg_all->msg_ctx,
118
crec->pid, msg_all->msg_type,
114
status = messaging_send_buf(msg_all->msg_ctx, *id, msg_all->msg_type,
119
115
(uint8 *)msg_all->buf, msg_all->len);
121
117
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
123
119
/* If the pid was not found delete the entry from connections.tdb */
125
DEBUG(2,("pid %s doesn't exist - deleting connections %d [%s]\n",
126
procid_str_static(&crec->pid), crec->cnum,
121
DEBUG(2, ("pid %s doesn't exist\n", procid_str_static(id)));
129
123
rec->delete_rec(rec);
172
166
msg_all.n_sent = 0;
173
167
msg_all.msg_ctx = msg_ctx;
175
connections_forall(traverse_fn, &msg_all);
169
serverid_traverse(traverse_fn, &msg_all);
177
171
*n_sent = msg_all.n_sent;
200
194
status = messaging_tdb_init(ctx, ctx, &ctx->local);
202
196
if (!NT_STATUS_IS_OK(status)) {
203
DEBUG(0, ("messaging_tdb_init failed: %s\n",
197
DEBUG(2, ("messaging_tdb_init failed: %s\n",
204
198
nt_errstr(status)));
205
199
TALLOC_FREE(ctx);
211
205
status = messaging_ctdbd_init(ctx, ctx, &ctx->remote);
213
207
if (!NT_STATUS_IS_OK(status)) {
214
DEBUG(1, ("messaging_ctdb_init failed: %s\n",
208
DEBUG(2, ("messaging_ctdb_init failed: %s\n",
215
209
nt_errstr(status)));
216
210
TALLOC_FREE(ctx);
214
ctx->id.vnn = get_my_vnn();
222
217
messaging_register(ctx, NULL, MSG_PING, ping_message);
228
struct server_id messaging_server_id(const struct messaging_context *msg_ctx)
234
234
* re-init after a fork
236
NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
236
NTSTATUS messaging_reinit(struct messaging_context *msg_ctx,
240
241
TALLOC_FREE(msg_ctx->local);
242
245
status = messaging_tdb_init(msg_ctx, msg_ctx, &msg_ctx->local);
243
246
if (!NT_STATUS_IS_OK(status)) {
244
247
DEBUG(0, ("messaging_tdb_init failed: %s\n",
363
Dispatch one messsaging_rec
366
Dispatch one messaging_rec
365
368
void messaging_dispatch_rec(struct messaging_context *msg_ctx,
366
369
struct messaging_rec *rec)