/* This is similar to yp_remove, but we force a touch * attempt */ void yp_touch (const char *mount) { struct yp_server *server = (struct yp_server *)active_yps; time_t trigger; ypdata_t *search_list = NULL; thread_rwlock_rlock (&yp_lock); /* do update in 3 secs, give stats chance to update */ trigger = time(NULL) + 3; if (server) search_list = server->mounts; while (server) { ypdata_t *yp = find_yp_mount (search_list, mount); if (yp) { /* we may of found old entries not purged yet, so skip them */ if (yp->release != 0 || yp->remove != 0) { search_list = yp->next; continue; } /* only force if touch */ if (yp->process == do_yp_touch) yp->next_update = trigger; } server = server->next; if (server) search_list = server->mounts; } thread_rwlock_unlock (&yp_lock); }
/* Mark an existing entry in the YP list as to be marked for deletion */ void yp_remove (const char *mount) { struct yp_server *server = (struct yp_server *)active_yps; thread_rwlock_rlock (&yp_lock); while (server) { ypdata_t *list = server->mounts; while (1) { ypdata_t *yp = find_yp_mount (list, mount); if (yp == NULL) break; if (yp->release || yp->remove) { list = yp->next; continue; /* search again these are old entries */ } DEBUG2 ("release %s on YP %s", mount, server->url); yp->release = 1; yp->next_update = 0; yp_update = 1; } server = server->next; } thread_rwlock_unlock (&yp_lock); }
/* This is similar to yp_remove, but we force a touch * attempt */ void yp_touch (const char *mount) { struct yp_server *server = (struct yp_server *)active_yps; ypdata_t *search_list = NULL; thread_rwlock_rlock (&yp_lock); if (server) search_list = server->mounts; while (server) { ypdata_t *yp = find_yp_mount (search_list, mount); if (yp) { /* we may of found old entries not purged yet, so skip them */ if (yp->release != 0 || yp->remove != 0) { search_list = yp->next; continue; } /* don't update the directory if there is a touch scheduled soon */ if (yp->process == do_yp_touch && now + yp->touch_interval - yp->next_update > 60) yp_schedule (yp, 0); } server = server->next; if (server) search_list = server->mounts; } thread_rwlock_unlock (&yp_lock); }
/* Mark an existing entry in the YP list as to be marked for deletion */ void yp_remove (const char *mount) { struct yp_server *server = (struct yp_server *)active_yps; thread_rwlock_rlock (&yp_lock); while (server) { ypdata_t *yp = find_yp_mount (server->mounts, mount); if (yp) { DEBUG2 ("release %s on YP %s", mount, server->url); yp->release = 1; yp->next_update = 0; } server = server->next; } thread_rwlock_unlock (&yp_lock); }
/* Add YP entries to active servers */ void yp_add (const char *mount) { struct yp_server *server; /* make sure YP thread is not modifying the lists */ thread_rwlock_rlock (&yp_lock); /* make sure we don't race against another yp_add */ thread_mutex_lock (&yp_pending_lock); server = (struct yp_server *)active_yps; while (server) { ypdata_t *yp; /* on-demand relays may already have a YP entry */ yp = find_yp_mount (server->mounts, mount); if (yp == NULL) { /* add new ypdata to each servers pending yp */ yp = create_yp_entry (mount); if (yp) { DEBUG2 ("Adding %s to %s", mount, server->url); yp->server = server; yp->touch_interval = server->touch_interval; yp->next = server->pending_mounts; yp->next_update = time(NULL) + 5; server->pending_mounts = yp; yp_update = 1; } } else DEBUG1 ("YP entry %s already exists", mount); server = server->next; } thread_mutex_unlock (&yp_pending_lock); thread_rwlock_unlock (&yp_lock); }