2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Volker Lendecke 2014
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.
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.
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/>.
23 #include "lib/util/server_id_db.h"
25 int main(int argc
, const char *argv
[])
27 TALLOC_CTX
*frame
= talloc_stackframe();
28 struct tevent_context
*ev
;
29 struct messaging_context
*msg_ctx
;
30 struct server_id_db
*names
;
31 struct server_id notifyd
;
32 struct tevent_req
*req
;
37 fprintf(stderr
, "Usage: %s <smb.conf-file>\n", argv
[0]);
41 setup_logging(argv
[0], DEBUG_STDOUT
);
42 lp_load_global(argv
[1]);
44 ev
= tevent_context_init(NULL
);
46 fprintf(stderr
, "tevent_context_init failed\n");
50 msg_ctx
= messaging_init(ev
, ev
);
51 if (msg_ctx
== NULL
) {
52 fprintf(stderr
, "messaging_init failed\n");
56 names
= messaging_names_db(msg_ctx
);
58 ok
= server_id_db_lookup_one(names
, "notify-daemon", ¬ifyd
);
60 fprintf(stderr
, "no notifyd\n");
64 for (i
=0; i
<50000; i
++) {
65 struct notify_rec_change_msg msg
= {
66 .instance
.filter
= UINT32_MAX
,
67 .instance
.subdir_filter
= UINT32_MAX
74 len
= snprintf(path
, sizeof(path
), "/tmp%u", i
);
76 iov
[0].iov_base
= &msg
;
77 iov
[0].iov_len
= offsetof(struct notify_rec_change_msg
, path
);
78 iov
[1].iov_base
= path
;
79 iov
[1].iov_len
= len
+1;
81 status
= messaging_send_iov(
82 msg_ctx
, notifyd
, MSG_SMB_NOTIFY_REC_CHANGE
,
83 iov
, ARRAY_SIZE(iov
), NULL
, 0);
84 if (!NT_STATUS_IS_OK(status
)) {
85 fprintf(stderr
, "messaging_send_iov returned %s\n",
90 msg
.instance
.filter
= 0;
91 msg
.instance
.subdir_filter
= 0;
93 status
= messaging_send_iov(
94 msg_ctx
, notifyd
, MSG_SMB_NOTIFY_REC_CHANGE
,
95 iov
, ARRAY_SIZE(iov
), NULL
, 0);
96 if (!NT_STATUS_IS_OK(status
)) {
97 fprintf(stderr
, "messaging_send_iov returned %s\n",
103 req
= messaging_read_send(ev
, ev
, msg_ctx
, MSG_PONG
);
105 fprintf(stderr
, "messaging_read_send failed\n");
108 messaging_send_buf(msg_ctx
, notifyd
, MSG_PING
, NULL
, 0);
110 ok
= tevent_req_poll(req
, ev
);
112 fprintf(stderr
, "tevent_req_poll failed\n");