Skip to content

Commit db9d251

Browse files
committed
* FIX [ringbus] Fix aio == NULL error
Signed-off-by: Moi Ran <maoyi.ran@emqx.io>
1 parent dfce08e commit db9d251

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/supplemental/nanolib/ringbuffer/ringbuffer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,10 @@ put_msgs_to_aio(ringBuffer_t *rb, nng_aio *aio)
861861
{
862862
int ret = 0;
863863
int *list_len = NULL;
864+
if (aio == NULL) {
865+
log_error("aio is NULL for RB_FULL_RETURN\n");
866+
return -1;
867+
}
864868

865869
/* get all msgs and clean ringbuffer */
866870
nni_msg **list = NULL;
@@ -936,6 +940,11 @@ int ringBuffer_enqueue(ringBuffer_t *rb,
936940
}
937941
if (rb->fullOp == RB_FULL_RETURN) {
938942
log_info("RB_FULL_RETURN");
943+
if (aio == NULL) {
944+
log_error("Ring buffer is full but aio is NULL under RB_FULL_RETURN\n");
945+
nng_mtx_unlock(rb->ring_lock);
946+
return -1;
947+
}
939948
ret = put_msgs_to_aio(rb, aio);
940949
if (ret != 0) {
941950
log_error("Ring buffer is full and put msgs to aio failed!\n");

0 commit comments

Comments
 (0)