]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/user_ops.c
When opening a cursor, always read through to the end.
[citadel.git] / citadel / server / user_ops.c
index 7c85b011893b76daa02311e668d234e05de4d9c7..61183bcc06c1274834c2bff5f5a26278aa372e07 100644 (file)
@@ -398,7 +398,7 @@ int getuserbyuid(struct ctdluser *usbuf, uid_t number) {
        // Yes, we do this the long way.  Someday we might want to try an index.
        // No, we don't use CtdlForEachUser() because that requires multiple reads for each record
        cdb_rewind(CDB_USERS);
-       while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) {
+       while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) {         // always read through to the end
                usptr = (struct ctdluser *) cdbus.val.ptr;
 
                if (usptr->uid == number) {
@@ -1040,10 +1040,9 @@ void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data) {
        }
 
 
-       cdb_rewind(CDB_USERS);
-
        // Phase 1 : build an array of all our user account names
-       while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) {
+       cdb_rewind(CDB_USERS);
+       while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) {         // always read through to the end
                usptr = (struct ctdluser *) cdbus.val.ptr;
                if (strlen(usptr->fullname) > 0) {
                        array_append(all_users, usptr->fullname);