MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / max_background_threads_ctl

Function max_background_threads_ctl

deps/jemalloc/src/ctl.c:1686–1743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1684}
1685
1686static int
1687max_background_threads_ctl(tsd_t *tsd, const size_t *mib,
1688 size_t miblen, void *oldp, size_t *oldlenp, void *newp,
1689 size_t newlen) {
1690 int ret;
1691 size_t oldval;
1692
1693 if (!have_background_thread) {
1694 return ENOENT;
1695 }
1696 background_thread_ctl_init(tsd_tsdn(tsd));
1697
1698 malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx);
1699 malloc_mutex_lock(tsd_tsdn(tsd), &background_thread_lock);
1700 if (newp == NULL) {
1701 oldval = max_background_threads;
1702 READ(oldval, size_t);
1703 } else {
1704 if (newlen != sizeof(size_t)) {
1705 ret = EINVAL;
1706 goto label_return;
1707 }
1708 oldval = max_background_threads;
1709 READ(oldval, size_t);
1710
1711 size_t newval = *(size_t *)newp;
1712 if (newval == oldval) {
1713 ret = 0;
1714 goto label_return;
1715 }
1716 if (newval > opt_max_background_threads) {
1717 ret = EINVAL;
1718 goto label_return;
1719 }
1720
1721 if (background_thread_enabled()) {
1722 background_thread_enabled_set(tsd_tsdn(tsd), false);
1723 if (background_threads_disable(tsd)) {
1724 ret = EFAULT;
1725 goto label_return;
1726 }
1727 max_background_threads = newval;
1728 background_thread_enabled_set(tsd_tsdn(tsd), true);
1729 if (background_threads_enable(tsd)) {
1730 ret = EFAULT;
1731 goto label_return;
1732 }
1733 } else {
1734 max_background_threads = newval;
1735 }
1736 }
1737 ret = 0;
1738label_return:
1739 malloc_mutex_unlock(tsd_tsdn(tsd), &background_thread_lock);
1740 malloc_mutex_unlock(tsd_tsdn(tsd), &ctl_mtx);
1741
1742 return ret;
1743}

Callers

nothing calls this directly

Calls 8

tsd_tsdnFunction · 0.50
malloc_mutex_lockFunction · 0.50
malloc_mutex_unlockFunction · 0.50

Tested by

no test coverage detected