Cosmetic nonchange to radiusd.c and updates to request_tree walk.
authorcmiller <cmiller>
Sat, 16 Dec 2000 17:06:10 +0000 (17:06 +0000)
committercmiller <cmiller>
Sat, 16 Dec 2000 17:06:10 +0000 (17:06 +0000)
src/main/radiusd.c
src/main/request_tree.c

index ae75dfb..9611d3f 100644 (file)
@@ -257,14 +257,15 @@ static int reread_config(int reload)
         *      in debugging mode.
         */
        if (!debug_flag) {
+
                /*
                 *      Set group.
                 */
-               if (gid_name) {
+               if (gid_name != NULL) {
                        struct group *gr;
 
                        gr = getgrnam(gid_name);
-                       if (!gr) {
+                       if (gr == NULL) {
                                radlog(L_ERR|L_CONS, "Cannot switch to Group %s: %s", gid_name, strerror(errno));
                                exit(1);
                        }
@@ -282,7 +283,7 @@ static int reread_config(int reload)
                        struct passwd *pw;
 
                        pw = getpwnam(uid_name);
-                       if (!pw) {
+                       if (pw == NULL) {
                                radlog(L_ERR|L_CONS, "Cannot switch to User %s: %s", uid_name, strerror(errno));
                                exit(1);
                        }
index dcf5fa5..8c15f5a 100644 (file)
@@ -311,39 +311,55 @@ static REQUEST *do_rt_find(REQTREE **tree, REQUEST *reqobject) {
 static REQUEST *do_rt_next(REQUEST *reqobject) {
        REQTREE *ptr, *next;
        int i;
-       /* this should walk in the same order as walk() */
-
-       ptr = ((REQTREE *)reqobject->container);
-       assert(ptr != NULL);
+       /* this should/must walk in the same order as walk() */
+
+       if (reqobject != NULL) {
+               ptr = ((REQTREE *)reqobject->container);
+               assert(ptr != NULL);
+
+               if (ptr->parent != NULL) {
+                       if ((ptr->parent->leftbranch == ptr) && 
+                                       (ptr->parent->rightbranch != NULL)) {
+                               next = ptr->parent->rightbranch;
+                               while (next->leftbranch != NULL) {
+                                       next = next->leftbranch;
+                               }
+                               return(next->req);
+                       } else {
+                               return(ptr->parent->req);
+                       }
+               } else {
+                       i = (ptr->req->packet->id + 1) % 256;
+                       while (reqtreehead[i] == NULL) {
+                               i = (i + 1) % 256;
+                       }
+                       assert(reqtreehead[i] != NULL);
 
-       if (ptr->parent != NULL) {
-               if ((ptr->parent->leftbranch == ptr) && 
-                               (ptr->parent->rightbranch != NULL)) {
-                       next = ptr->parent->rightbranch;
-                       while (next->leftbranch != NULL) {
+                       next = reqtreehead[i];
+                       while (next->leftbranch) {
                                next = next->leftbranch;
                        }
-                       return(next->req);
-               } else {
-                       return(ptr->parent->req);
+
+                       if (ptr == next) { /* we looped */
+                               return(NULL);
+                       } else {
+                               return(next->req);
+                       }
                }
-       } else {
-               i = (ptr->req->packet->id + 1) % 256;
-               while (reqtreehead[i] == NULL) {
-                       i = (i + 1) % 256;
+       } else {  /* we were passed a NULL, so we give back the first request we have. */
+               i = 0;
+               while ((reqtreehead[i] == NULL) && (i < 256)) {
+                       i = i + 1;
                }
-               assert(reqtreehead[i] != NULL);
+
+               if (reqtreehead[i] == NULL) 
+                       return(NULL);
 
                next = reqtreehead[i];
                while (next->leftbranch) {
                        next = next->leftbranch;
                }
-
-               if (ptr == next) { /* we looped */
-                       return(NULL);
-               } else {
-                       return(next->req);
-               }
+               return(next->req);
        }
 
        return(NULL); /* kill warnings */