s3-epmapper: Refactor the cleanup of endpoints.
authorAndreas Schneider <asn@samba.org>
Thu, 24 Mar 2011 12:07:54 +0000 (13:07 +0100)
committerSimo Sorce <idra@samba.org>
Thu, 24 Mar 2011 18:57:12 +0000 (14:57 -0400)
source3/rpc_server/epmapper/srv_epmapper.c

index 3c12b3caa24a4dd5d90609497822f0598d5e581c..2e3e5d2173ff6d62a6ecf44183e404623ea48914 100644 (file)
@@ -231,16 +231,12 @@ static bool is_priviledged_pipe(struct auth_serversupplied_info *info) {
 bool srv_epmapper_delete_endpoints(struct pipes_struct *p)
 {
        struct epm_Delete r;
-       struct dcesrv_ep_entry_list *el;
+       struct dcesrv_ep_entry_list *el = p->ep_entries;
        error_status_t result;
 
-       if (p->ep_entries == NULL) {
-               return true;
-       }
+       while (el) {
+               struct dcesrv_ep_entry_list *next = el->next;
 
-       for (el = p->ep_entries;
-            el != NULL;
-            el = p->ep_entries) {
                r.in.num_ents = el->num_ents;
                r.in.entries = el->entries;
 
@@ -254,6 +250,8 @@ bool srv_epmapper_delete_endpoints(struct pipes_struct *p)
 
                DLIST_REMOVE(p->ep_entries, el);
                TALLOC_FREE(el);
+
+               el = next;
        }
 
        return true;
@@ -261,13 +259,15 @@ bool srv_epmapper_delete_endpoints(struct pipes_struct *p)
 
 void srv_epmapper_cleanup(void)
 {
-       struct dcesrv_endpoint *ep;
+       struct dcesrv_endpoint *ep = endpoint_table;
+
+       while (ep) {
+               struct dcesrv_endpoint *next = ep->next;
 
-       for (ep = endpoint_table;
-            ep != NULL;
-            ep = endpoint_table) {
                DLIST_REMOVE(endpoint_table, ep);
                TALLOC_FREE(ep);
+
+               ep = next;
        }
 }