Home | History | Annotate | Download | only in ServiceRegistration

Lines Matching defs:probe_state

61 struct probe_state {
76 probe_state_finalize(probe_state_t *probe_state)
78 if (probe_state->wakeup != NULL) {
79 ioloop_wakeup_release(probe_state->wakeup);
81 if (probe_state->service != NULL) {
82 thread_service_release(probe_state->service);
83 probe_state->service = NULL;
85 if (probe_state->connection != NULL) {
86 ioloop_comm_release(probe_state->connection);
87 probe_state->connection = NULL;
89 if (probe_state->context_release) {
90 probe_state->context_release(probe_state->context);
92 free(probe_state);
98 probe_state_t *probe_state = service->probe_state;
99 probe_state->service = NULL;
100 service->probe_state = NULL;
102 if (probe_state->context_release != NULL) {
103 probe_state->context_release(probe_state->context);
105 probe_state->context = NULL;
108 if (probe_state->wakeup != NULL) {
109 ioloop_cancel_wake_event(probe_state->wakeup);
112 if (probe_state->connection != NULL) {
113 ioloop_comm_cancel(probe_state->connection); // Cancel the connection (should result in the state being released)
114 ioloop_comm_release(probe_state->connection);
115 probe_state->connection = NULL;
117 RELEASE_HERE(probe_state, probe_state); // The thread_service_t's reference to the probe state
123 probe_state_t *probe_state = context;
126 thread_service_t *service = probe_state->service;
127 // Note: we should still have references both to probe_state and to service here because they each held references
129 probe_state->service = NULL;
130 service->probe_state = NULL;
160 if (probe_state->callback != NULL) {
161 probe_state->callback(probe_state->service, probe_state->context, succeeded);
162 probe_state->callback = NULL;
164 if (probe_state->context_release != NULL) {
165 probe_state->context_release(probe_state->context);
167 probe_state->context = NULL;
170 if (probe_state->wakeup != NULL) {
171 ioloop_cancel_wake_event(probe_state->wakeup);
173 RELEASE_HERE(probe_state, probe_state); // The thread_service_t's reference to the probe state
185 probe_state_t *probe_state = context;
188 ntohs(probe_state->connection->address.sin6.sin6_port), message->wire.id, probe_state->question.id, rcode);
190 SEGMENTED_IPv6_ADDR_GEN_SRP(&probe_state->connection->address.sin6.sin6_addr, addr_buf);
192 SEGMENTED_IPv6_ADDR_PARAM_SRP(&probe_state->connection->address.sin6.sin6_addr, addr_buf),
193 ntohs(probe_state->connection->address.sin6.sin6_port), message->wire.id, probe_state->question.id, rcode);
195 if (message->wire.id != probe_state->question.id) {
210 ioloop_comm_cancel(probe_state->connection); // Cancel the connection (should result in the state being released)
211 if (probe_state->wakeup != NULL) {
212 ioloop_cancel_wake_event(probe_state->wakeup);
220 probe_state_t *probe_state = context;
221 RELEASE_HERE(probe_state, probe_state);
227 probe_state_t *probe_state = context;
230 // failed to connect. If we haven't signaled "done" yet, probe_state->service will be non-NULL.
231 if (probe_state->service != NULL) {
236 if (probe_state->connection != NULL) {
237 ioloop_comm_release(probe_state->connection);
238 probe_state->connection = NULL;
243 static void probe_srp_schedule_retransmission(probe_state_t *probe_state);
248 probe_state_t *probe_state = context;
251 probe_state->num_retransmissions++;
252 INFO("num_retransmissions = %d, time = %lg", probe_state->num_retransmissions, probe_state->retransmission_delay / 1000.0);
253 if (probe_state->num_retransmissions > 3) {
255 ioloop_comm_cancel(probe_state->connection);
258 probe_srp_schedule_retransmission(probe_state);
262 iov.iov_len = probe_state->question_length;
263 iov.iov_base = &probe_state->question;
264 ioloop_send_message(probe_state->connection, NULL, &iov, 1);
271 probe_state_t *probe_state = context;
272 RELEASE_HERE(probe_state, probe_state);
276 probe_srp_schedule_retransmission(probe_state_t *probe_state)
278 if (probe_state->wakeup == NULL) {
279 probe_state->wakeup = ioloop_wakeup_create();
280 if (probe_state->wakeup == NULL) {
282 probe_srp_done(probe_state, false);
283 ioloop_comm_cancel(probe_state->connection);
287 int next_time = probe_state->retransmission_delay + srp_random16() % probe_state->retransmission_delay;
288 probe_state->retransmission_delay *= 2;
289 ioloop_add_wake_event(probe_state->wakeup, probe_state, probe_srp_retransmit, probe_srp_context_release, next_time);
290 RETAIN_HERE(probe_state, probe_state); // The wakeup holds a reference to probe_state.
301 probe_state_t *probe_state = context;
303 memset(&probe_state->question, 0, DNS_HEADER_SIZE);
306 towire.p = &probe_state->question.data[0];
307 towire.lim = &probe_state->question.data[0] + DNS_DATA_SIZE;
308 towire.message = &probe_state->question;
311 probe_state->question.id = srp_random16();
312 probe_state->question.bitfield = 0;
313 dns_qr_set(&probe_state->question, dns_qr_query);
314 dns_opcode_set(&probe_state->question, dns_opcode_query);
315 probe_state->question.qdcount = htons(1); // Just ask one question
321 probe_state->question_length = (uint16_t)(towire.p - (uint8_t *)&probe_state->question);
324 probe_state->retransmission_delay = 1000; // milliseconds
325 probe_state->num_retransmissions = 0;
328 probe_srp_schedule_retransmission(probe_state);
337 probe_state_t *ret = NULL, *probe_state = calloc(1, sizeof(*probe_state));
338 if (probe_state == NULL) {
342 RETAIN_HERE(probe_state, probe_state); // Retain for the caller
344 probe_state->connection = ioloop_connection_create(address, false, false, false, false,
346 probe_srp_probe_state_context_release, probe_state);
347 if (probe_state->connection == NULL) {
351 RETAIN_HERE(probe_state, probe_state); // for connection
355 probe_state->context = context;
356 probe_state->callback = callback;
359 service->probe_state = probe_state;
360 RETAIN_HERE(service->probe_state, probe_state);
362 probe_state->service = service;
363 thread_service_retain(probe_state->service);
365 // connection holds the only reference to probe_state.
366 ret = probe_state;
367 probe_state = NULL;
369 if (probe_state != NULL) {
370 RELEASE_HERE(probe_state, probe_state);
417 probe_state_t *probe_state;
419 probe_state = probe_srp_unicast_service(service, context, callback, context_release);
421 probe_state = probe_srp_anycast_service(service, context, callback, context_release);
436 RELEASE_HERE(probe_state, probe_state);