diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-05-15 14:39:18 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:22:06 -0500 |
commit | 331041139f2389baab6ba28483121abc31c1a870 (patch) | |
tree | d4d719104d3a864507af67904c7442265cc036e3 | |
parent | 63f9607ea7d48ad4bd418fc1135d72215aa05c85 (diff) | |
download | samba-331041139f2389baab6ba28483121abc31c1a870.tar.gz samba-331041139f2389baab6ba28483121abc31c1a870.tar.bz2 samba-331041139f2389baab6ba28483121abc31c1a870.zip |
r22906: Some more message_send_pid
(This used to be commit 8abf9f396375b42d838e992b3a4e40e68e550ab2)
-rw-r--r-- | source3/torture/msgtest.c | 41 | ||||
-rw-r--r-- | source3/utils/smbcontrol.c | 79 |
2 files changed, 73 insertions, 47 deletions
diff --git a/source3/torture/msgtest.c b/source3/torture/msgtest.c index 703832c7b4..18674ef0f5 100644 --- a/source3/torture/msgtest.c +++ b/source3/torture/msgtest.c @@ -29,14 +29,19 @@ static int pong_count; /**************************************************************************** a useful function for testing the message system ****************************************************************************/ -static void pong_message(int msg_type, struct server_id src, - void *buf, size_t len, void *private_data) +static void pong_message(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id pid, + DATA_BLOB *data) { pong_count++; } int main(int argc, char *argv[]) { + struct event_context *evt_ctx; + struct messaging_context *msg_ctx; pid_t pid; int i, n; char buf[12]; @@ -49,6 +54,12 @@ static void pong_message(int msg_type, struct server_id src, message_init(); + if (!(evt_ctx = event_context_init(NULL)) || + !(msg_ctx = messaging_init(NULL, server_id_self(), evt_ctx))) { + fprintf(stderr, "could not init messaging context\n"); + exit(1); + } + if (argc != 3) { fprintf(stderr, "%s: Usage - %s pid count\n", argv[0], argv[0]); @@ -58,10 +69,11 @@ static void pong_message(int msg_type, struct server_id src, pid = atoi(argv[1]); n = atoi(argv[2]); - message_register(MSG_PONG, pong_message, NULL); + messaging_register(msg_ctx, NULL, MSG_PONG, pong_message); for (i=0;i<n;i++) { - message_send_pid(pid_to_procid(pid), MSG_PING, NULL, 0, True); + messaging_send(msg_ctx, pid_to_procid(pid), MSG_PING, + &data_blob_null); } while (pong_count < i) { @@ -75,10 +87,10 @@ static void pong_message(int msg_type, struct server_id src, safe_strcpy(buf, "1234567890", sizeof(buf)-1); for (i=0;i<n;i++) { - message_send_pid(pid_to_procid(getpid()), MSG_PING, - NULL, 0, False); - message_send_pid(pid_to_procid(getpid()), MSG_PING, - buf, 11, False); + messaging_send(msg_ctx, pid_to_procid(getpid()), MSG_PING, + &data_blob_null); + messaging_send_buf(msg_ctx, pid_to_procid(getpid()), MSG_PING, + (uint8 *)buf, 11); } for (i=0;i<n;i++) { @@ -101,13 +113,14 @@ static void pong_message(int msg_type, struct server_id src, printf("Sending pings for %d seconds\n", (int)timelimit); while (timeval_elapsed(&tv) < timelimit) { - if(NT_STATUS_IS_OK(message_send_pid(pid_to_procid(pid), - MSG_PING, - buf, 11, False))) + if(NT_STATUS_IS_OK(messaging_send_buf( + msg_ctx, pid_to_procid(pid), + MSG_PING, + (uint8 *)buf, 11))) ping_count++; - if(NT_STATUS_IS_OK(message_send_pid(pid_to_procid(pid), - MSG_PING, - NULL, 0, False))) + if(NT_STATUS_IS_OK(messaging_send( + msg_ctx, pid_to_procid(pid), + MSG_PING, &data_blob_null))) ping_count++; while (ping_count > pong_count + 20) { diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 55711c94a1..c4d71361fd 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -47,7 +47,8 @@ static int num_replies; /* Used by message callback fns */ /* Send a message to a destination pid. Zero means broadcast smbd. */ -static BOOL send_message(struct server_id pid, int msg_type, +static BOOL send_message(struct messaging_context *msg_ctx, + struct server_id pid, int msg_type, const void *buf, int len, BOOL duplicates) { @@ -58,8 +59,9 @@ static BOOL send_message(struct server_id pid, int msg_type, return False; if (procid_to_pid(&pid) != 0) - return NT_STATUS_IS_OK(message_send_pid(pid, msg_type, buf, len, - duplicates)); + return NT_STATUS_IS_OK( + messaging_send_buf(msg_ctx, pid, msg_type, + (uint8 *)buf, len)); ret = message_send_all(msg_type, buf, len, duplicates, &n_sent); @@ -133,7 +135,7 @@ static BOOL do_debug(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_DEBUG, argv[1], strlen(argv[1]) + 1, False); } @@ -328,7 +330,7 @@ static BOOL do_inject_fault(struct messaging_context *msg_ctx, return False; } - return send_message(pid, MSG_SMB_INJECT_FAULT, + return send_message(msg_ctx, pid, MSG_SMB_INJECT_FAULT, &sig, sizeof(int), False); } #endif /* DEVELOPER */ @@ -345,7 +347,7 @@ static BOOL do_election(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_FORCE_ELECTION, NULL, 0, False); } @@ -371,7 +373,7 @@ static BOOL do_ping(struct messaging_context *msg_ctx, /* Send a message and register our interest in a reply */ - if (!send_message(pid, MSG_PING, NULL, 0, False)) + if (!send_message(msg_ctx, pid, MSG_PING, NULL, 0, False)) return False; message_register(MSG_PONG, pong_cb, NULL); @@ -415,26 +417,29 @@ static BOOL do_profile(struct messaging_context *msg_ctx, return False; } - return send_message(pid, MSG_PROFILE, &v, sizeof(int), False); + return send_message(msg_ctx, pid, MSG_PROFILE, &v, sizeof(int), False); } /* Return the profiling level */ -static void profilelevel_cb(int msg_type, struct server_id pid, void *buf, - size_t len, void *private_data) +static void profilelevel_cb(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id pid, + DATA_BLOB *data) { int level; const char *s; num_replies++; - if (len != sizeof(int)) { + if (data->length != sizeof(int)) { fprintf(stderr, "invalid message length %ld returned\n", - (unsigned long)len); + (unsigned long)data->length); return; } - memcpy(&level, buf, sizeof(int)); + memcpy(&level, data->data, sizeof(int)); switch (level) { case 0: @@ -457,14 +462,17 @@ static void profilelevel_cb(int msg_type, struct server_id pid, void *buf, printf("Profiling %s on pid %u\n",s,(unsigned int)procid_to_pid(&pid)); } -static void profilelevel_rqst(int msg_type, struct server_id pid, - void *buf, size_t len, void *private_data) +static void profilelevel_rqst(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id pid, + DATA_BLOB *data) { int v = 0; /* Send back a dummy reply */ - send_message(pid, MSG_PROFILELEVEL, &v, sizeof(int), False); + send_message(msg_ctx, pid, MSG_PROFILELEVEL, &v, sizeof(int), False); } static BOOL do_profilelevel(struct messaging_context *msg_ctx, @@ -478,11 +486,12 @@ static BOOL do_profilelevel(struct messaging_context *msg_ctx, /* Send a message and register our interest in a reply */ - if (!send_message(pid, MSG_REQ_PROFILELEVEL, NULL, 0, False)) + if (!send_message(msg_ctx, pid, MSG_REQ_PROFILELEVEL, NULL, 0, False)) return False; - message_register(MSG_PROFILELEVEL, profilelevel_cb, NULL); - message_register(MSG_REQ_PROFILELEVEL, profilelevel_rqst, NULL); + messaging_register(msg_ctx, NULL, MSG_PROFILELEVEL, profilelevel_cb); + messaging_register(msg_ctx, NULL, MSG_REQ_PROFILELEVEL, + profilelevel_rqst); wait_replies(procid_to_pid(&pid) == 0); @@ -509,7 +518,7 @@ static BOOL do_debuglevel(struct messaging_context *msg_ctx, /* Send a message and register our interest in a reply */ - if (!send_message(pid, MSG_REQ_DEBUGLEVEL, NULL, 0, False)) + if (!send_message(msg_ctx, pid, MSG_REQ_DEBUGLEVEL, NULL, 0, False)) return False; message_register(MSG_DEBUGLEVEL, print_pid_string_cb, NULL); @@ -679,7 +688,7 @@ static BOOL do_closeshare(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_SMB_FORCE_TDIS, argv[1], strlen(argv[1]) + 1, False); } @@ -694,7 +703,7 @@ static BOOL do_samsync(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_SMB_SAM_SYNC, NULL, 0, False); } @@ -709,7 +718,7 @@ static BOOL do_samrepl(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_SMB_SAM_REPL, NULL, 0, False); } @@ -728,7 +737,7 @@ static BOOL do_poolusage(struct messaging_context *msg_ctx, /* Send a message and register our interest in a reply */ - if (!send_message(pid, MSG_REQ_POOL_USAGE, NULL, 0, False)) + if (!send_message(msg_ctx, pid, MSG_REQ_POOL_USAGE, NULL, 0, False)) return False; wait_replies(procid_to_pid(&pid) == 0); @@ -754,7 +763,7 @@ static BOOL do_dmalloc_mark(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_REQ_DMALLOC_MARK, NULL, 0, False); } @@ -770,7 +779,7 @@ static BOOL do_dmalloc_changed(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_REQ_DMALLOC_LOG_CHANGED, NULL, 0, False); } @@ -785,7 +794,7 @@ static BOOL do_shutdown(struct messaging_context *msg_ctx, return False; } - return send_message(pid, MSG_SHUTDOWN, NULL, 0, False); + return send_message(msg_ctx, pid, MSG_SHUTDOWN, NULL, 0, False); } /* Notify a driver upgrade */ @@ -800,7 +809,7 @@ static BOOL do_drvupgrade(struct messaging_context *msg_ctx, return False; } - return send_message( + return send_message(msg_ctx, pid, MSG_DEBUG, argv[1], strlen(argv[1]) + 1, False); } @@ -835,7 +844,7 @@ static BOOL do_winbind_online(struct messaging_context *msg_ctx, tdb_delete_bystring(tdb, "WINBINDD_OFFLINE"); tdb_close(tdb); - return send_message(pid, MSG_WINBIND_ONLINE, NULL, 0, False); + return send_message(msg_ctx, pid, MSG_WINBIND_ONLINE, NULL, 0, False); } static BOOL do_winbind_offline(struct messaging_context *msg_ctx, @@ -891,7 +900,8 @@ static BOOL do_winbind_offline(struct messaging_context *msg_ctx, tdb_store_bystring(tdb, "WINBINDD_OFFLINE", d, TDB_INSERT); - ret = send_message(pid, MSG_WINBIND_OFFLINE, NULL, 0, False); + ret = send_message(msg_ctx, pid, MSG_WINBIND_OFFLINE, + NULL, 0, False); /* Check that the entry "WINBINDD_OFFLINE" still exists. */ d = tdb_fetch_bystring( tdb, "WINBINDD_OFFLINE" ); @@ -924,7 +934,8 @@ static BOOL do_winbind_onlinestatus(struct messaging_context *msg_ctx, message_register(MSG_WINBIND_ONLINESTATUS, print_pid_string_cb, NULL); - if (!send_message(pid, MSG_WINBIND_ONLINESTATUS, &myid, sizeof(myid), False)) + if (!send_message(msg_ctx, pid, MSG_WINBIND_ONLINESTATUS, &myid, + sizeof(myid), False)) return False; wait_replies(procid_to_pid(&pid) == 0); @@ -949,7 +960,8 @@ static BOOL do_reload_config(struct messaging_context *msg_ctx, return False; } - return send_message(pid, MSG_SMB_CONF_UPDATED, NULL, 0, False); + return send_message(msg_ctx, pid, MSG_SMB_CONF_UPDATED, + NULL, 0, False); } static void my_make_nmb_name( struct nmb_name *n, const char *name, int type) @@ -997,7 +1009,8 @@ static BOOL do_nodestatus(struct messaging_context *msg_ctx, p.packet.nmb.question.question_type = 0x21; p.packet.nmb.question.question_class = 0x1; - return send_message(pid, MSG_SEND_PACKET, &p, sizeof(p), False); + return send_message(msg_ctx, pid, MSG_SEND_PACKET, &p, sizeof(p), + False); } /* A list of message type supported */ |