From 7a88ab75ec5645d70fe8a7ce0dc128ea87f2273a Mon Sep 17 00:00:00 2001 From: guo_peixu Date: Wed, 22 Jun 2022 18:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E8=BF=9B=E8=A1=8Csnprintf=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=EF=BC=8C=E8=BF=9B=E8=A1=8C=E7=BC=93=E5=86=B2=E5=8C=BA?= =?UTF-8?q?=E7=9A=84=E5=88=A4=E6=BB=A1=EF=BC=8C=E6=8F=90=E9=AB=98=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=95=88=E7=8E=87=E3=80=82=E5=8E=BB=E6=8E=89=E6=97=A0?= =?UTF-8?q?=E6=84=8F=E4=B9=89=E7=9A=84goto=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shm_consumer/MESA_shm_consumer.c | 3 +-- src/MESA_handle_logger.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shm_consumer/MESA_shm_consumer.c b/shm_consumer/MESA_shm_consumer.c index 9ff435a..f240fdf 100644 --- a/shm_consumer/MESA_shm_consumer.c +++ b/shm_consumer/MESA_shm_consumer.c @@ -524,7 +524,7 @@ int main(int argc, char **argv) if(g_care_pid == CONSUMER_CARE_PID_SPEC){ if(!producer_pid_is_cared(tmp_ovw->producer_pid)){ MESA_shm_ring_queue_set_empty(ring_queue_head[i]); - goto next; + break ; } } if(g_output_mode == CONSUMER_OUTPUT_MODE_FILE){ @@ -534,7 +534,6 @@ int main(int argc, char **argv) } } } - next: usleep(5000); } return 0; diff --git a/src/MESA_handle_logger.c b/src/MESA_handle_logger.c index 900b9ee..4e7107b 100644 --- a/src/MESA_handle_logger.c +++ b/src/MESA_handle_logger.c @@ -346,6 +346,9 @@ void MESA_handle_runtime_log(void *handle, int level, const char *module, const } pthread_setspecific(MESA_pthread_key,(void*)pri); } + if(MESA_shm_ring_queue_is_full(pri->ring_queue_head)){ + return ; + } portable_vsnprintf(handle, pri->cache_buf, pri->cache_buf_len, fmt, ap); MESA_shm_copy_buf_to_ring_queue(pri->cache_buf, pri->cache_buf_len, pri->ring_queue_head, p_handle->real_log_file,p_handle->real_log_file_len); zlog(p_handle->zc, p_handle->runtime_log_file, strlen(p_handle->runtime_log_file), module, strlen(module), __LINE__, level, "%s", pri->cache_buf);