MOD aaa-12 解决死锁问题,并将客户端线程调整为1个

SOL 解决死锁问题,并将客户端线程调整为1个
修改人:zhangliang
检视人:zhangliang
This commit is contained in:
zhanglianghy 2019-06-27 11:12:28 +08:00
parent 277ad370c3
commit 83f9907001
5 changed files with 13 additions and 4 deletions

View File

@ -16,7 +16,7 @@
#include <pthread.h>
#include <ev.h>
#define CLIENT_CONN_NUM 3
#define CLIENT_CONN_NUM 1
struct _rpc_dispatch_thread {
pthread_t thread_id;

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -317,6 +317,8 @@ static void* thread_write_hander(void* data) {
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);
rpc_send_message(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;