Loading...
Searching...
No Matches
Locking API

## Functions

int | sr_get_lock (sr_conn_ctx_t *conn, sr_datastore_t datastore, const char *module_name, int *is_locked, uint32_t *id, struct timespec *timestamp)
| Check whether the data of the specified module or the whole datastore are locked.
int | sr_lock (sr_session_ctx_t *session, const char *module_name, uint32_t timeout_ms)
| Locks the data of the specified module or the whole datastore.
int | sr_unlock (sr_session_ctx_t *session, const char *module_name)
| Unlocks the data of the specified module or the whole datastore.

## Detailed Description

## Function Documentation

## sr_get_lock()

int sr_get_lock | ( | sr_conn_ctx_t * | conn,
|  | sr_datastore_t | datastore,
|  | const char * | module_name,
|  | int * | is_locked,
|  | uint32_t * | id,
|  | struct timespec * | timestamp )

Check whether the data of the specified module or the whole datastore are locked.

Note that if whole datastore is checked, `is_locked` will be set only if all the modules are locked by the same Sysrepo session. If a module is not locked or locked by another Sysrepo session, `is_locked` will be false.

Parameters

  [in] | conn | Connection to use.
  [in] | datastore | Datastore of the lock.
  [in] | module_name | Optional name of the module to check.
  [out] | is_locked | True is the module or whole datastore is locked.
  [out] | id | Optional Sysrepo SID of the session if the module/datastore is locked.
  [out] | timestamp | Optional timestamp of the lock.

Returns
  Error code (SR_ERR_OK on success).

## sr_lock()

int sr_lock | ( | sr_session_ctx_t * | session,
|  | const char * | module_name,
|  | uint32_t | timeout_ms )

Locks the data of the specified module or the whole datastore.

Note
  Note that locking candidate datastore after it has already been modified is not allowed. Session needs to acquire this lock before it or any other session performs any changes.
  This lock will be automatically released when the session is stopped.

Required READ access.

Parameters

  [in] | session | Session (DS-specific) to use.
  [in] | module_name | Optional name of the module to be locked.
  [in] | timeout_ms | Timeout in milliseconds for waiting for the lock(s). If 0, no waiting is performed.

Returns
  Error code (SR_ERR_OK on success).

## sr_unlock()

int sr_unlock | ( | sr_session_ctx_t * | session,
|  | const char * | module_name )

Unlocks the data of the specified module or the whole datastore.

Required READ access.

Parameters

  [in] | session | Session (DS-specific) to use.
  [in] | module_name | Optional name of the module to be unlocked.

Returns
  Error code (SR_ERR_OK on success).