lpereira / lwan

Experimental, scalable, high performance HTTP server
https://lwan.ws
GNU General Public License v2.0
5.92k stars 549 forks source link

some atomic operations in lwan maybe wrong? #67

Closed littletiny closed 9 years ago

littletiny commented 9 years ago

line 542 in common/lwan.c static volatile sig_atomic_t main_socket = -1;

in c/c++, volatile cannot ensure memory visible and atomic atomic variable fetch and store can ensure memory visible and memory barrier i think, change it to

volatile sig_atomic_t main_socket = -1;

is ok

line 54 in common/lwan-status.c

static volatile bool quiet = false;

the variable quiet may be used in multithreading same as the first question, volatile cannot ensure atomic gcc provide _sync* function to do a atomic operation,c11 and c++11 also has a standard atomic operation

littletiny commented 9 years ago

Sorry, i have misunderstood it.