Changeset d21efbc


Ignore:
Timestamp:
Mar 7, 2009, 7:04:55 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:
a5e7ed6
Parents:
0cff2b4
Message:
Correctly load .anyone files over 3000 users.

More importantly, refactor the code slightly to share more code.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zephyr.c

    r0cff2b4 rd21efbc  
    192192  }
    193193
     194  owl_free(subs);
     195
    194196  return ret;
    195197}
     
    242244   
    243245    if (count >= subSize) {
    244       ZSubscription_t* newsubs;
    245       newsubs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize * 2);
    246       if (NULL == newsubs) {
    247         /* If realloc fails, load what we've got, clear, and continue */
    248         ret = owl_zephyr_loadsubs_helper(subs, count);
    249         if (ret != 0) {
    250           fclose(file);
    251           return(ret);
    252         }
    253         count=0;
    254       }
    255       else {
    256         subs = newsubs;
    257         subSize *= 2;
    258       }
     246      subSize *= 2;
     247      subs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize);
    259248    }
    260249   
     
    282271
    283272  owl_zephyr_loadsubs_helper(subs, count);
    284   owl_free(subs);
    285273  return(ret);
    286274#else
     
    308296#ifdef HAVE_LIBZEPHYR
    309297  FILE *file;
    310   ZSubscription_t subs[3001];
     298  ZSubscription_t *subs;
     299  int numSubs = 100;
    311300  char subsfile[1024], buffer[1024];
    312   int count, ret, i;
     301  int count, ret;
    313302  struct stat statbuff;
     303
     304  subs = owl_malloc(numSubs * sizeof(ZSubscription_t));
    314305
    315306  if (filename==NULL) {
     
    325316
    326317  ZResetAuthentication();
    327   /* need to redo this to do chunks, not just bag out after 3000 */
    328318  count=0;
    329319  file=fopen(subsfile, "r");
     
    332322      if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue;
    333323     
    334       if (count >= 3000) break; /* also tell the user */
     324      if (count == numSubs) {
     325        numSubs *= 2;
     326        subs = owl_realloc(subs, numSubs * sizeof(ZSubscription_t));
     327      }
    335328
    336329      buffer[strlen(buffer)-1]='\0';
    337       subs[count].zsub_class="login";
    338       subs[count].zsub_recipient="*";
     330      subs[count].zsub_class=owl_strdup("login");
     331      subs[count].zsub_recipient=owl_strdup("*");
    339332      if (strchr(buffer, '@')) {
    340         subs[count].zsub_classinst=owl_strdup(buffer);
     333        subs[count].zsub_classinst=owl_strdup(buffer);
    341334      } else {
    342         subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm());
     335        subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm());
    343336      }
    344337
     
    351344  }
    352345
    353   /* sub with defaults */
    354   if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) {
    355     owl_function_error("Error subscribing to zephyr notifications.");
    356     ret=-2;
    357   }
    358 
    359   /* free stuff */
    360   for (i=0; i<count; i++) {
    361     owl_free(subs[i].zsub_classinst);
    362   }
     346  ret = owl_zephyr_loadsubs_helper(subs, count);
    363347
    364348  return(ret);
Note: See TracChangeset for help on using the changeset viewer.