Every time the telemetry server successfully returns from the accept, it atomically increases the value of num_clients(if < MAX_CONNECTIONS) and then executes pthread_create to create a thread to execute the client_handler function. In this function, some information will be written to the client. If the write fails, the thread returns NULL without atomically reducing num_clients, this will cause the Telemetry server to run for a period of time, and the value of num_clients will be greater than 10, resulting in telemetry being unavailable. Therefore, the decrease in atomicity v2_clients should occur after the write() failure
Thanks for the report. A call to write() failing is likely a sign that something is wrong with the system but the analysis looks correct to me. A fix could be to add a out: label at the end of the function, and jump to this label if write() fails. Can you send a patch or do you prefer someone from the dpdk community handles it?
Fix patch sent by reporter - thanks! https://patches.dpdk.org/project/dpdk/patch/tencent_69E4B1D2B6C0865DA223940C173EC4904506@qq.com/