*/
#include "includes.h"
-#include "librpc/gen_ndr/messaging.h"
+#include "messages.h"
static int pong_count;
int i, n;
char buf[12];
int ret;
+ TALLOC_CTX *frame = talloc_stackframe();
- load_case_tables();
+ smb_init_locale();
setup_logging(argv[0], DEBUG_STDOUT);
- lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
+ lp_load_global(get_dyn_CONFIGFILE());
- if (!(evt_ctx = tevent_context_init(NULL)) ||
- !(msg_ctx = messaging_init(NULL, procid_self(), evt_ctx))) {
+ if (!(evt_ctx = samba_tevent_context_init(NULL)) ||
+ !(msg_ctx = messaging_init(NULL, evt_ctx))) {
fprintf(stderr, "could not init messaging context\n");
+ TALLOC_FREE(frame);
exit(1);
}
if (argc != 3) {
fprintf(stderr, "%s: Usage - %s pid count\n", argv[0],
argv[0]);
+ TALLOC_FREE(frame);
exit(1);
}
}
}
- /* Now test that the duplicate filtering code works. */
+ /* Ensure all messages get through to ourselves. */
pong_count = 0;
- safe_strcpy(buf, "1234567890", sizeof(buf)-1);
+ strlcpy(buf, "1234567890", sizeof(buf));
for (i=0;i<n;i++) {
messaging_send(msg_ctx, messaging_server_id(msg_ctx), MSG_PING,
&data_blob_null);
messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
- MSG_PING,(uint8 *)buf, 11);
+ MSG_PING,(uint8_t *)buf, 11);
}
- for (i=0;i<n;i++) {
+ /*
+ * We have to loop at least 2 times for
+ * each message as local ping messages are
+ * handled by an immediate callback, that
+ * has to be dispatched, which sends a pong
+ * message, which also has to be dispatched.
+ * Above we sent 2*n messages, which means
+ * we have to dispatch 4*n times.
+ */
+
+ while (pong_count < n*2) {
ret = tevent_loop_once(evt_ctx);
if (ret != 0) {
break;
}
}
- if (pong_count != 2) {
- fprintf(stderr, "Duplicate filter failed (%d).\n", pong_count);
+ if (pong_count != 2*n) {
+ fprintf(stderr, "Message count failed (%d).\n", pong_count);
}
/* Speed testing */
if(NT_STATUS_IS_OK(messaging_send_buf(
msg_ctx, pid_to_procid(pid),
MSG_PING,
- (uint8 *)buf, 11)))
+ (uint8_t *)buf, 11)))
ping_count++;
if(NT_STATUS_IS_OK(messaging_send(
msg_ctx, pid_to_procid(pid),
(ping_count+pong_count)/timeval_elapsed(&tv));
}
+ TALLOC_FREE(frame);
return (0);
}