Ignore:
Timestamp:
May 24, 2009, 7:51:24 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 branch to 3.3.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/lib/dbwrap.c

    r206 r223  
    4343}
    4444
     45/*
     46 * Fall back using fetch if no genuine parse operation is provided
     47 */
     48
     49static int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
     50                                        int (*parser)(TDB_DATA key,
     51                                                      TDB_DATA data,
     52                                                      void *private_data),
     53                                        void *private_data)
     54{
     55        TDB_DATA data;
     56        int res;
     57
     58        res = db->fetch(db, talloc_tos(), key, &data);
     59        if (res != 0) {
     60                return res;
     61        }
     62
     63        res = parser(key, data, private_data);
     64        TALLOC_FREE(data.dptr);
     65        return res;
     66}
     67
     68bool db_is_local(const char *name)
     69{
     70#ifdef CLUSTER_SUPPORT
     71        const char *sockname = lp_ctdbd_socket();
     72
     73        if(!sockname || !*sockname) {
     74                sockname = CTDB_PATH;
     75        }
     76
     77        if (lp_clustering() && socket_exist(sockname)) {
     78                const char *partname;
     79                /* ctdb only wants the file part of the name */
     80                partname = strrchr(name, '/');
     81                if (partname) {
     82                        partname++;
     83                } else {
     84                        partname = name;
     85                }
     86                /* allow ctdb for individual databases to be disabled */
     87                if (lp_parm_bool(-1, "ctdb", partname, True)) {
     88                        return false;
     89                }
     90        }
     91#endif
     92        return true;
     93}
     94
    4595/**
    4696 * open a database
     
    102152                result->fetch = dbwrap_fallback_fetch;
    103153        }
     154        if ((result != NULL) && (result->parse_record == NULL)) {
     155                result->parse_record = dbwrap_fallback_parse_record;
     156        }
    104157
    105158        return result;
Note: See TracChangeset for help on using the changeset viewer.