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

Function prof_thread_name_set

deps/jemalloc/src/prof.c:2816–2852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2814}
2815
2816int
2817prof_thread_name_set(tsd_t *tsd, const char *thread_name) {
2818 prof_tdata_t *tdata;
2819 unsigned i;
2820 char *s;
2821
2822 tdata = prof_tdata_get(tsd, true);
2823 if (tdata == NULL) {
2824 return EAGAIN;
2825 }
2826
2827 /* Validate input. */
2828 if (thread_name == NULL) {
2829 return EFAULT;
2830 }
2831 for (i = 0; thread_name[i] != '\0'; i++) {
2832 char c = thread_name[i];
2833 if (!isgraph(c) && !isblank(c)) {
2834 return EFAULT;
2835 }
2836 }
2837
2838 s = prof_thread_name_alloc(tsd_tsdn(tsd), thread_name);
2839 if (s == NULL) {
2840 return EAGAIN;
2841 }
2842
2843 if (tdata->thread_name != NULL) {
2844 idalloctm(tsd_tsdn(tsd), tdata->thread_name, NULL, NULL, true,
2845 true);
2846 tdata->thread_name = NULL;
2847 }
2848 if (strlen(s) > 0) {
2849 tdata->thread_name = s;
2850 }
2851 return 0;
2852}
2853
2854bool
2855prof_thread_active_get(tsd_t *tsd) {

Callers 1

thread_prof_name_ctlFunction · 0.70

Calls 4

prof_thread_name_allocFunction · 0.70
isblankFunction · 0.50
tsd_tsdnFunction · 0.50
idalloctmFunction · 0.50

Tested by

no test coverage detected