Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Use __thread (thread-local storage) keyword for pthread-safe#113

Open
kyeongy wants to merge 1 commit intokravietz:masterfrom
kyeongy:mt
Open

Use __thread (thread-local storage) keyword for pthread-safe#113
kyeongy wants to merge 1 commit intokravietz:masterfrom
kyeongy:mt

Conversation

@kyeongy
Copy link
Contributor

@kyeongy kyeongy commented Feb 28, 2018

C99 supports Thread-Local Storage:
https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Thread_002dLocal.html

This patch makes use of "__thread" storage class keyword to make the code
pthread-safe without changing the code much:

  • Changed all global variables which can be modified by multiple threads
  • Changed static varible in tac_ntop()
  • Removed unnecessary "static" from local variable in _pam_account()

C99 supports Thread-Local Storage:
  https://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Thread_002dLocal.html

This patch makes use of "__thread" storage class keyword to make the code
pthread-safe without changing the code much:

- Changed all global variables which can be modified by multiple threads
- Changed static varible in tac_ntop()
- Removed unnecessary "static" from local variable in _pam_account()
@kravietz kravietz self-assigned this Dec 13, 2018
@kravietz
Copy link
Owner

Hi @kyeongy did you test if it works on older compilers as well?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants