Пример #1
0
/*!
  \brief Frees up any resources of the plugin
  */
G_MODULE_EXPORT void plugin_shutdown()
{
	ENTER();
	deregister_common_enums();
	EXIT();
	return;
}
Пример #2
0
G_MODULE_EXPORT void plugin_shutdown()
{
    GThread *thread = NULL;
    GCond *cond = NULL;
    GAsyncQueue *queue = NULL;
    GHashTable *hash = NULL;
    GMutex *mutex = NULL;
    gint id = 0;

    freeems_serial_disable();

    thread = DATA_GET(global_data,"packet_handler_thread");
    if (thread)
    {
        DATA_SET(global_data,"packet_handler_thread_exit",GINT_TO_POINTER(TRUE));
        g_thread_join(thread);
        DATA_SET(global_data,"packet_handler_thread",NULL);
        DATA_SET(global_data,"packet_handler_thread_exit",NULL);
    }
    queue = DATA_GET(global_data,"burn_queue");
    if (queue)
    {
        deregister_packet_queue(PAYLOAD_ID,queue,RESPONSE_BURN_BLOCK_FROM_RAM_TO_FLASH);
        g_async_queue_unref(queue);
        DATA_SET(global_data,"burn_queue",NULL);
        queue = NULL;
    }
    queue = DATA_GET(global_data,"FLASH_write_queue");
    if (queue)
    {
        deregister_packet_queue(PAYLOAD_ID,queue,RESPONSE_REPLACE_BLOCK_IN_FLASH);
        g_async_queue_unref(queue);
        DATA_SET(global_data,"FLASH_write_queue",NULL);
        queue = NULL;
    }
    queue = DATA_GET(global_data,"RAM_write_queue");
    if (queue)
    {
        deregister_packet_queue(PAYLOAD_ID,queue,RESPONSE_UPDATE_BLOCK_IN_RAM);
        g_async_queue_unref(queue);
        DATA_SET(global_data,"RAM_write_queue",NULL);
        queue = NULL;
    }
    queue = DATA_GET(global_data,"packet_queue");
    if (queue)
    {
        g_async_queue_unref(queue);
        DATA_SET(global_data,"packet_queue",NULL);
        queue = NULL;
    }
    hash = DATA_GET(global_data,"payload_id_queue_hash");
    if (hash)
        g_hash_table_destroy(hash);
    hash = NULL;
    DATA_SET(global_data,"payload_id_queue_hash",NULL);

    hash = DATA_GET(global_data,"sequence_num_queue_hash");
    if (hash)
        g_hash_table_destroy(hash);
    hash = NULL;
    DATA_SET(global_data,"sequence_num_queue_hash",NULL);

    cond = DATA_GET(global_data,"packet_handler_cond");
    if (cond)
        g_cond_free(cond);
    cond = NULL;
    DATA_SET(global_data,"packet_handler_cond",NULL);
    cond = DATA_GET(global_data,"serial_reader_cond");
    if (cond)
        g_cond_free(cond);
    cond = NULL;
    DATA_SET(global_data,"serial_reader_cond",NULL);
    mutex = DATA_GET(global_data,"queue_mutex");
    if (mutex)
        g_mutex_free(mutex);
    DATA_SET(global_data,"queue_mutex",NULL);

    deregister_common_enums();
    return;
}