int cl_endpoint_list_cleanup(cl_raw_list_t** list_p) { cl_endpoint_list_data_t* ldata = NULL; cl_endpoint_list_elem_t* elem = NULL; if (list_p == NULL) { /* we expect an address of an pointer */ return CL_RETVAL_PARAMS; } if (*list_p == NULL) { /* we expect an initalized pointer */ return CL_RETVAL_PARAMS; } /* delete all entries in list */ cl_raw_list_lock(*list_p); while ( (elem = cl_endpoint_list_get_first_elem(*list_p)) != NULL) { cl_raw_list_remove_elem(*list_p, elem->raw_elem); cl_com_free_endpoint(&(elem->endpoint)); sge_free(&elem); } cl_raw_list_unlock(*list_p); /* clean list private data */ ldata = (*list_p)->list_data; if (ldata != NULL) { if (ldata->ht != NULL) { sge_htable_destroy(ldata->ht); } sge_free(&ldata); } (*list_p)->list_data = NULL; return cl_raw_list_cleanup(list_p); }
int cl_endpoint_list_undefine_endpoint(cl_raw_list_t* list_p, cl_com_endpoint_t* endpoint) { int back = CL_RETVAL_UNKNOWN_ENDPOINT; int ret_val = CL_RETVAL_OK; cl_endpoint_list_elem_t* elem = NULL; if (list_p == NULL || endpoint == NULL) { return CL_RETVAL_PARAMS; } /* lock list */ if ( (ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) { return ret_val; } elem = cl_endpoint_list_get_elem_endpoint(list_p, endpoint); if (elem && elem->is_static == false) { cl_endpoint_list_data_t* ldata = NULL; cl_raw_list_remove_elem(list_p, elem->raw_elem); cl_com_free_endpoint(&(elem->endpoint)); sge_free(&elem); ldata = list_p->list_data; if (ldata->ht != NULL) { sge_htable_delete(ldata->ht, endpoint->hash_id); } back = CL_RETVAL_OK; } /* unlock list */ if ( (ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) { return ret_val; } return back; }
int cl_host_alias_list_cleanup(cl_raw_list_t** list_p) { cl_host_alias_list_elem_t* elem = NULL; int ret_val = CL_RETVAL_OK; if (list_p == NULL) { /* we expect an address of an pointer */ return CL_RETVAL_PARAMS; } if (*list_p == NULL) { /* we expect an initalized pointer */ return CL_RETVAL_PARAMS; } /* delete all entries in list */ cl_raw_list_lock(*list_p); while ( (elem = cl_host_alias_list_get_first_elem(*list_p)) != NULL) { cl_raw_list_remove_elem(*list_p, elem->raw_elem); sge_free(&(elem->local_resolved_hostname)); sge_free(&(elem->alias_name)); sge_free(&elem); } cl_raw_list_unlock(*list_p); ret_val = cl_raw_list_cleanup(list_p); CL_LOG(CL_LOG_INFO,"host alias cleanup done"); return ret_val; }
int cl_fd_list_unregister_fd(cl_raw_list_t* list_p, cl_fd_list_elem_t* elem, int lock_list) { int ret_val = CL_RETVAL_OK; if (list_p == NULL || elem == NULL) { return CL_RETVAL_PARAMS; } if (lock_list != 0) { /* lock list */ if ((ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) { return ret_val; } } cl_raw_list_remove_elem(list_p, elem->raw_elem); sge_free(&(elem->data)); sge_free(&elem); if (lock_list != 0) { /* unlock list */ if ((ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) { return ret_val; } } return ret_val; }
int cl_app_message_queue_remove(cl_raw_list_t* list_p, cl_com_connection_t* connection, int do_lock, cl_bool_t remove_all_elements ) { int function_return = CL_RETVAL_CONNECTION_NOT_FOUND; int ret_val = CL_RETVAL_OK; cl_app_message_queue_elem_t* elem = NULL; cl_app_message_queue_elem_t* next_elem = NULL; if (list_p == NULL || connection == NULL) { return CL_RETVAL_PARAMS; } /* lock list */ if (do_lock != 0) { if ( (ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) { return ret_val; } } elem = cl_app_message_queue_get_first_elem(list_p); while ( elem != NULL) { next_elem = cl_app_message_queue_get_next_elem(elem); if (elem->rcv_connection == connection) { /* found matching element */ cl_raw_list_remove_elem(list_p, elem->raw_elem); sge_free(&elem); function_return = CL_RETVAL_OK; if (remove_all_elements == CL_FALSE) { break; /* break here, we don't want to remove all elems */ } } elem = next_elem; } /* unlock the thread list */ if (do_lock != 0) { if ( ( ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) { return ret_val; } } return function_return; }
int cl_host_list_remove_host(cl_raw_list_t* list_p, cl_com_host_spec_t* host, int lock_list) { int ret_val = CL_RETVAL_OK; int function_return = CL_RETVAL_UNKOWN_HOST_ERROR; cl_host_list_elem_t* elem = NULL; if (list_p == NULL || host == NULL) { return CL_RETVAL_PARAMS; } if (lock_list != 0) { /* lock list */ if ( (ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) { return ret_val; } } elem = cl_host_list_get_elem_host(list_p, host->unresolved_name); if (elem != NULL) { /* remove element from hash table */ if (host->unresolved_name != NULL) { cl_host_list_data_t* ldata = list_p->list_data; if (ldata->ht != NULL) { sge_htable_delete(ldata->ht, host->unresolved_name); } } cl_raw_list_remove_elem(list_p, elem->raw_elem); function_return = CL_RETVAL_OK; cl_com_free_hostspec(&(elem->host_spec)); free(elem); } if (lock_list != 0) { /* unlock list */ if ((ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) { return ret_val; } } return function_return; }
int cl_host_alias_list_remove_host(cl_raw_list_t* list_p, cl_host_alias_list_elem_t* element, int lock_list) { cl_host_alias_list_elem_t* elem = NULL; int ret_val = CL_RETVAL_OK; int function_return = CL_RETVAL_UNKNOWN; if ( list_p == NULL || element == NULL) { return CL_RETVAL_PARAMS; } if (lock_list != 0) { /* lock list */ if ( (ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) { return ret_val; } } elem = cl_host_alias_list_get_first_elem(list_p); while ( elem != NULL) { if (elem == element) { /* found matching element */ cl_raw_list_remove_elem(list_p, elem->raw_elem); function_return = CL_RETVAL_OK; sge_free(&(elem->local_resolved_hostname)); sge_free(&(elem->alias_name)); sge_free(&elem); elem = NULL; break; } elem = cl_host_alias_list_get_next_elem(elem); } if (lock_list != 0) { /* unlock list */ if ( (ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) { return ret_val; } } return function_return; }
int cl_message_list_remove_message(cl_raw_list_t* list_p, cl_com_message_t* message, int lock_list) { /*CR check */ int function_return = CL_RETVAL_CONNECTION_NOT_FOUND; int ret_val = CL_RETVAL_OK; cl_message_list_elem_t* elem = NULL; if (list_p == NULL || message == NULL) { return CL_RETVAL_PARAMS; } if (lock_list != 0) { /* lock list */ if ( (ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) { return ret_val; } } elem = cl_message_list_get_first_elem(list_p); while ( elem != NULL) { if (elem->message == message) { /* found matching element */ gettimeofday(&(message->message_remove_time),NULL); function_return = CL_RETVAL_OK; cl_raw_list_remove_elem(list_p, elem->raw_elem); sge_free(&elem); break; } elem = cl_message_list_get_next_elem(elem); } if (lock_list != 0) { /* unlock list */ if ( (ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) { return ret_val; } } return function_return; }
int main(int argc, char **argv) { int test = 1; int my_error = 0; cl_raw_list_t* list = NULL; cl_raw_list_t* log_list = NULL; my_error = cl_log_list_setup(&log_list, "test_dummy", 0, CL_LOG_FLUSHED , NULL); printf("log list setup: %s\n", cl_get_error_text(my_error)); cl_log_list_set_log_level(log_list,CL_LOG_DEBUG); cl_raw_list_setup(&list, "dummy_list",1); cl_raw_list_append_elem( list , (void*) &test); printf("list entries: %ld\n", cl_raw_list_get_elem_count(list)); my_error = CL_LOG(CL_LOG_INFO,"hallo"); printf("log: %s\n", cl_get_error_text(my_error)); printf("log list entries: %ld\n", cl_raw_list_get_elem_count(log_list)); cl_raw_list_remove_elem( list , cl_raw_list_search_elem( list, (void*) &test) ); printf("list entries: %ld\n", cl_raw_list_get_elem_count(list)); my_error = cl_raw_list_cleanup(&list); if ( my_error != CL_RETVAL_OK) { printf("error cl_raw_list_cleanup() -> %s\n", cl_get_error_text(my_error)); exit(1); } while (argc>1) { dummy(argv[argc-1]); argc--; } cl_log_list_cleanup(&log_list); return 0; }