IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20341


Ignore:
Timestamp:
Oct 22, 2008, 9:44:43 PM (18 years ago)
Author:
bills
Message:

when opening a file in nebulous for writing, cull all but one existing
instance for consistencty (may need some work with respect to locking
versus replication)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/nebclient/src/nebclient.c

    r20209 r20341  
    44 * Copyright (C) 2005  Joshua Hoblitt
    55 *
    6  * $Id: nebclient.c,v 1.52 2008-10-16 23:53:01 jhoblitt Exp $
     6 * $Id: nebclient.c,v 1.53 2008-10-23 07:44:43 bills Exp $
    77 */
    88
     
    247247
    248248    locations = nebFindInstances(server, key, NULL);
    249     if (!locations) {
     249    if (!locations || locations->n <= 1) {
    250250        nebSetErr(server, "can not cull - not enough instances");
    251251
     
    260260
    261261    nebObjectInstancesFree(locations);
     262
     263    return true;
     264}
     265
     266bool nebCullAllButOne(nebServer *server, const char *key)
     267{
     268    while (nebCull(server, key)) {
     269        ;
     270    }
    262271
    263272    return true;
  • trunk/Nebulous/nebclient/src/nebclient.h

    r20209 r20341  
    44 * Copyright (C) 2005  Joshua Hoblitt
    55 *
    6  * $Id: nebclient.h,v 1.34 2008-10-16 23:53:01 jhoblitt Exp $
     6 * $Id: nebclient.h,v 1.35 2008-10-23 07:44:43 bills Exp $
    77 */
    88
     
    120120);
    121121
     122/** Removes all but one instance from a storage object
     123 *
     124 * @return true on success
     125 */
     126
     127bool nebCullAllButOne(
     128    nebServer *server,                  ///< nebServer object
     129    const char *key                     ///< storage object key (name)
     130);
     131
    122132/** Trys to acquire a lock on a storage object
    123133 *
  • trunk/psModules/src/config/pmConfig.c

    r20260 r20341  
    16041604        nebServer *server = nebServerAlloc(neb_server);
    16051605        if (!server) {
    1606             psError(PM_ERR_SYS, true, "failed to create a nebServer object: %s", nebErr(server));
    1607             nebServerFree(server);
     1606            psError(PM_ERR_SYS, true, "failed to create a nebServer object.");
    16081607            return NULL;
    16091608        }
     
    16261625                return NULL;
    16271626            }
     1627        } else if (create || trunc) {
     1628            // object exists and it looks like the caller intends to write to it
     1629            // delete all but one instance
     1630            if (!nebCullAllButOne(server,filename)) {
     1631                psError(PM_ERR_SYS, true, "failed to cull instances of existing nebulous file: %s\n%s",
     1632                    filename, nebErr(server));
     1633                return NULL;
     1634            }
     1635            // we don't know which instances got culled so get the instance again
     1636            if (!(nebfile = nebFind(server, filename))) {
     1637                psError(PM_ERR_SYS, true, "failed to find instance of existing nebulous file: %s\n%s",
     1638                    filename, nebErr(server));
     1639                return NULL;
     1640            }
    16281641        }
    16291642
Note: See TracChangeset for help on using the changeset viewer.