void namespace_info_reset(namespace_info_t *ni) { if (ni == NULL) return; namespace_info_clear(ni); namespace_info_init(ni); }
void namespace_info_free(namespace_info_t* ns_info) { if (ns_info == NULL) return; namespace_info_clear(ns_info); g_free(ns_info); }
static int parse_namespace_info(worker_t *worker, GError **error) { gchar *ns_name; asn1_session_t *asn1_session; namespace_data_t *ns_data; namespace_info_t *ns_info = NULL; asn1_session = asn1_worker_get_session(worker); ns_name = asn1_worker_get_session_data(worker); if (!ns_name || !asn1_session) { GSETERROR(error,"Invalid worker : no session data"); return 0; } ns_data = g_hash_table_lookup(namespaces,ns_name); if (!ns_data) { GSETERROR(error,"Namespace '%s' does not exist", ns_name); return 0; } if (asn1_session->resp_body != NULL) { ns_info = namespace_info_unmarshall(asn1_session->resp_body, asn1_session->resp_body_size, error); if (ns_info == NULL) { GSETERROR(error, "Failed to unmarshall namespace_info from ASN1 data"); return 0; } memcpy(&(ns_info->addr), &(ns_data->ns_info.addr), sizeof(addr_info_t)); /* Check that we have the same name */ if (strcmp(ns_info->name, ns_data->name)) { ERROR("Namespace name [%s] in /etc/gridstorage does not match name [%s] in conscience !", ns_data->name, ns_info->name); namespace_info_free(ns_info); return(0); } DEBUG("Infos of namespace [%s] updated with value name [%s] / chunk_size[%"G_GINT64_FORMAT"]", ns_data->ns_info.name, ns_info->name, ns_info->chunk_size); namespace_info_clear(&(ns_data->ns_info)); namespace_info_copy(ns_info, &(ns_data->ns_info)); namespace_info_free(ns_info); /* Flag namespace if it's the first config */ ns_data->configured = TRUE; } return(1); }
enum http_rc_e action_cs_info (struct req_args_s *args) { GError *err; if (NULL != (err = _cs_check_tokens(args))) return _reply_notfound_error (args, err); struct namespace_info_s ni; memset (&ni, 0, sizeof (ni)); NSINFO_DO(namespace_info_copy (&nsinfo, &ni, NULL)); GString *gstr = g_string_new (""); namespace_info_encode_json (gstr, &ni); namespace_info_clear (&ni); return _reply_success_json (args, gstr); }
static gs_error_t * _dl_nocache(gs_container_t *c, struct hc_url_s *url, gs_download_info_t *dlinfo, gchar *stgpol) { gs_error_t *e = NULL; GError *err = NULL; gs_content_t *content = NULL; namespace_info_t *ni = NULL; GSList *filtered = NULL, *beans = NULL; /*find the content*/ content = gs_get_content_from_path_full(c, hc_url_get(url, HCURL_PATH), hc_url_get(url, HCURL_SNAPORVERS), &filtered, &beans, &e); if(NULL != content) { GRID_DEBUG("Content %s found in container %s\n", hc_url_get(url, HCURL_PATH), hc_url_get(url, HCURL_REFERENCE)); ni = get_namespace_info(hc_url_get(url, HCURL_NS), &err); if (!ni) { GSERRORCAUSE(&e, err, "Cannot get namespace info for NS [%s]", hc_url_get(url, HCURL_NS)); g_clear_error(&err); return e; } namespace_info_copy(ni, &(content->info.container->info.gs->ni), &err); /*download the content*/ (void) gs_download_content_full (content, dlinfo, stgpol, filtered, beans, &e); namespace_info_clear(ni); g_free(ni); gs_content_free (content); g_slist_free(filtered); _bean_cleanl2(beans); return e; } g_printerr("'%s' not found in '%s'\n", hc_url_get(url, HCURL_PATH), hc_url_get(url, HCURL_REFERENCE)); return e; }
void conscience_destroy(struct conscience_s *conscience) { if (!conscience) return; g_static_rw_lock_free(&(conscience->rwlock_srv)); if (conscience->srvtypes) g_hash_table_destroy(conscience->srvtypes); if (conscience->default_srvtype) conscience_srvtype_destroy(conscience->default_srvtype); namespace_info_clear(&conscience->ns_info); memset(conscience, 0x00, sizeof(struct conscience_s)); g_free(conscience); }
static struct storage_policy_s * _init_storage_policy(const char *ns, const char *polname) { namespace_info_t *ni = NULL; GError *e = NULL; struct storage_policy_s *sp =NULL; ni = get_namespace_info(ns, &e); if(NULL != e) { GRID_ERROR("Failed to get namespace info : %s", e->message); g_clear_error(&e); return NULL; } sp = storage_policy_init(ni, polname); namespace_info_clear(ni); g_free(ni); return sp; }