Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
idnode: optimize idnodes (split to domains)
  • Loading branch information
perexg committed Sep 22, 2014
1 parent fca35b9 commit df1cf7d
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 69 deletions.
22 changes: 14 additions & 8 deletions src/api/api_idnode.c
Expand Up @@ -185,7 +185,7 @@ api_idnode_load_by_class
assert(idc);

l = htsmsg_create_list();
if ((is = idnode_find_all(idc))) {
if ((is = idnode_find_all(idc, NULL))) {
for (i = 0; i < is->is_count; i++) {
in = is->is_array[i];

Expand Down Expand Up @@ -256,10 +256,12 @@ api_idnode_load

/* Multiple */
if (uuids) {
const idnodes_rb_t *domain = NULL;
l = htsmsg_create_list();
HTSMSG_FOREACH(f, uuids) {
if (!(uuid = htsmsg_field_get_str(f))) continue;
if (!(in = idnode_find(uuid, NULL))) continue;
if (!(in = idnode_find(uuid, NULL, domain))) continue;
domain = in->in_domain;
if (idnode_perm(in, perm, NULL)) {
err = EPERM;
continue;
Expand All @@ -276,7 +278,7 @@ api_idnode_load

/* Single */
} else {
if (!(in = idnode_find(uuid, NULL)))
if (!(in = idnode_find(uuid, NULL, NULL)))
err = ENOENT;
else {
if (idnode_perm(in, perm, NULL)) {
Expand Down Expand Up @@ -326,7 +328,7 @@ api_idnode_save
if (!msg->hm_islist) {
if (!(uuid = htsmsg_get_str(msg, "uuid")))
goto exit;
if (!(in = idnode_find(uuid, NULL)))
if (!(in = idnode_find(uuid, NULL, NULL)))
goto exit;
if (idnode_perm(in, perm, msg)) {
err = EPERM;
Expand All @@ -337,13 +339,15 @@ api_idnode_save

/* Multiple */
} else {
const idnodes_rb_t *domain = NULL;
HTSMSG_FOREACH(f, msg) {
if (!(conf = htsmsg_field_get_map(f)))
continue;
if (!(uuid = htsmsg_get_str(conf, "uuid")))
continue;
if (!(in = idnode_find(uuid, NULL)))
if (!(in = idnode_find(uuid, NULL, domain)))
continue;
domain = in->in_domain;
if (idnode_perm(in, perm, conf)) {
err = EPERM;
continue;
Expand Down Expand Up @@ -389,7 +393,7 @@ api_idnode_tree
pthread_mutex_lock(&global_lock);

if (!isroot || root) {
if (!(node = idnode_find(isroot ? root : uuid, NULL))) {
if (!(node = idnode_find(isroot ? root : uuid, NULL, NULL))) {
pthread_mutex_unlock(&global_lock);
return EINVAL;
}
Expand Down Expand Up @@ -477,16 +481,18 @@ api_idnode_handler

/* Multiple */
if (uuids) {
const idnodes_rb_t *domain = NULL;
HTSMSG_FOREACH(f, uuids) {
if (!(uuid = htsmsg_field_get_string(f))) continue;
if (!(in = idnode_find(uuid, NULL))) continue;
if (!(in = idnode_find(uuid, NULL, domain))) continue;
domain = in->in_domain;
handler(perm, in);
}

/* Single */
} else {
uuid = htsmsg_field_get_string(f);
if (!(in = idnode_find(uuid, NULL)))
if (!(in = idnode_find(uuid, NULL, NULL)))
err = ENOENT;
else
handler(perm, in);
Expand Down
4 changes: 2 additions & 2 deletions src/channels.h
Expand Up @@ -145,7 +145,7 @@ void channel_delete(channel_t *ch, int delconf);

channel_t *channel_find_by_name(const char *name);
#define channel_find_by_uuid(u)\
(channel_t*)idnode_find(u, &channel_class)
(channel_t*)idnode_find(u, &channel_class, NULL)

channel_t *channel_find_by_id(uint32_t id);

Expand All @@ -165,7 +165,7 @@ channel_tag_t *channel_tag_find_by_name(const char *name, int create);
channel_tag_t *channel_tag_find_by_identifier(uint32_t id);

static inline channel_tag_t *channel_tag_find_by_uuid(const char *uuid)
{ return (channel_tag_t*)idnode_find(uuid, &channel_tag_class); }
{ return (channel_tag_t*)idnode_find(uuid, &channel_tag_class, NULL); }

void channel_tag_save(channel_tag_t *ct);

Expand Down
2 changes: 1 addition & 1 deletion src/descrambler/capmt.c
Expand Up @@ -1456,7 +1456,7 @@ capmt_thread(void *aux)
int i, n;
extern const idclass_t linuxdvb_adapter_class;
linuxdvb_adapter_t *la;
idnode_set_t *is = idnode_find_all(&linuxdvb_adapter_class);
idnode_set_t *is = idnode_find_all(&linuxdvb_adapter_class, NULL);
for (i = 0; i < is->is_count; i++) {
la = (linuxdvb_adapter_t*)is->is_array[i];
if (!la || !la->la_is_enabled(la)) continue;
Expand Down
8 changes: 4 additions & 4 deletions src/dvr/dvr.h
Expand Up @@ -344,7 +344,7 @@ dvr_config_t *dvr_config_find_by_name_default(const char *name);
dvr_config_t *dvr_config_create(const char *name, const char *uuid, htsmsg_t *conf);

static inline dvr_config_t *dvr_config_find_by_uuid(const char *uuid)
{ return (dvr_config_t*)idnode_find(uuid, &dvr_config_class); }
{ return (dvr_config_t*)idnode_find(uuid, &dvr_config_class, NULL); }

void dvr_config_delete(const char *name);

Expand Down Expand Up @@ -431,7 +431,7 @@ void dvr_event_updated(epg_broadcast_t *e);
dvr_entry_t *dvr_entry_find_by_id(int id);

static inline dvr_entry_t *dvr_entry_find_by_uuid(const char *uuid)
{ return (dvr_entry_t*)idnode_find(uuid, &dvr_entry_class); }
{ return (dvr_entry_t*)idnode_find(uuid, &dvr_entry_class, NULL); }

dvr_entry_t *dvr_entry_find_by_event(epg_broadcast_t *e);

Expand Down Expand Up @@ -490,7 +490,7 @@ void dvr_autorec_changed(dvr_autorec_entry_t *dae, int purge);

static inline dvr_autorec_entry_t *
dvr_autorec_find_by_uuid(const char *uuid)
{ return (dvr_autorec_entry_t*)idnode_find(uuid, &dvr_autorec_entry_class); }
{ return (dvr_autorec_entry_t*)idnode_find(uuid, &dvr_autorec_entry_class, NULL); }


htsmsg_t * dvr_autorec_entry_class_time_list(void *o, const char *null);
Expand Down Expand Up @@ -526,7 +526,7 @@ dvr_timerec_create(const char *uuid, htsmsg_t *conf);

static inline dvr_timerec_entry_t *
dvr_timerec_find_by_uuid(const char *uuid)
{ return (dvr_timerec_entry_t*)idnode_find(uuid, &dvr_timerec_entry_class); }
{ return (dvr_timerec_entry_t*)idnode_find(uuid, &dvr_timerec_entry_class, NULL); }


void dvr_timerec_save(dvr_timerec_entry_t *dae);
Expand Down

0 comments on commit df1cf7d

Please sign in to comment.