diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/peerinfo/perf_peerinfo_api.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/peerinfo/perf_peerinfo_api.c')
-rw-r--r-- | src/peerinfo/perf_peerinfo_api.c | 145 |
1 files changed, 73 insertions, 72 deletions
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index b9317478c..0c8c22345 100644 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c | |||
@@ -48,40 +48,40 @@ static struct GNUNET_SCHEDULER_Task *tt; | |||
48 | 48 | ||
49 | 49 | ||
50 | static void | 50 | static void |
51 | do_shutdown(void *cls) | 51 | do_shutdown (void *cls) |
52 | { | 52 | { |
53 | if (NULL != tt) | 53 | if (NULL != tt) |
54 | { | 54 | { |
55 | GNUNET_SCHEDULER_cancel(tt); | 55 | GNUNET_SCHEDULER_cancel (tt); |
56 | tt = NULL; | 56 | tt = NULL; |
57 | } | 57 | } |
58 | for (unsigned int i = 0; i < NUM_REQUESTS; i++) | 58 | for (unsigned int i = 0; i < NUM_REQUESTS; i++) |
59 | if (NULL != ic[i]) | 59 | if (NULL != ic[i]) |
60 | GNUNET_PEERINFO_iterate_cancel(ic[i]); | 60 | GNUNET_PEERINFO_iterate_cancel (ic[i]); |
61 | GNUNET_PEERINFO_disconnect(h); | 61 | GNUNET_PEERINFO_disconnect (h); |
62 | h = NULL; | 62 | h = NULL; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | static void | 66 | static void |
67 | do_timeout(void *cls) | 67 | do_timeout (void *cls) |
68 | { | 68 | { |
69 | tt = NULL; | 69 | tt = NULL; |
70 | GNUNET_SCHEDULER_shutdown(); | 70 | GNUNET_SCHEDULER_shutdown (); |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | static int | 74 | static int |
75 | check_it(void *cls, | 75 | check_it (void *cls, |
76 | const struct GNUNET_HELLO_Address *address, | 76 | const struct GNUNET_HELLO_Address *address, |
77 | struct GNUNET_TIME_Absolute expiration) | 77 | struct GNUNET_TIME_Absolute expiration) |
78 | { | 78 | { |
79 | return GNUNET_OK; | 79 | return GNUNET_OK; |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | static ssize_t | 83 | static ssize_t |
84 | address_generator(void *cls, size_t max, void *buf) | 84 | address_generator (void *cls, size_t max, void *buf) |
85 | { | 85 | { |
86 | size_t *agc = cls; | 86 | size_t *agc = cls; |
87 | ssize_t ret; | 87 | ssize_t ret; |
@@ -91,100 +91,101 @@ address_generator(void *cls, size_t max, void *buf) | |||
91 | if (*agc == 0) | 91 | if (*agc == 0) |
92 | return GNUNET_SYSERR; /* Done */ | 92 | return GNUNET_SYSERR; /* Done */ |
93 | 93 | ||
94 | GNUNET_asprintf(&caddress, "Address%d", *agc); | 94 | GNUNET_asprintf (&caddress, "Address%d", *agc); |
95 | address.peer = pid; | 95 | address.peer = pid; |
96 | address.address_length = strlen(caddress) + 1; | 96 | address.address_length = strlen (caddress) + 1; |
97 | address.address = caddress; | 97 | address.address = caddress; |
98 | address.transport_name = "peerinfotest"; | 98 | address.transport_name = "peerinfotest"; |
99 | ret = | 99 | ret = |
100 | GNUNET_HELLO_add_address(&address, | 100 | GNUNET_HELLO_add_address (&address, |
101 | GNUNET_TIME_relative_to_absolute | 101 | GNUNET_TIME_relative_to_absolute |
102 | (GNUNET_TIME_UNIT_HOURS), buf, max); | 102 | (GNUNET_TIME_UNIT_HOURS), buf, max); |
103 | GNUNET_free(caddress); | 103 | GNUNET_free (caddress); |
104 | *agc = 0; | 104 | *agc = 0; |
105 | return ret; | 105 | return ret; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | static void | 109 | static void |
110 | add_peer(size_t i) | 110 | add_peer (size_t i) |
111 | { | 111 | { |
112 | struct GNUNET_HELLO_Message *h2; | 112 | struct GNUNET_HELLO_Message *h2; |
113 | 113 | ||
114 | memset(&pid, i, sizeof(pid)); | 114 | memset (&pid, i, sizeof(pid)); |
115 | h2 = GNUNET_HELLO_create(&pid.public_key, | 115 | h2 = GNUNET_HELLO_create (&pid.public_key, |
116 | &address_generator, | 116 | &address_generator, |
117 | &i, | 117 | &i, |
118 | GNUNET_NO); | 118 | GNUNET_NO); |
119 | GNUNET_PEERINFO_add_peer(h, h2, NULL, NULL); | 119 | GNUNET_PEERINFO_add_peer (h, h2, NULL, NULL); |
120 | GNUNET_free(h2); | 120 | GNUNET_free (h2); |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | static void | 124 | static void |
125 | process(void *cls, | 125 | process (void *cls, |
126 | const struct GNUNET_PeerIdentity *peer, | 126 | const struct GNUNET_PeerIdentity *peer, |
127 | const struct GNUNET_HELLO_Message *hello, | 127 | const struct GNUNET_HELLO_Message *hello, |
128 | const char *err_msg) | 128 | const char *err_msg) |
129 | { | 129 | { |
130 | struct GNUNET_PEERINFO_IteratorContext **icp = cls; | 130 | struct GNUNET_PEERINFO_IteratorContext **icp = cls; |
131 | 131 | ||
132 | if (NULL == peer) | 132 | if (NULL == peer) |
133 | { | 133 | { |
134 | *icp = NULL; | 134 | *icp = NULL; |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | numpeers++; | 137 | numpeers++; |
138 | if (0 && (NULL != hello)) | 138 | if (0 && (NULL != hello)) |
139 | GNUNET_HELLO_iterate_addresses(hello, | 139 | GNUNET_HELLO_iterate_addresses (hello, |
140 | GNUNET_NO, | 140 | GNUNET_NO, |
141 | &check_it, | 141 | &check_it, |
142 | NULL); | 142 | NULL); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | static void | 146 | static void |
147 | run(void *cls, | 147 | run (void *cls, |
148 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 148 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
149 | struct GNUNET_TESTING_Peer *peer) | 149 | struct GNUNET_TESTING_Peer *peer) |
150 | { | 150 | { |
151 | h = GNUNET_PEERINFO_connect(cfg); | 151 | h = GNUNET_PEERINFO_connect (cfg); |
152 | GNUNET_assert(h != NULL); | 152 | GNUNET_assert (h != NULL); |
153 | for (unsigned int i = 0; i < NUM_REQUESTS; i++) | 153 | for (unsigned int i = 0; i < NUM_REQUESTS; i++) |
154 | { | 154 | { |
155 | add_peer(i); | 155 | add_peer (i); |
156 | ic[i] = GNUNET_PEERINFO_iterate(h, | 156 | ic[i] = GNUNET_PEERINFO_iterate (h, |
157 | GNUNET_YES, | 157 | GNUNET_YES, |
158 | NULL, | 158 | NULL, |
159 | &process, | 159 | &process, |
160 | &ic[i]); | 160 | &ic[i]); |
161 | } | 161 | } |
162 | tt = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, | 162 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( |
163 | 5), | 163 | GNUNET_TIME_UNIT_SECONDS, |
164 | &do_timeout, | 164 | 5), |
165 | NULL); | 165 | &do_timeout, |
166 | GNUNET_SCHEDULER_add_shutdown(&do_shutdown, | 166 | NULL); |
167 | NULL); | 167 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, |
168 | NULL); | ||
168 | } | 169 | } |
169 | 170 | ||
170 | 171 | ||
171 | int | 172 | int |
172 | main(int argc, | 173 | main (int argc, |
173 | char *argv[]) | 174 | char *argv[]) |
174 | { | 175 | { |
175 | if (0 != GNUNET_TESTING_service_run("perf-gnunet-peerinfo", | 176 | if (0 != GNUNET_TESTING_service_run ("perf-gnunet-peerinfo", |
176 | "peerinfo", | 177 | "peerinfo", |
177 | "test_peerinfo_api_data.conf", | 178 | "test_peerinfo_api_data.conf", |
178 | &run, NULL)) | 179 | &run, NULL)) |
179 | return 1; | 180 | return 1; |
180 | fprintf(stderr, | 181 | fprintf (stderr, |
181 | "Received %u/%u calls before timeout\n", | 182 | "Received %u/%u calls before timeout\n", |
182 | numpeers, | 183 | numpeers, |
183 | NUM_REQUESTS * NUM_REQUESTS / 2); | 184 | NUM_REQUESTS * NUM_REQUESTS / 2); |
184 | GAUGER("PEERINFO", | 185 | GAUGER ("PEERINFO", |
185 | "Peerinfo lookups", | 186 | "Peerinfo lookups", |
186 | numpeers / 5, | 187 | numpeers / 5, |
187 | "peers/s"); | 188 | "peers/s"); |
188 | return 0; | 189 | return 0; |
189 | } | 190 | } |
190 | 191 | ||