00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "includes.h"
00025
00026 static int pong_count;
00027
00028
00029
00030
00031
00032 static void pong_message(int msg_type, struct process_id src,
00033 void *buf, size_t len, void *private_data)
00034 {
00035 pong_count++;
00036 }
00037
00038 int main(int argc, char *argv[])
00039 {
00040 pid_t pid;
00041 int i, n;
00042 char buf[12];
00043
00044 load_case_tables();
00045
00046 setup_logging(argv[0],True);
00047
00048 lp_load(dyn_CONFIGFILE,False,False,False,True);
00049
00050 message_init();
00051
00052 if (argc != 3) {
00053 fprintf(stderr, "%s: Usage - %s pid count\n", argv[0],
00054 argv[0]);
00055 exit(1);
00056 }
00057
00058 pid = atoi(argv[1]);
00059 n = atoi(argv[2]);
00060
00061 message_register(MSG_PONG, pong_message, NULL);
00062
00063 for (i=0;i<n;i++) {
00064 message_send_pid(pid_to_procid(pid), MSG_PING, NULL, 0, True);
00065 }
00066
00067 while (pong_count < i) {
00068 message_dispatch();
00069 smb_msleep(1);
00070 }
00071
00072
00073 pong_count = 0;
00074
00075 safe_strcpy(buf, "1234567890", sizeof(buf)-1);
00076
00077 for (i=0;i<n;i++) {
00078 message_send_pid(pid_to_procid(getpid()), MSG_PING,
00079 NULL, 0, False);
00080 message_send_pid(pid_to_procid(getpid()), MSG_PING,
00081 buf, 11, False);
00082 }
00083
00084 for (i=0;i<n;i++) {
00085 message_dispatch();
00086 smb_msleep(1);
00087 }
00088
00089 if (pong_count != 2) {
00090 fprintf(stderr, "Duplicate filter failed (%d).\n", pong_count);
00091 }
00092
00093
00094
00095 pong_count = 0;
00096
00097 {
00098 struct timeval tv = timeval_current();
00099 size_t timelimit = n;
00100 size_t ping_count = 0;
00101
00102 printf("Sending pings for %d seconds\n", (int)timelimit);
00103 while (timeval_elapsed(&tv) < timelimit) {
00104 if(NT_STATUS_IS_OK(message_send_pid(pid_to_procid(pid),
00105 MSG_PING,
00106 buf, 11, False)))
00107 ping_count++;
00108 if(NT_STATUS_IS_OK(message_send_pid(pid_to_procid(pid),
00109 MSG_PING,
00110 NULL, 0, False)))
00111 ping_count++;
00112
00113 while (ping_count > pong_count + 20) {
00114 message_dispatch();
00115 }
00116 }
00117
00118 printf("waiting for %d remaining replies (done %d)\n",
00119 (int)(ping_count - pong_count), pong_count);
00120 while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) {
00121 message_dispatch();
00122 }
00123
00124 if (ping_count != pong_count) {
00125 fprintf(stderr, "ping test failed! received %d, sent "
00126 "%d\n", pong_count, (int)ping_count);
00127 }
00128
00129 printf("ping rate of %.0f messages/sec\n",
00130 (ping_count+pong_count)/timeval_elapsed(&tv));
00131 }
00132
00133 return (0);
00134 }
00135