Ignore:
Timestamp:
Nov 29, 2012, 2:06:31 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9 2nd part

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/lib/talloc/talloc.c

    r745 r752  
    839839                if (tc->prev) tc->prev->next = tc->next;
    840840                if (tc->next) tc->next->prev = tc->prev;
     841                tc->prev = tc->next = NULL;
    841842        }
    842843
     
    926927                if (tc->prev) tc->prev->next = tc->next;
    927928                if (tc->next) tc->next->prev = tc->prev;
     929                tc->prev = tc->next = NULL;
    928930        }
    929931
     
    12521254                        if (p) new_parent = TC_PTR_FROM_CHUNK(p);
    12531255                }
    1254                 /* finding the parent here is potentially quite
    1255                    expensive, but the alternative, which is to change
    1256                    talloc to always have a valid tc->parent pointer,
    1257                    makes realloc more expensive where there are a
    1258                    large number of children.
    1259 
    1260                    The reason we need the parent pointer here is that
    1261                    if _talloc_free_internal() fails due to references
    1262                    or a failing destructor we need to re-parent, but
    1263                    the free call can invalidate the prev pointer.
    1264                 */
    1265                 if (new_parent == null_context && (tc->child->refs || tc->child->destructor)) {
    1266                         old_parent = talloc_parent_chunk(ptr);
    1267                 }
    12681256                if (unlikely(_talloc_free_internal(child, location) == -1)) {
    12691257                        if (new_parent == null_context) {
    1270                                 struct talloc_chunk *p = old_parent;
     1258                                struct talloc_chunk *p = talloc_parent_chunk(ptr);
    12711259                                if (p) new_parent = TC_PTR_FROM_CHUNK(p);
    12721260                        }
     
    12831271_PUBLIC_ void talloc_free_children(void *ptr)
    12841272{
     1273        struct talloc_chunk *tc_name = NULL;
    12851274        struct talloc_chunk *tc;
    12861275
     
    12911280        tc = talloc_chunk_from_ptr(ptr);
    12921281
     1282        /* we do not want to free the context name if it is a child .. */
     1283        if (likely(tc->child)) {
     1284                for (tc_name = tc->child; tc_name; tc_name = tc_name->next) {
     1285                        if (tc->name == TC_PTR_FROM_CHUNK(tc_name)) break;
     1286                }
     1287                if (tc_name) {
     1288                        _TLIST_REMOVE(tc->child, tc_name);
     1289                        if (tc->child) {
     1290                                tc->child->parent = tc;
     1291                        }
     1292                }
     1293        }
     1294
    12931295        _talloc_free_children_internal(tc, ptr, __location__);
     1296
     1297        /* .. so we put it back after all other children have been freed */
     1298        if (tc_name) {
     1299                if (tc->child) {
     1300                        tc->child->parent = NULL;
     1301                }
     1302                tc_name->parent = tc;
     1303                _TLIST_ADD(tc->child, tc_name);
     1304        }
    12941305}
    12951306
Note: See TracChangeset for help on using the changeset viewer.