Changeset 93e883d


Ignore:
Timestamp:
Feb 11, 2007, 10:36:00 AM (17 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
16138b0
Parents:
687c674
Message:
Load zephyr subscriptions in chunks.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    r272a4a0 r93e883d  
    7070  return("");
    7171#endif
     72}
     73
     74int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count)
     75{
     76  int i, ret = 0;
     77  /* sub without defaults */
     78  if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
     79    owl_function_error("Error subscribing to zephyr notifications.");
     80    ret=-2;
     81  }
     82
     83  /* free stuff */
     84  for (i=0; i<count; i++) {
     85    owl_free(subs[i].zsub_class);
     86    owl_free(subs[i].zsub_classinst);
     87    owl_free(subs[i].zsub_recipient);
     88  }
     89  return ret;
    7290}
    7391
     
    87105  char buffer[1024], subsfile[1024];
    88106  ZSubscription_t subs[3001];
    89   int count, ret, i;
     107  int count, ret;
    90108  struct stat statbuff;
    91109
     
    103121
    104122  ZResetAuthentication();
    105   /* need to redo this to do chunks, not just bail after 3000 */
    106123  count=0;
    107124  file=fopen(subsfile, "r");
     
    116133    }
    117134   
    118     if (count >= 3000) break; /* also tell the user */
     135    if (count >= 3000) {
     136      ret = owl_zephyr_loadsubs_helper(subs, count);
     137      if (ret != 0) {
     138        fclose(file);
     139        return(ret);
     140      }
     141      count=0;
     142    }
    119143   
    120144    /* add it to the list of subs */
     
    135159  fclose(file);
    136160
    137   /* sub without defaults */
    138   ret=0;
    139   if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
    140     owl_function_error("Error subscribing to zephyr notifications.");
    141     ret=-2;
    142   }
    143 
    144   /* free stuff */
    145   for (i=0; i<count; i++) {
    146     owl_free(subs[i].zsub_class);
    147     owl_free(subs[i].zsub_classinst);
    148     owl_free(subs[i].zsub_recipient);
    149   }
     161  ret=owl_zephyr_loadsubs_helper(subs, count);
    150162
    151163  return(ret);
Note: See TracChangeset for help on using the changeset viewer.