From 3c6f9ca096e9d046f9a1edbd5cfb131b93feffeb Mon Sep 17 00:00:00 2001 From: fengzero Date: Mon, 11 Dec 2023 07:47:48 +0000 Subject: [PATCH] Revert "fix(conn): lock conn buf" This reverts commit 1151bb43b8f47209156a3b065acf15a540b03c4c. --- src/connection/connection.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/connection/connection.c b/src/connection/connection.c index bc440525..4a2b87fb 100644 --- a/src/connection/connection.c +++ b/src/connection/connection.c @@ -1274,18 +1274,19 @@ int neu_conn_stream_consume(neu_conn_t *conn, void *context, ssize_t ret = neu_conn_recv(conn, conn->buf + conn->offset, conn->buf_size - conn->offset); if (ret > 0) { - pthread_mutex_lock(&conn->mtx); zlog_recv_protocol(conn->param.log, conn->buf + conn->offset, ret); conn->offset += ret; neu_protocol_unpack_buf_t protocol_buf = { 0 }; neu_protocol_unpack_buf_init(&protocol_buf, conn->buf, conn->offset); - int used = 0; while (neu_protocol_unpack_buf_unused_size(&protocol_buf) > 0) { - used = fn(context, &protocol_buf); + int used = fn(context, &protocol_buf); zlog_debug(conn->param.log, "buf used: %d offset: %d", used, conn->offset); - if (used == 0 || used == -1) { + if (used == 0) { + break; + } else if (used == -1) { + neu_conn_disconnect(conn); break; } else { conn->offset -= used; @@ -1294,10 +1295,6 @@ int neu_conn_stream_consume(neu_conn_t *conn, void *context, conn->offset); } } - pthread_mutex_unlock(&conn->mtx); - if (used == -1) { - neu_conn_disconnect(conn); - } } return ret;