Changeset a5e7ed6


Ignore:
Timestamp:
Mar 7, 2009, 8:49:37 PM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
975f2d0
Parents:
d21efbc
Message:
Properly handle :load-subs in .owl/startup

If :load-subs is called before we have Zephyr, save the list of subs we
would have loaded and subscribe to them once we get a reply from the
hostmaster.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    rd21efbc ra5e7ed6  
    88
    99static const char fileIdent[] = "$Id$";
     10
     11static GList *deferred_subs = NULL;
     12typedef struct _owl_sub_list {                            /* noproto */
     13  ZSubscription_t *subs;
     14  int nsubs;
     15} owl_sub_list;
    1016
    1117#ifdef HAVE_LIBZEPHYR
     
    102108    owl_zephyr_load_initial_subs();
    103109  }
     110  while(deferred_subs != NULL) {
     111    owl_sub_list *subs = deferred_subs->data;
     112    owl_function_debugmsg("Loading %d deferred subs.", subs->nsubs);
     113    owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs);
     114    deferred_subs = g_list_delete_link(deferred_subs, deferred_subs);
     115    owl_free(subs);
     116  }
    104117}
    105118
     
    178191int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count)
    179192{
    180   int i, ret = 0;
    181   /* sub without defaults */
    182   if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
    183     owl_function_error("Error subscribing to zephyr notifications.");
    184     ret=-2;
    185   }
    186 
    187   /* free stuff */
    188   for (i=0; i<count; i++) {
    189     owl_free(subs[i].zsub_class);
    190     owl_free(subs[i].zsub_classinst);
    191     owl_free(subs[i].zsub_recipient);
    192   }
    193 
    194   owl_free(subs);
     193  int ret;
     194  if (owl_global_is_havezephyr(&g)) {
     195    int i;
     196    /* sub without defaults */
     197    if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
     198      owl_function_error("Error subscribing to zephyr notifications.");
     199      ret=-2;
     200    }
     201
     202    /* free stuff */
     203    for (i=0; i<count; i++) {
     204      owl_free(subs[i].zsub_class);
     205      owl_free(subs[i].zsub_classinst);
     206      owl_free(subs[i].zsub_recipient);
     207    }
     208
     209    owl_free(subs);
     210  } else {
     211    owl_sub_list *s = owl_malloc(sizeof(owl_sub_list));
     212    s->subs = subs;
     213    s->nsubs = count;
     214    deferred_subs = g_list_append(deferred_subs, s);
     215  }
    195216
    196217  return ret;
     
    345366
    346367  ret = owl_zephyr_loadsubs_helper(subs, count);
    347 
    348368  return(ret);
    349369#else
Note: See TracChangeset for help on using the changeset viewer.