Attempt to fix bug #3617. Mix of patches from Volker and
authorJeremy Allison <jra@samba.org>
Wed, 2 Jan 2008 19:56:07 +0000 (11:56 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 2 Jan 2008 19:56:07 +0000 (11:56 -0800)
myself. Use standard dlinklist macros.
Jeremy.
(This used to be commit 1b06ee69f6b737c1d6e7b29f8ae9621e6eb07d27)

source3/nmbd/nmbd_packets.c
source3/nmbd/nmbd_responserecordsdb.c

index 3bb151420343fbf3a5114bea0681125d27b5797a..c1d373aa189038af44a036c8eb70b70381138ba4 100644 (file)
@@ -1613,6 +1613,8 @@ void retransmit_or_expire_response_records(time_t t)
        for (subrec = FIRST_SUBNET; subrec; subrec = get_next_subnet_maybe_unicast_or_wins_server(subrec)) {
                struct response_record *rrec, *nextrrec;
 
+  restart:
+
                for (rrec = subrec->responselist; rrec; rrec = nextrrec) {
                        nextrrec = rrec->next;
 
@@ -1651,6 +1653,9 @@ on subnet %s\n", rrec->response_id, inet_ntoa(rrec->packet->ip), subrec->subnet_
                                                                        no timeout function. */
                                                        remove_response_record(subrec, rrec);
                                                }
+                                               /* We have changed subrec->responselist,
+                                                * restart from the beginning of this list. */
+                                               goto restart;
                                        } /* !rrec->in_expitation_processing */
                                } /* rrec->repeat_count > 0 */
                        } /* rrec->repeat_time <= t */
index 22a038ef2ea8496b2a98fd835219ae4695329a98..6498ce04cf32485c389092fdfde7626a66e2bf6a 100644 (file)
@@ -31,26 +31,12 @@ int num_response_packets = 0;
 static void add_response_record(struct subnet_record *subrec,
                                struct response_record *rrec)
 {
-       struct response_record *rrec2;
-
        num_response_packets++; /* count of total number of packets still around */
 
        DEBUG(4,("add_response_record: adding response record id:%hu to subnet %s. num_records:%d\n",
                rrec->response_id, subrec->subnet_name, num_response_packets));
 
-       if (!subrec->responselist) {
-               subrec->responselist = rrec;
-               rrec->prev = NULL;
-               rrec->next = NULL;
-               return;
-       }
-  
-       for (rrec2 = subrec->responselist; rrec2->next; rrec2 = rrec2->next) 
-               ;
-  
-       rrec2->next = rrec;
-       rrec->next = NULL;
-       rrec->prev = rrec2;
+       DLIST_ADD_END(subrec->responselist, rrec, struct response_record *);
 }
 
 /***************************************************************************
@@ -60,13 +46,7 @@ static void add_response_record(struct subnet_record *subrec,
 void remove_response_record(struct subnet_record *subrec,
                                struct response_record *rrec)
 {
-       if (rrec->prev)
-               rrec->prev->next = rrec->next;
-       if (rrec->next)
-               rrec->next->prev = rrec->prev;
-
-       if (subrec->responselist == rrec) 
-               subrec->responselist = rrec->next; 
+       DLIST_REMOVE(subrec->responselist, rrec);
 
        if(rrec->userdata) {
                if(rrec->userdata->free_fn) {