qinguoyi / TinyWebServer

:fire: Linux下C++轻量级WebServer服务器
Apache License 2.0
15.85k stars 3.81k forks source link

m_user_count不是原子量在工作线程中自减是否会产生问题? #229

Open streamyy opened 1 year ago

streamyy commented 1 year ago

在http_conn类里面的m_user_count在process()函数里面会调用close_conn()自减,process()函数是在工作线程中调用,m_user_count不是原子量是不是会导致计数结果不准确?

qinguoyi commented 1 year ago

会,这里需要加锁