Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

Resource Locks

It is expected that you process resource updates without permitting user interactions to occur during the actual update. It is important for performance considerations and c-treeDB API assumes that resource entries will be locked only for very short intervals. Do not lock a resource and then request user input. Be careful not to include resource updates, (additions, deletions or updates), in long held transactions when the table is under transaction processing control. Locks cannot be released until a transaction either commits or aborts.

c-treeDB API resource handling automatically unlocks resources when necessary. A resource can be manually unlocked by the user. Use the following function to check if a resource is locked or not:

CTBOOL ctdbDECL ctdbIsResourceLocked(CTHANDLE resource);


  • resource is a resource handle allocated by ctdbAllocHandle().

ctdbIsResourceLocked() returns YES if the resource referenced by the resource handle is locked, otherwise it returns NO.

The following function should be used to unlock resources whose locks are no longer necessary:

CTDBRET ctdbDECL ctdbUnlockResource(CTHANDLE resource);

ctdbUnlockResource() releases a lock placed on a resource by one of the following read resource functions: ctdbFirstResource(), ctdbNextResource(), ctdbFindResource() or ctdbFindResourceByName().


ctdbUnlockResource() returns CTDBRET_OK on success.

If a resource is not locked, ctdbUnlockResource() performs no operation and returns CTDBRET_OK.

c-treeDB API C API Resource Unlocking Example

if (ctdbIsResourceLocked(resource))