static void _vala_clear_GRWLock (GRWLock * mutex) { GRWLock zero_mutex = { 0 }; if (memcmp (mutex, &zero_mutex, sizeof (GRWLock))) { g_rw_lock_clear (mutex); memset (mutex, 0, sizeof (GRWLock)); } }
/** * free the data-structures for a event-thread * * joins the event-thread, closes notification-pipe and free's the event-base */ void chassis_event_thread_free(chassis_event_thread_t *thread) { if (!thread) return; if (thread->thr) g_thread_join(thread->thr); if (thread->notify_receive_fd != -1) { event_del(&(thread->notify_fd_event)); closesocket(thread->notify_receive_fd); } if (thread->notify_send_fd != -1) { closesocket(thread->notify_send_fd); } /* we don't want to free the global event-base */ if (thread->thr != NULL && thread->event_base) event_base_free(thread->event_base); network_mysqld_con* con = NULL; while ((con = g_async_queue_try_pop(thread->event_queue))) { network_mysqld_con_free(con); } g_atomic_pointer_set(&(thread->thread_status_var.thread_stat[THREAD_STAT_EVENT_WAITING]), 0); g_async_queue_unref(thread->event_queue); g_rw_lock_clear(&thread->connection_lock); if (thread->connection_list != NULL) { g_list_free_full(thread->connection_list, (GDestroyNotify)network_mysqld_con_free); } g_free(thread); }
void drew_loader_unref(DrewLoader *ldr) { g_return_if_fail(ldr); if (g_atomic_int_dec_and_test(&ldr->ref_count)) { g_rw_lock_clear(&ldr->lock); for (int i = 0; i < ldr->nlibs; i++) { g_free(ldr->lib[i].name); g_free(ldr->lib[i].path); close_library(ldr->lib[i].handle); } g_free(ldr->lib); for (int i = 0; i < ldr->nplugins; i++) { if (!(ldr->plugin[i].flags & FLAG_PLUGIN_OK)) continue; g_free(ldr->plugin[i].name); g_free(ldr->plugin[i].functbl); g_free(ldr->plugin[i].metadata); } g_free(ldr->plugin); g_free(ldr); } return; }
/** * free all entries of the pool * */ void network_connection_pool_free(network_connection_pool *pool) { if (!pool) return; g_hash_table_foreach_remove(pool->users, g_hash_table_true, NULL); g_mutex_lock(&(pool->connection_pool_mutex)); g_hash_table_destroy(pool->users); g_mutex_unlock(&(pool->connection_pool_mutex)); g_mutex_clear(&(pool->connection_pool_mutex)); // added by sohu-inc.com g_rw_lock_writer_lock(&pool->pool_status_lock); g_hash_table_destroy(pool->conn_pool_status); g_rw_lock_writer_unlock(&pool->pool_status_lock); g_rw_lock_clear(&pool->pool_status_lock); // g_hash_table_destroy(pool->conn_num_in_use); // g_hash_table_destroy(pool->conn_pending); if (pool->garbage_connection_pool != NULL) { garbage_connection_pool_free(pool->garbage_connection_pool); pool->garbage_connection_pool = NULL; } g_free(pool); }
static void test_rwlock (void) { GRWLock lock; g_rw_lock_init (&lock); g_rw_lock_clear (&lock); }
/* * refstore_free */ void refstore_free ( refstore *rs ) { refstore_clear ( rs, TRUE ); g_free ( rs->path ); g_rw_lock_clear ( &(rs->lock) ); g_free ( rs ); }
/* * view_free */ void view_free ( view *v ) { g_free ( v->current_line ); g_free ( v->current_line_most_recent_data ); vblocks_list_clear ( v->blocks_head ); g_rw_lock_clear ( &(v->lock) ); g_free ( v ); }
void sql_filter_free(sql_filter *filter) { if (filter == NULL) return ; g_hash_table_remove_all(filter->blacklist); g_hash_table_destroy(filter->blacklist); g_rw_lock_clear(&filter->sql_filter_lock); g_free(filter->blacklist_file); g_free(filter); return ; }
static void test_rwlock1 (void) { GRWLock lock; g_rw_lock_init (&lock); g_rw_lock_writer_lock (&lock); g_rw_lock_writer_unlock (&lock); g_rw_lock_writer_lock (&lock); g_rw_lock_writer_unlock (&lock); g_rw_lock_clear (&lock); }
static void fu_mutex_finalize (GObject *obj) { FuMutex *self = FU_MUTEX (obj); g_rw_lock_clear (&self->rw_lock); #ifdef FU_MUTEX_DEBUG g_free (self->id); g_string_free (self->reader, TRUE); g_string_free (self->writer, TRUE); #endif G_OBJECT_CLASS (fu_mutex_parent_class)->finalize (obj); }
static void _schedulerpolicyhoststeal_free(SchedulerPolicy* policy) { MAGIC_ASSERT(policy); HostStealPolicyData* data = policy->data; g_hash_table_destroy(data->hostToQueueDataMap); g_hash_table_destroy(data->threadToThreadDataMap); g_hash_table_destroy(data->hostToThreadMap); g_rw_lock_clear(&data->lock); g_free(data); MAGIC_CLEAR(policy); g_free(policy); }
/** * user_db_sql_rule_table内存释放函数 * @param table user_db_sql_rule_table规则列表 */ void user_db_sql_rule_table_free( user_db_sql_rule_table *table) { if (NULL == table) { return; } g_rw_lock_writer_lock(&table->table_lock[SQL_SINGLE]); g_hash_table_destroy(table->user_db_sql_rule[SQL_SINGLE]); table->user_db_sql_rule[SQL_SINGLE] = NULL; g_rw_lock_writer_unlock(&table->table_lock[SQL_SINGLE]); g_rw_lock_clear(&table->table_lock[SQL_SINGLE]); g_rw_lock_writer_lock(&table->table_lock[SQL_TEMPLATE]); g_hash_table_destroy(table->user_db_sql_rule[SQL_TEMPLATE]); table->user_db_sql_rule[SQL_TEMPLATE] = NULL; g_rw_lock_writer_unlock(&table->table_lock[SQL_TEMPLATE]); g_rw_lock_clear(&table->table_lock[SQL_TEMPLATE]); g_free(table); }
/** * db sql规则列表的销毁 * @param table 要被销毁的db sql规则列表的指针 */ void db_sql_rule_table_free(db_sql_rule_table *table) { if (NULL == table) { return; } g_rw_lock_writer_lock(&table->table_lock); g_hash_table_destroy(table->db_sql_rule); table->db_sql_rule = NULL; g_rw_lock_writer_unlock(&table->table_lock); g_rw_lock_clear(&table->table_lock); g_free(table); }
void meta0_backend_clean(struct meta0_backend_s *m0) { if (!m0) return; oio_str_clean (&m0->ns); oio_str_clean (&m0->id); if (m0->array_by_prefix) meta0_utils_array_clean(m0->array_by_prefix); if (m0->array_meta1_ref) meta0_utils_array_meta1ref_clean(m0->array_meta1_ref); g_rw_lock_clear (&m0->rwlock); g_free(m0); }
void sql_reserved_query_free(sql_reserved_query *srq) { if (srq == NULL) return ; g_hash_table_remove_all(srq->ht_reserved_query); g_hash_table_destroy(srq->ht_reserved_query); g_queue_free(srq->gq_reserved_long_query); g_queue_free(srq->gq_reserved_short_query); g_rw_lock_clear(&srq->rq_lock); g_free(srq); }
static void _shadowtorpreload_cryptoTeardown() { G_LOCK(shadowtorpreloadPrimaryLock); if(shadowtorpreloadGlobalState.initialized && shadowtorpreloadGlobalState.cryptoThreadLocks && --shadowtorpreloadGlobalState.nThreads == 0) { for(int i = 0; i < shadowtorpreloadGlobalState.numCryptoThreadLocks; i++) { g_rw_lock_clear(&(shadowtorpreloadGlobalState.cryptoThreadLocks[i])); } g_free(shadowtorpreloadGlobalState.cryptoThreadLocks); shadowtorpreloadGlobalState.cryptoThreadLocks = NULL; shadowtorpreloadGlobalState.initialized = 0; } G_UNLOCK(shadowtorpreloadPrimaryLock); }
void slow_query_log_config_t_free(slow_query_log_config_t *config) { if (config != NULL) { g_rw_lock_writer_lock( &(config->rwlock) ); config->is_enabled = FALSE; if (config->log_file != NULL) { slow_query_log_file_t_free(config->log_file); config->log_file = NULL; } if (config->filter != NULL) { slow_query_log_filter_t_free(config->filter); config->filter = NULL; } g_rw_lock_writer_unlock( &(config->rwlock) ); g_rw_lock_clear( &(config->rwlock) ); g_free(config); } return; }
JS_EXPORT_API void dock_emit_webview_ok() { static gboolean inited = FALSE; if (!inited) { if (!is_compiz_plugin_valid()) { gtk_widget_hide(container); GtkWidget* dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Dock failed to start" ", because " "Compiz is not " "enabled.")); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); exit(2); } inited = TRUE; init_config(); } g_warning("[%s]", __func__); GRWLock lock; g_rw_lock_init(&lock); // non-static GRWLock must init and clear. g_rw_lock_writer_lock(&lock); update_primary_info(&dock); g_rw_lock_writer_unlock(&lock); g_rw_lock_clear(&lock); _update_dock_size(dock.x, dock.y, dock.width, dock.height); gtk_widget_show_all(container); GD.is_webview_loaded = TRUE; if (GD.config.hide_mode == ALWAYS_HIDE_MODE) { // dock_hide_now(); } else { } dde_session_register(); }
static void test_rwlock7 (void) { gint i; GThread *threads[THREADS]; for (i = 0; i < LOCKS; i++) g_rw_lock_init (&locks[i]); for (i = 0; i < THREADS; i++) threads[i] = g_thread_new ("test", thread_func, NULL); for (i = 0; i < THREADS; i++) g_thread_join (threads[i]); for (i = 0; i < LOCKS; i++) g_rw_lock_clear (&locks[i]); for (i = 0; i < LOCKS; i++) g_assert (owners[i] == NULL); }
/* Internal: */ void dupin_attachment_db_disconnect (DupinAttachmentDB * attachment_db) { g_return_if_fail (attachment_db != NULL); #if DEBUG g_message("dupin_attachment_db_disconnect: total number of changes for '%s' attachments database: %d\n", attachment_db->name, (gint)sqlite3_total_changes (attachment_db->db)); #endif if (attachment_db->db) sqlite3_close (attachment_db->db); if (attachment_db->todelete == TRUE) g_unlink (attachment_db->path); if (attachment_db->name) g_free (attachment_db->name); if (attachment_db->path) g_free (attachment_db->path); if (attachment_db->parent) g_free (attachment_db->parent); if (attachment_db->rwlock) { g_rw_lock_clear (attachment_db->rwlock); g_free (attachment_db->rwlock); } if (attachment_db->error_msg) g_free (attachment_db->error_msg); if (attachment_db->warning_msg) g_free (attachment_db->warning_msg); g_free (attachment_db); }
/* This test has 2 writers and 10 readers. * The writers modify an integer multiple times, * but always leave it with an even value. * The readers verify that they can only observe * even values */ static void test_rwlock8 (void) { gint i; even = 0; g_rw_lock_init (&even_lock); for (i = 0; i < 2; i++) writers[i] = g_thread_new ("a", writer_func, GINT_TO_POINTER (i)); for (i = 0; i < 10; i++) readers[i] = g_thread_new ("b", reader_func, NULL); for (i = 0; i < 2; i++) g_thread_join (writers[i]); for (i = 0; i < 10; i++) g_thread_join (readers[i]); g_assert (even % 2 == 0); g_rw_lock_clear (&even_lock); }