/** Revisa que la celda cumpla las condiciones establecidas */ bool zone_check(Zone* zone) { for(int i = 0; i < zone -> building_count; i++) { if(!client_check(zone -> buildings[i])) return false; } return true; }
void doit(void) { server_check(); reset_buffers(); client_check(); if (g_pcert) { gnutls_pcert_deinit(g_pcert); gnutls_free(g_pcert); } if (g_pkey) { gnutls_privkey_deinit(g_pkey); } }
static exports get_exportlist(void) { static exports elist = NULL; struct exportnode *e, *ne; struct groupnode *g, *ng, *c, **cp; nfs_export *exp; int i; static unsigned int ecounter; unsigned int acounter; acounter = auth_reload(); if (elist && acounter == ecounter) return elist; ecounter = acounter; for (e = elist; e != NULL; e = ne) { ne = e->ex_next; for (g = e->ex_groups; g != NULL; g = ng) { ng = g->gr_next; xfree(g->gr_name); xfree(g); } xfree(e->ex_dir); xfree(e); } elist = NULL; for (i = 0; i < MCL_MAXTYPES; i++) { for (exp = exportlist[i].p_head; exp; exp = exp->m_next) { for (e = elist; e != NULL; e = e->ex_next) { if (!strcmp(exp->m_export.e_path, e->ex_dir)) break; } if (!e) { e = (struct exportnode *) xmalloc(sizeof(*e)); e->ex_next = elist; e->ex_groups = NULL; e->ex_dir = xstrdup(exp->m_export.e_path); elist = e; } /* We need to check if we should remove previous ones. */ if (i == MCL_ANONYMOUS && e->ex_groups) { for (g = e->ex_groups; g; g = ng) { ng = g->gr_next; xfree(g->gr_name); xfree(g); } e->ex_groups = NULL; continue; } if (i != MCL_FQDN && e->ex_groups) { struct hostent *hp; cp = &e->ex_groups; while ((c = *cp) != NULL) { if (client_gettype (c->gr_name) == MCL_FQDN && (hp = gethostbyname(c->gr_name))) { hp = hostent_dup (hp); if (client_check(exp->m_client, hp)) { *cp = c->gr_next; xfree(c->gr_name); xfree(c); xfree (hp); continue; } xfree (hp); } cp = &(c->gr_next); } } if (exp->m_export.e_hostname [0] != '\0') { for (g = e->ex_groups; g; g = g->gr_next) if (strcmp (exp->m_export.e_hostname, g->gr_name) == 0) break; if (g) continue; g = (struct groupnode *) xmalloc(sizeof(*g)); g->gr_name = xstrdup(exp->m_export.e_hostname); g->gr_next = e->ex_groups; e->ex_groups = g; } } } return elist; }
bool ipaddr_client_matches(nfs_export *exp, struct addrinfo *ai) { return client_check(exp->m_client, ai); }
int client_main(struct server_info **info_ary, int count) { struct server_info *best_off; struct server_info *best_freq; double last_freq; double freq; double offset; int calc_offset_correction; int didreconnect; int i; int insane; last_freq = 0.0; for (;;) { /* * Subtract the interval from poll_sleep and poll the client * if it reaches 0. * * Because we do not compensate for offset corrections which are * in progress, we cannot accumulate data for an offset correction * while a prior correction is still being worked through by the * system. */ calc_offset_correction = !sysntp_offset_correction_is_running(); for (i = 0; i < count; ++i) client_poll(info_ary[i], min_sleep_opt, calc_offset_correction); /* * Find the best client (or synthesize one). A different client * can be chosen for frequency and offset. Note in particular * that offset counters and averaging code gets reset when an * offset correction is made (otherwise the averaging history will * cause later corrections to overshoot). * * The regression used to calculate the frequency is a much * longer-term entity and is NOT reset, so it is still possible * for the offset correction code to make minor adjustments to * the frequency if it so desires. * * client_check may replace the server_info pointer with a new * one. */ best_off = NULL; best_freq = NULL; for (i = 0; i < count; ++i) client_check(&info_ary[i], &best_off, &best_freq); /* * Check for server insanity. In large NNTP pools some servers * may just be dead wrong, but report that they are right. */ if (best_off) { insane = client_insane(info_ary, count, best_off); if (insane > 0) { /* * best_off meets the quorum requirements and is good * (keep best_off) */ best_off->server_insane = 0; } else if (insane == 0) { /* * best_off is probably good, but we do not have enough * servers reporting yet to meet the quorum requirements. */ best_off = NULL; } else { /* * best_off is ugly, mark the server as being insane for * 60 minutes. */ best_off->server_insane = 60 * 60; logdebuginfo(best_off, 1, "excessive offset deviation, mapping out\n"); best_off = NULL; } } /* * Offset correction. */ if (best_off) { offset = best_off->lin_sumoffset / best_off->lin_countoffset; lin_resetalloffsets(info_ary, count); if (offset < -COURSE_OFFSET_CORRECTION_LIMIT || offset > COURSE_OFFSET_CORRECTION_LIMIT || quickset_opt ) { freq = sysntp_correct_course_offset(offset); quickset_opt = 0; } else { freq = sysntp_correct_offset(offset); } } else { freq = 0.0; } /* * Frequency correction (throw away minor freq adjusts from the * offset code if we can't do a frequency correction here). Do * not reissue if it hasn't changed from the last issued correction. */ if (best_freq) { freq += best_freq->lin_cache_freq; if (last_freq != freq) { sysntp_correct_freq(freq); last_freq = freq; } } /* * This function is responsible for managing the polling mode and * figures out how long we should sleep. */ didreconnect = 0; for (i = 0; i < count; ++i) client_manage_polling_mode(info_ary[i], &didreconnect); if (didreconnect) client_check_duplicate_ips(info_ary, count); /* * Polling loop sleep. */ usleep(min_sleep_opt * 1000000 + random() % 500000); } }
void doit(void) { server_check(); client_check(); }