当 hloop_post_event 与 malloc 内存同时发生时,如果生产 ev 的速度大于处理速度,如何防止崩溃?
作者: WSS0271创建于 2026年3月18日更新于 2026年3月18日
Situation: I need to monitor the alarms of 10+ devices, and there are about dozens of alarms for each type. When an alarm occurs, I will malloc the alarm information, hloop_post_event, and use its processing function to write to the file. Problem: I am worried that the production speed is greater than the consumption speed, and event_queue_push_back will continue to increase the number of messages without any limit. I wonder if it is possible to limit the number of custom_events in the loop, and if it exceeds the expected value, we can just discard it and avoid crashing the memory!
内容来源: ithewei/libhv