MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_pthread_tls_set

Function acl_pthread_tls_set

lib_acl/src/thread/acl_pthread.c:800–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798}
799
800int acl_pthread_tls_set(acl_pthread_key_t key, void *ptr,
801 void (*free_fn)(void *))
802{
803 const char *myname = "acl_pthread_tls_set";
804 TLS_CTX *tls_ctxes;
805
806 if ((long) key >= acl_tls_ctx_max) {
807 acl_msg_error("%s(%d): key(%ld) invalid",
808 myname, __LINE__, (long) key);
809 acl_set_error(ACL_EINVAL);
810 return ACL_EINVAL;
811 }
812
813 if (__tls_ctx_key == (acl_pthread_key_t) ACL_TLS_OUT_OF_INDEXES) {
814 acl_msg_error("%s(%d): __tls_ctx_key invalid, tid(%lu)",
815 myname, __LINE__, (unsigned long) acl_pthread_self());
816 acl_set_error(ACL_ENOMEM);
817 return ACL_ENOMEM;
818 }
819 tls_ctxes = (TLS_CTX*) acl_pthread_getspecific(__tls_ctx_key);
820 if (tls_ctxes == NULL) {
821 acl_msg_error("%s(%d): __tls_ctx_key(%ld) no exist",
822 myname, __LINE__, (long) __tls_ctx_key);
823 return -1;
824 }
825 if (tls_ctxes[(long) key].key != key) {
826 acl_msg_error("%s(%d): key(%ld) invalid",
827 myname, __LINE__, (long) key);
828 acl_set_error(ACL_EINVAL);
829 return ACL_EINVAL;
830 }
831 /* ����ü�ֵ���ھ�������������Ҫ�ͷŵ������� */
832 if (tls_ctxes[(long) key].ptr != NULL && tls_ctxes[(long) key].free_fn != NULL) {
833 tls_ctxes[(long) key].free_fn(tls_ctxes[(long) key].ptr);
834 }
835
836 tls_ctxes[(long) key].free_fn = free_fn;
837 tls_ctxes[(long) key].ptr = ptr;
838 return 0;
839}
840
841int acl_pthread_tls_del(acl_pthread_key_t key)
842{

Callers 12

test_tls_threadFunction · 0.85
test_once_threadFunction · 0.85
acl_getenvFunction · 0.85
acl_getenv_listFunction · 0.85
get_tls_bufFunction · 0.85
acl_token_name1Function · 0.85
acl_aio_iocp_closeFunction · 0.85
dat_filepathFunction · 0.85
dat_pathFunction · 0.85
http_hdr_res_newFunction · 0.85
http_hdr_req_newFunction · 0.85
http_hdr_req_urlFunction · 0.85

Calls 4

acl_msg_errorFunction · 0.85
acl_set_errorFunction · 0.85
acl_pthread_selfFunction · 0.85
acl_pthread_getspecificFunction · 0.85

Tested by 2

test_tls_threadFunction · 0.68
test_once_threadFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…