void notify_timeout_cb(guint time) { time_t t = state_active_get_time_remain(); if (t < g_config.notify_time && t > 0) { if(!s_notified) { static gchar time_str[PATH_MAX]; struct tm* tm = localtime(&t); if(tm == NULL) { g_snprintf(time_str, sizeof(time_str), "%lu", (unsigned long)t); } else { strftime(time_str, sizeof(time_str), g_config.notify_format, tm); } notify_send(time_str, t); } } else { s_notified = FALSE; notify_close(); } }
/** * Handle notify. * */ static void notify_handle_zone(netio_type* ATTR_UNUSED(netio), netio_handler_type* handler, netio_events_type event_types) { notify_type* notify = NULL; xfrhandler_type* xfrhandler = NULL; zone_type* zone = NULL; if (!handler) { return; } notify = (notify_type*) handler->user_data; ods_log_assert(notify); xfrhandler = (xfrhandler_type*) notify->xfrhandler; zone = (zone_type*) notify->zone; ods_log_assert(xfrhandler); ods_log_assert(zone); ods_log_assert(zone->name); ods_log_debug("[%s] handle notify for zone %s", notify_str, zone->name); if (notify->is_waiting) { ods_log_debug("[%s] already waiting, skipping notify for zone %s", notify_str, zone->name); ods_log_assert(notify->handler.fd == -1); return; } if (event_types & NETIO_EVENT_READ) { ods_log_debug("[%s] read notify ok for zone %s", notify_str, zone->name); ods_log_assert(notify->handler.fd != -1); if (notify_udp_read_packet(notify)) { if (notify_handle_reply(notify)) { notify_next(notify); } } } else if(event_types & NETIO_EVENT_TIMEOUT) { ods_log_debug("[%s] notify timeout for zone %s", notify_str, zone->name); /* timeout, try again */ } /* see if notify is still enabled */ if (notify->secondary) { ods_log_assert(notify->secondary->address); notify->retry++; if (notify->retry > NOTIFY_MAX_RETRY) { ods_log_verbose("[%s] notify max retry for zone %s, %s unreachable", notify_str, zone->name, notify->secondary->address); notify_next(notify); } else { notify_send(notify); } } return; }
static void notify_each_addr4(uint32_t addr, uint32_t mask, void *zone_name) { struct sockaddr_in sin; if (mask != 0xffffffff) return; memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(addr); sin.sin_port = htons(DNS_PORT); /* XXX sin_len? */ if (notify_send((SA *) &sin, zone_name) < 0) { plog(LOG_ERR, "%s: dns_notify_send() failed", MODULE); return; } }