Commit 6c3be854 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Update: Migrated from refobject to igloo_ro

parent 0a87e902
......@@ -28,7 +28,6 @@ noinst_HEADERS = \
md5.h \
matchfile.h \
tls.h \
refobject.h \
buffer.h \
module.h \
reportxml.h \
......@@ -74,7 +73,6 @@ icecast_SOURCES = \
md5.c \
matchfile.c \
tls.c \
refobject.c \
buffer.c \
module.c \
reportxml.c \
......
......@@ -16,10 +16,10 @@
#include <stdarg.h>
#include "buffer.h"
#include "refobject.h"
#include <igloo/ro.h>
struct buffer_tag {
refobject_base_t __base;
igloo_ro_base_t __base;
/* Buffer itself */
void *buffer;
/* Length in bytes of buffer */
......@@ -30,21 +30,23 @@ struct buffer_tag {
size_t offset;
};
static void __free(refobject_t self, void **userdata)
static void __free(igloo_ro_t self);
igloo_RO_PUBLIC_TYPE(buffer_t,
igloo_RO_TYPEDECL_FREE(__free),
igloo_RO_TYPEDECL_NEW_NOOP()
);
static void __free(igloo_ro_t self)
{
buffer_t *buffer = REFOBJECT_TO_TYPE(self, buffer_t*);
buffer_t *buffer = igloo_RO_TO_TYPE(self, buffer_t);
free(buffer->buffer);
}
REFOBJECT_DEFINE_TYPE(buffer_t,
REFOBJECT_DEFINE_TYPE_FREE(__free),
REFOBJECT_DEFINE_TYPE_NEW_NOOP()
);
buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name, refobject_t associated)
buffer_t * buffer_new(ssize_t preallocation, const char *name, igloo_ro_t associated)
{
buffer_t *buffer = refobject_new_ext(buffer_t, userdata, name, associated);
buffer_t *buffer = igloo_ro_new_ext(buffer_t, name, associated);
if (!buffer)
return NULL;
......@@ -57,7 +59,7 @@ buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name,
buffer_t * buffer_new_simple(void)
{
return refobject_new(buffer_t);
return igloo_ro_new(buffer_t);
}
void buffer_preallocate(buffer_t *buffer, size_t request)
......
......@@ -22,13 +22,13 @@
#include "icecasttypes.h"
#include "compat.h"
#include "refobject.h"
#include <igloo/ro.h>
/* About thread safety:
* This set of functions is intentinally not thread safe.
*/
REFOBJECT_FORWARD_TYPE(buffer_t);
igloo_RO_FORWARD_TYPE(buffer_t);
/* This creates a new buffer object.
* Parameters:
......@@ -37,7 +37,7 @@ REFOBJECT_FORWARD_TYPE(buffer_t);
* userdata, name, associated
* See refobject_new().
*/
buffer_t * buffer_new(ssize_t preallocation, void *userdata, const char *name, refobject_t associated);
buffer_t * buffer_new(ssize_t preallocation, const char *name, igloo_ro_t associated);
/* Depreciated: This creates a new buffer with defaults.
* Do NOT use this. Use refobject_new(buffer_t)
......
......@@ -34,7 +34,7 @@
#include "util.h"
#include "auth.h"
#include "event.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "reportxml.h"
/* for config_reread_config() */
......@@ -258,7 +258,7 @@ void config_init_configuration(ice_config_t *configuration)
{
memset(configuration, 0, sizeof(ice_config_t));
_set_defaults(configuration);
configuration->reportxml_db = refobject_new(reportxml_database_t);
configuration->reportxml_db = igloo_ro_new(reportxml_database_t);
}
static inline void __read_int(xmlDocPtr doc, xmlNodePtr node, int *val, const char *warning)
......@@ -723,7 +723,7 @@ void config_clear(ice_config_t *c)
config_clear_http_header(c->http_headers);
refobject_unref(c->reportxml_db);
igloo_ro_unref(c->reportxml_db);
memset(c, 0, sizeof(ice_config_t));
}
......@@ -2265,7 +2265,7 @@ static void _parse_paths(xmlDocPtr doc,
ICECAST_LOG_ERROR("Can not parse report xml database \"%H\"", temp);
} else {
reportxml_database_add_report(configuration->reportxml_db, report);
refobject_unref(report);
igloo_ro_unref(report);
ICECAST_LOG_INFO("File \"%H\" added to report xml database", temp);
}
}
......
......@@ -31,7 +31,7 @@
#include <igloo/httpp.h>
#include "global.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "cfgfile.h"
#include "connection.h"
#include "tls.h"
......@@ -41,7 +41,7 @@
#include "fserve.h"
#include "errors.h"
#include "reportxml.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "xslt.h"
#include "source.h"
......@@ -266,7 +266,7 @@ void client_destroy(client_t *client)
if (client->free_client_data)
client->free_client_data(client);
refobject_unref(client->handler_module);
igloo_ro_unref(client->handler_module);
free(client->handler_function);
free(client->uri);
free(client->username);
......@@ -344,7 +344,7 @@ static inline void _client_send_report(client_t *client, const char *uuid, const
client_send_reportxml(client, report, DOCUMENT_DOMAIN_ADMIN, xslt, admin_format, http_status, location);
refobject_unref(report);
igloo_ro_unref(report);
}
void client_send_error_by_error(client_t *client, const icecast_error_t *error)
......@@ -660,7 +660,7 @@ static void client_get_reportxml__add_basic_stats(reportxml_t *report)
reportxml_node_add_child(rootnode, extension);
refobject_unref(rootnode);
igloo_ro_unref(rootnode);
xmlroot = xmlNewNode(NULL, XMLSTR("icestats"));
modules = module_container_get_modulelist_as_xml(global.modulecontainer);
......@@ -668,7 +668,7 @@ static void client_get_reportxml__add_basic_stats(reportxml_t *report)
reportxml_node_add_xml_child(extension, xmlroot);
refobject_unref(extension);
igloo_ro_unref(extension);
xmlFreeNode(xmlroot);
}
......@@ -687,7 +687,7 @@ reportxml_t *client_get_reportxml(const char *state_definition, const char *stat
if (!report) {
reportxml_node_t *rootnode, *incidentnode, *statenode;
report = refobject_new(reportxml_t);
report = igloo_ro_new(reportxml_t);
rootnode = reportxml_get_root_node(report);
incidentnode = reportxml_node_new(REPORTXML_NODE_TYPE_INCIDENT, NULL, NULL, NULL);
statenode = reportxml_node_new(REPORTXML_NODE_TYPE_STATE, NULL, state_definition, state_akindof);
......@@ -698,14 +698,14 @@ reportxml_t *client_get_reportxml(const char *state_definition, const char *stat
textnode = reportxml_node_new(REPORTXML_NODE_TYPE_TEXT, NULL, NULL, NULL);
reportxml_node_set_content(textnode, state_text);
reportxml_node_add_child(statenode, textnode);
refobject_unref(textnode);
igloo_ro_unref(textnode);
}
reportxml_node_add_child(incidentnode, statenode);
reportxml_node_add_child(rootnode, incidentnode);
refobject_unref(statenode);
refobject_unref(incidentnode);
refobject_unref(rootnode);
igloo_ro_unref(statenode);
igloo_ro_unref(incidentnode);
igloo_ro_unref(rootnode);
}
client_get_reportxml__add_basic_stats(report);
......
......@@ -43,7 +43,7 @@
#include "cfgfile.h"
#include "global.h"
#include "util.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "refbuf.h"
#include "client.h"
#include "errors.h"
......@@ -58,7 +58,7 @@
#include "matchfile.h"
#include "tls.h"
#include "acl.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "listensocket.h"
#include "fastevent.h"
......@@ -261,8 +261,8 @@ connection_t *connection_create(igloo_sock_t sock, listensocket_t *listensocket_
con = (connection_t *)calloc(1, sizeof(connection_t));
if (con) {
refobject_ref(listensocket_real);
refobject_ref(listensocket_effective);
igloo_ro_ref(listensocket_real);
igloo_ro_ref(listensocket_effective);
con->sock = sock;
con->listensocket_real = listensocket_real;
......@@ -1242,7 +1242,7 @@ static int _handle_resources(client_t *client, char **uri)
module_t *module = module_container_get_module(global.modulecontainer, resource->module);
if (module != NULL) {
refobject_unref(client->handler_module);
igloo_ro_unref(client->handler_module);
client->handler_module = module;
} else {
ICECAST_LOG_ERROR("Module used in alias not found: %s", resource->module);
......@@ -1701,7 +1701,7 @@ static void __on_sock_count(size_t count, void *userdata)
void connection_setup_sockets (ice_config_t *config)
{
global_lock();
refobject_unref(global.listensockets);
igloo_ro_unref(global.listensockets);
if (config == NULL) {
global_unlock();
......@@ -1721,7 +1721,7 @@ void connection_setup_sockets (ice_config_t *config)
allowed_ip = matchfile_new(config->allowfile);
}
global.listensockets = refobject_new(listensocket_container_t);
global.listensockets = igloo_ro_new(listensocket_container_t);
listensocket_container_configure(global.listensockets, config);
global_unlock();
......@@ -1745,8 +1745,8 @@ void connection_close(connection_t *con)
free(con->ip);
if (con->readbuffer)
free(con->readbuffer);
refobject_unref(con->listensocket_real);
refobject_unref(con->listensocket_effective);
igloo_ro_unref(con->listensocket_real);
igloo_ro_unref(con->listensocket_effective);
free(con);
}
......
......@@ -14,6 +14,10 @@
#include <config.h>
#endif
#include <igloo/typedef.h>
typedef struct fastevent_registration_tag fastevent_registration_t;
#define igloo_RO_PRIVATETYPES igloo_RO_TYPE(fastevent_registration_t)
#include <stdlib.h>
#include <string.h>
......@@ -26,14 +30,19 @@
#ifdef FASTEVENT_ENABLED
typedef struct {
refobject_base_t __base;
struct fastevent_registration_tag {
igloo_ro_base_t __base;
fastevent_type_t type;
fastevent_cb_t cb;
fastevent_freecb_t freecb;
void *userdata;
} fastevent_registration_t;
};
static void __unregister(igloo_ro_t self);
igloo_RO_PRIVATE_TYPE(fastevent_registration_t,
igloo_RO_TYPEDECL_FREE(__unregister)
);
struct eventrow {
size_t length;
......@@ -96,13 +105,11 @@ static int __remove_from_row(struct eventrow * row, fastevent_registration_t *re
}
static void __unregister(refobject_t self, void **userdata)
static void __unregister(igloo_ro_t self)
{
fastevent_registration_t *registration = REFOBJECT_TO_TYPE(self, fastevent_registration_t *);
fastevent_registration_t *registration = igloo_RO_TO_TYPE(self, fastevent_registration_t);
struct eventrow * row;
(void)userdata;
igloo_thread_rwlock_wlock(&fastevent_lock);
row = __get_row(registration->type);
if (__remove_from_row(row, registration) != 0) {
......@@ -143,31 +150,28 @@ int fastevent_shutdown(void)
return 0;
}
REFOBJECT_DEFINE_PRIVATE_TYPE(fastevent_registration_t,
REFOBJECT_DEFINE_TYPE_FREE(__unregister)
);
refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fastevent_freecb_t freecb, void *userdata)
igloo_ro_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fastevent_freecb_t freecb, void *userdata)
{
struct eventrow * row;
fastevent_registration_t *registration;
if (cb == NULL)
return REFOBJECT_NULL;
return igloo_RO_NULL;
igloo_thread_rwlock_wlock(&fastevent_lock);
row = __get_row(type);
if (row == NULL) {
igloo_thread_rwlock_unlock(&fastevent_lock);
return REFOBJECT_NULL;
return igloo_RO_NULL;
}
registration = refobject_new__new(fastevent_registration_t, NULL, NULL, NULL);
registration = igloo_ro_new_raw(fastevent_registration_t, NULL, igloo_RO_NULL);
if (!registration) {
igloo_thread_rwlock_unlock(&fastevent_lock);
return REFOBJECT_NULL;
return igloo_RO_NULL;
}
registration->type = type;
......@@ -177,12 +181,12 @@ refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fasteve
if (__add_to_row(row, registration) != 0) {
igloo_thread_rwlock_unlock(&fastevent_lock);
refobject_unref(REFOBJECT_FROM_TYPE(registration));
return REFOBJECT_NULL;
igloo_ro_unref(registration);
return igloo_RO_NULL;
}
igloo_thread_rwlock_unlock(&fastevent_lock);
return REFOBJECT_FROM_TYPE(registration);
return (igloo_ro_t)registration;
}
void fastevent_emit(fastevent_type_t type, fastevent_flag_t flags, fastevent_datatype_t datatype, ...)
......
......@@ -15,7 +15,7 @@
#endif
#include <stdarg.h>
#include "refobject.h"
#include <igloo/ro.h>
typedef enum {
FASTEVENT_TYPE_SLOWEVENT = 0,
......@@ -54,7 +54,7 @@ typedef void (*fastevent_freecb_t)(void **userdata);
#ifdef FASTEVENT_ENABLED
int fastevent_initialize(void);
int fastevent_shutdown(void);
refobject_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fastevent_freecb_t freecb, void *userdata);
igloo_ro_t fastevent_register(fastevent_type_t type, fastevent_cb_t cb, fastevent_freecb_t freecb, void *userdata);
void fastevent_emit(fastevent_type_t type, fastevent_flag_t flags, fastevent_datatype_t datatype, ...);
#else
#define fastevent_initialize() 0
......
......@@ -22,7 +22,7 @@
#include <igloo/avl.h>
#include "global.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "module.h"
#include "source.h"
......@@ -39,14 +39,14 @@ void global_initialize(void)
global.clients = 0;
global.sources = 0;
global.source_tree = igloo_avl_tree_new(source_compare_sources, NULL);
global.modulecontainer = refobject_new(module_container_t);
global.modulecontainer = igloo_ro_new(module_container_t);
igloo_thread_mutex_create(&_global_mutex);
}
void global_shutdown(void)
{
igloo_thread_mutex_destroy(&_global_mutex);
refobject_unref(global.modulecontainer);
igloo_ro_unref(global.modulecontainer);
igloo_avl_tree_free(global.source_tree, NULL);
}
......
......@@ -15,6 +15,8 @@
#include "compat.h"
#include <igloo/typedef.h>
/* ---[ client.[ch] ]--- */
typedef struct _client_tag client_t;
......@@ -116,22 +118,14 @@ typedef struct listensocket_tag listensocket_t;
/* ---[ refobject.[ch] ]--- */
typedef struct refobject_base_tag refobject_base_t;
#ifdef HAVE_TYPE_ATTRIBUTE_TRANSPARENT_UNION
typedef union __attribute__ ((__transparent_union__)) {
refobject_base_t *refobject_base;
buffer_t *buffer;
module_t *module;
module_container_t *module_container;
reportxml_t *reportxml;
reportxml_node_t *reportxml_node;
reportxml_database_t *reportxml_database;
listensocket_container_t *listensocket_container;
listensocket_t *listensocket;
} refobject_t;
#else
typedef void * refobject_t;
#endif
#define igloo_RO_APPTYPES \
igloo_RO_TYPE(buffer_t) \
igloo_RO_TYPE(module_t) \
igloo_RO_TYPE(module_container_t) \
igloo_RO_TYPE(reportxml_t) \
igloo_RO_TYPE(reportxml_node_t) \
igloo_RO_TYPE(reportxml_database_t) \
igloo_RO_TYPE(listensocket_container_t) \
igloo_RO_TYPE(listensocket_t)
#endif
......@@ -22,20 +22,22 @@
#include <string.h>
#include "icecasttypes.h"
#include <igloo/sock.h>
#include <igloo/thread.h>
#include "listensocket.h"
#include "global.h"
#include "connection.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "logging.h"
#define CATMODULE "listensocket"
struct listensocket_container_tag {
refobject_base_t __base;
igloo_ro_base_t __base;
igloo_mutex_t lock;
listensocket_t **sock;
int *sockref;
......@@ -44,7 +46,7 @@ struct listensocket_container_tag {
void *sockcount_userdata;
};
struct listensocket_tag {
refobject_base_t __base;
igloo_ro_base_t __base;
size_t sockrefc;
igloo_mutex_t lock;
igloo_rwlock_t listener_rwlock;
......@@ -53,6 +55,17 @@ struct listensocket_tag {
igloo_sock_t sock;
};
static void __listensocket_container_free(igloo_ro_t self);
int __listensocket_container_new(igloo_ro_t self, const igloo_ro_type_t *type, va_list ap);
igloo_RO_PUBLIC_TYPE(listensocket_container_t,
igloo_RO_TYPEDECL_FREE(__listensocket_container_free),
igloo_RO_TYPEDECL_NEW(__listensocket_container_new)
);
static void __listensocket_free(igloo_ro_t self);
igloo_RO_PUBLIC_TYPE(listensocket_t,
igloo_RO_TYPEDECL_FREE(__listensocket_free)
);
static listensocket_t * listensocket_container_get_by_id(listensocket_container_t *self, const char *id);
static int listensocket_container_configure__unlocked(listensocket_container_t *self, const ice_config_t *config);
static int listensocket_container_setup__unlocked(listensocket_container_t *self);
......@@ -126,7 +139,7 @@ static void __listensocket_container_clear_sockets(listensocket_container_t *sel
if (self->sockref[i]) {
listensocket_unrefsock(self->sock[i]);
}
refobject_unref(self->sock[i]);
igloo_ro_unref(self->sock[i]);
self->sock[i] = NULL;
}
}
......@@ -141,18 +154,18 @@ static void __listensocket_container_clear_sockets(listensocket_container_t *sel
}
static void __listensocket_container_free(refobject_t self, void **userdata)
static void __listensocket_container_free(igloo_ro_t self)
{
listensocket_container_t *container = REFOBJECT_TO_TYPE(self, listensocket_container_t *);
listensocket_container_t *container = igloo_RO_TO_TYPE(self, listensocket_container_t);
igloo_thread_mutex_lock(&container->lock);
__listensocket_container_clear_sockets(container);
igloo_thread_mutex_unlock(&container->lock);
igloo_thread_mutex_destroy(&container->lock);
}
int __listensocket_container_new(refobject_t self, const refobject_type_t *type, va_list ap)
int __listensocket_container_new(igloo_ro_t self, const igloo_ro_type_t *type, va_list ap)
{
listensocket_container_t *ret = REFOBJECT_TO_TYPE(self, listensocket_container_t*);
listensocket_container_t *ret = igloo_RO_TO_TYPE(self, listensocket_container_t);
ret->sock = NULL;
ret->sock_len = 0;
......@@ -164,11 +177,6 @@ int __listensocket_container_new(refobject_t self, const refobject_type_t *type,
return 0;
}
REFOBJECT_DEFINE_TYPE(listensocket_container_t,
REFOBJECT_DEFINE_TYPE_FREE(__listensocket_container_free),
REFOBJECT_DEFINE_TYPE_NEW(__listensocket_container_new)
);
static inline void __find_matching_entry(listensocket_container_t *self, const listener_t *listener, listensocket_t ***found, int **ref)
{
const listener_t *b;
......@@ -251,7 +259,7 @@ static int listensocket_container_configure__unlocked(listensocket_container_t *
}
if (n[i] == NULL) {
for (; i; i--) {
refobject_unref(n[i - 1]);
igloo_ro_unref(n[i - 1]);
}
return -1;
}
......@@ -434,11 +442,11 @@ connection_t * listensocket_container_accept(listensocket_container
igloo_thread_mutex_lock(&self->lock);
ls = listensocket_container_accept__inner(self, timeout);
refobject_ref(ls);
igloo_ro_ref(ls);
igloo_thread_mutex_unlock(&self->lock);
ret = listensocket_accept(ls, self);
refobject_unref(ls);
igloo_ro_unref(ls);
return ret;
}
......@@ -495,7 +503,7 @@ static listensocket_t * listensocket_container_get_by_id(listensocket_container_
if (listener) {
if (listener->id != NULL && strcmp(listener->id, id) == 0) {
listensocket_release_listener(self->sock[i]);
if (refobject_ref(self->sock[i]) == 0) {
if (igloo_ro_ref(self->sock[i]) == 0) {
return self->sock[i];
}
}
......@@ -509,9 +517,9 @@ static listensocket_t * listensocket_container_get_by_id(listensocket_container_
/* ---------------------------------------------------------------------------- */
static void __listensocket_free(refobject_t self, void **userdata)
static void __listensocket_free(igloo_ro_t self)
{
listensocket_t *listensocket = REFOBJECT_TO_TYPE(self, listensocket_t *);
listensocket_t *listensocket = igloo_RO_TO_TYPE(self, listensocket_t);
igloo_thread_mutex_lock(&listensocket->lock);
......@@ -530,17 +538,13 @@ static void __listensocket_free(refobject_t self, void **userdata)
igloo_thread_mutex_destroy(&listensocket->lock);
}
REFOBJECT_DEFINE_TYPE(listensocket_t,
REFOBJECT_DEFINE_TYPE_FREE(__listensocket_free)
);
static listensocket_t * listensocket_new(const listener_t *listener) {
listensocket_t *self;
if (listener == NULL)
return NULL;
self = refobject_new__new(listensocket_t, NULL, NULL, NULL);
self = igloo_ro_new_raw(listensocket_t, NULL, igloo_RO_NULL);
if (!self)
return NULL;
......@@ -551,7 +555,7 @@ static listensocket_t * listensocket_new(const listener_t *listener) {
self->listener = config_copy_listener_one(listener);
if (self->listener == NULL) {
refobject_unref(self);
igloo_ro_unref(self);
return NULL;
}
......@@ -738,12 +742,12 @@ connection_t * listensocket_accept(listensocket_t *self, listensock
if (!effective) {
effective = self;
refobject_ref(effective);
igloo_ro_ref(effective);
}
con = connection_create(sock, self, effective, ip);
refobject_unref(effective);
igloo_ro_unref(effective);
if (con == NULL) {
igloo_sock_close(sock);
......
......@@ -10,10 +10,10 @@
#define __LISTENSOCKET_H__
#include "icecasttypes.h"
#include "refobject.h"
#include <igloo/ro.h>
#include "cfgfile.h"
REFOBJECT_FORWARD_TYPE(listensocket_container_t);
igloo_RO_FORWARD_TYPE(listensocket_container_t);
listensocket_container_t * listensocket_container_new(void);
int listensocket_container_configure(listensocket_container_t *self, const ice_config_t *config);
......@@ -23,7 +23,7 @@ connection_t * listensocket_container_accept(listensocket_container
int listensocket_container_set_sockcount_cb(listensocket_container_t *self, void (*cb)(size_t count, void *userdata), void *userdata);
ssize_t listensocket_container_sockcount(listensocket_container_t *self);
REFOBJECT_FORWARD_TYPE(listensocket_t);
igloo_RO_FORWARD_TYPE(listensocket_t);
int listensocket_refsock(listensocket_t *self);
int listensocket_unrefsock(listensocket_t *self);
......
......@@ -141,7 +141,7 @@ static void __fastevent_cb(const void *userdata, fastevent_type_t type, fasteven
}
}
static refobject_t fastevent_reg;
static igloo_ro_t fastevent_reg;
#endif
static void initialize_subsystems(void)
......@@ -179,7 +179,7 @@ static void shutdown_subsystems(void)
tls_shutdown();
config_shutdown();
#ifndef FASTEVENT_ENABLED
refobject_unref(fastevent_reg);
igloo_ro_unref(fastevent_reg);
fastevent_shutdown();
#endif
global_shutdown();
......
......@@ -13,15 +13,17 @@
#include <stdlib.h>
#include <string.h>
#include "icecasttypes.h"
#include <igloo/thread.h>
#include <igloo/avl.h>
#include "refobject.h"
#include <igloo/ro.h>
#include "module.h"
#include "cfgfile.h" /* for XMLSTR() */
struct module_tag {
refobject_base_t __base;
igloo_ro_base_t __base;
igloo_mutex_t lock;
const module_client_handler_t *client_handlers;
size_t client_handlers_len;
......@@ -33,26 +35,38 @@ struct module_tag {
struct module_container_tag {
refobject_base_t __base;
igloo_ro_base_t __base;
igloo_mutex_t lock;
igloo_avl_tree *module;
};
static void __module_container_free(igloo_ro_t self);
int __module_container_new(igloo_ro_t self, const igloo_ro_type_t *type, va_list ap);
igloo_RO_PUBLIC_TYPE(module_container_t,
igloo_RO_TYPEDECL_FREE(__module_container_free),
igloo_RO_TYPEDECL_NEW(__module_container_new)
);
static void __module_free(igloo_ro_t self);
igloo_RO_PUBLIC_TYPE(module_t,
igloo_RO_TYPEDECL_FREE(__module_free)
);
static int compare_refobject_t_name(void *arg, void *a, void *b)
{
return strcmp(refobject_get_name(a), refobject_get_name(b));
return strcmp(igloo_ro_get_name(a), igloo_ro_get_name(b));
}
static void __module_container_free(refobject_t self, void **userdata)
static void __module_container_free(igloo_ro_t self)
{
module_container_t *cont = REFOBJECT_TO_TYPE(self, module_container_t *);
module_container_t *cont = igloo_RO_TO_TYPE(self, module_container_t);
igloo_thread_mutex_destroy(&(cont->lock));
igloo_avl_tree_free(cont->module, (igloo_avl_free_key_fun_type)refobject_unref);
igloo_avl_tree_free(cont->module, (igloo_avl_free_key_fun_type)igloo_ro_unref);
}
int __module_container_new(refobject_t self, const refobject_type_t *type, va_list ap)
int __module_container_new(igloo_ro_t self, const igloo_ro_type_t *type, va_list ap)
{
module_container_t *ret = REFOBJECT_TO_TYPE(self, module_container_t*);
module_container_t *ret = igloo_RO_TO_TYPE(self, module_container_t);
igloo_thread_mutex_create(&(ret->lock));
......@@ -61,17 +75,12 @@ int __module_container_new(refobject_t self, const refobject_type_t *type, va_li
return 0;
}
REFOBJECT_DEFINE_TYPE(module_container_t,
REFOBJECT_DEFINE_TYPE_FREE(__module_container_free),
REFOBJECT_DEFINE_TYPE_NEW(__module_container_new)
);
int module_container_add_module(module_container_t *self, module_t *module)
{