From 83f9907001c729633c558b3295624ddef60b04f4 Mon Sep 17 00:00:00 2001 From: zhanglianghy Date: Thu, 27 Jun 2019 11:12:28 +0800 Subject: [PATCH] =?UTF-8?q?MOD=20aaa-12=20=E8=A7=A3=E5=86=B3=E6=AD=BB?= =?UTF-8?q?=E9=94=81=E9=97=AE=E9=A2=98=EF=BC=8C=E5=B9=B6=E5=B0=86=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E7=BA=BF=E7=A8=8B=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?1=E4=B8=AA=20SOL=20=E8=A7=A3=E5=86=B3=E6=AD=BB=E9=94=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=B9=B6=E5=B0=86=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E7=BA=BF=E7=A8=8B=E8=B0=83=E6=95=B4=E4=B8=BA1?= =?UTF-8?q?=E4=B8=AA=20=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9Azhangliang=20?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E4=BA=BA=EF=BC=9Azhangliang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Platform/common/rpc/rpc_thread.h | 2 +- Platform/user/rpc/rpc_client.c | 2 ++ Platform/user/rpc/rpc_conn.c | 1 + Platform/user/rpc/rpc_request.c | 2 ++ Platform/user/rpc/rpc_thread.c | 10 +++++++--- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Platform/common/rpc/rpc_thread.h b/Platform/common/rpc/rpc_thread.h index d5f62e8db..8455ad8ae 100755 --- a/Platform/common/rpc/rpc_thread.h +++ b/Platform/common/rpc/rpc_thread.h @@ -16,7 +16,7 @@ #include #include -#define CLIENT_CONN_NUM 3 +#define CLIENT_CONN_NUM 1 struct _rpc_dispatch_thread { pthread_t thread_id; diff --git a/Platform/user/rpc/rpc_client.c b/Platform/user/rpc/rpc_client.c index 23c9224d0..285371524 100755 --- a/Platform/user/rpc/rpc_client.c +++ b/Platform/user/rpc/rpc_client.c @@ -224,6 +224,8 @@ ret_code rpc_client_call_async(rpc_client* client, char* service_name, conn = (rpc_conn*) rpc_array_index(th->req_conns, idx); th->last_conn = idx; + rpc_log_dbg("rpc_client_call_async:send_message\n"); + //write data rpc_request_format(req, conn); rpc_send_message(conn); diff --git a/Platform/user/rpc/rpc_conn.c b/Platform/user/rpc/rpc_conn.c index 09fa3b8b6..6e9199b15 100755 --- a/Platform/user/rpc/rpc_conn.c +++ b/Platform/user/rpc/rpc_conn.c @@ -407,6 +407,7 @@ static inline void rpc_send_response(rpc_conn *conn, ret_code code, if (output) { rpc_conn_addiov(conn, output, output_len); } + rpc_log_dbg("rpc_send_response: %s\n", data); rpc_send_message(conn); } diff --git a/Platform/user/rpc/rpc_request.c b/Platform/user/rpc/rpc_request.c index 22f6f6c7c..2ba7d4374 100755 --- a/Platform/user/rpc/rpc_request.c +++ b/Platform/user/rpc/rpc_request.c @@ -174,6 +174,8 @@ void rpc_request_format(const rpc_request *request, rpc_conn *c) { //body len data = rpc_vsprintf("body-len:%d\n\n", request->input_len); rpc_conn_addiov(c, data, strlen(data)); + + rpc_log_dbg("request data:%s\n", data); //body if (request->input) rpc_conn_addiov(c, request->input, request->input_len); diff --git a/Platform/user/rpc/rpc_thread.c b/Platform/user/rpc/rpc_thread.c index 7e10ac597..f1cae7460 100755 --- a/Platform/user/rpc/rpc_thread.c +++ b/Platform/user/rpc/rpc_thread.c @@ -316,6 +316,8 @@ static void* thread_write_hander(void* data) { idx = (th->last_conn + 1) % (th->req_conn_count); conn = (rpc_conn*) rpc_array_index(th->req_conns, idx); th->last_conn = idx; + + rpc_log_dbg("thread_write_hander:send_message\n"); //write data rpc_request_format(req, conn); @@ -326,11 +328,13 @@ static void* thread_write_hander(void* data) { static void* thread_client_handler(void* data) { rpc_client_thread *th = data; - pthread_mutex_t mutex = th->client->mutex; - pthread_mutex_lock(&mutex); + + //pthread_mutex_t mutex = th->client->mutex; + + pthread_mutex_lock(&(th->client->mutex); th->client->init_count++; pthread_cond_signal(&(th->client->cond)); - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&(th->client->mutex); th->thread_receive_id = pthread_self(); ev_run(th->loop, 0); return NULL;