Skip to content

Commit e410854

Browse files
irfanHaslandedmichalvasko
authored andcommitted
sr_module_change_subscribe URGE locks for Ext SHM
in sr_module_change_subscribe(), the change sub Ext SHM lock should be acquired in a writer preferred manner (WRITE_URGE). Adding a change subscr holds the WRITE lock for a very short duration. But, a change_sub READ lock is held for much longer, because the oper notify diff needs to be determined correctly based on the subscriptions present. So, for modules with frequent writes, subscription can fail due to starvation.
1 parent bdbe383 commit e410854

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/sysrepo.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6514,8 +6514,8 @@ sr_module_change_subscribe(sr_session_ctx_t *session, const char *module_name, c
65146514
_sr_subscription_thread_suspend(*subscription);
65156515
}
65166516

6517-
/* CHANGE SUB WRITE LOCK - also prevents events from being published */
6518-
if ((err_info = sr_rwlock(&shm_mod->change_sub[session->ds].lock, SR_SHMEXT_SUB_LOCK_TIMEOUT, SR_LOCK_WRITE,
6517+
/* CHANGE SUB WRITE URGE LOCK - also prevents events from being published */
6518+
if ((err_info = sr_rwlock(&shm_mod->change_sub[session->ds].lock, SR_SHMEXT_SUB_LOCK_TIMEOUT, SR_LOCK_WRITE_URGE,
65196519
conn->cid, __func__, NULL, NULL))) {
65206520
goto cleanup;
65216521
}
@@ -6571,8 +6571,8 @@ sr_module_change_subscribe(sr_session_ctx_t *session, const char *module_name, c
65716571
subs_mode = SR_LOCK_NONE;
65726572

65736573
error1:
6574-
/* CHANGE SUB WRITE lock - and remove the newly added sub from Ext SHM */
6575-
if ((tmp_err = sr_rwlock(&shm_mod->change_sub[session->ds].lock, SR_SHMEXT_SUB_LOCK_TIMEOUT, SR_LOCK_WRITE,
6574+
/* CHANGE SUB WRITE URGE lock - and remove the newly added sub from Ext SHM */
6575+
if ((tmp_err = sr_rwlock(&shm_mod->change_sub[session->ds].lock, SR_SHMEXT_SUB_LOCK_TIMEOUT, SR_LOCK_WRITE_URGE,
65766576
conn->cid, __func__, NULL, NULL))) {
65776577
sr_errinfo_merge(&err_info, tmp_err);
65786578
}

0 commit comments

Comments
 (0)