From ebdb08a55d8b2862ded361566c763220668a78bb Mon Sep 17 00:00:00 2001 From: Brian Boru Date: Wed, 16 Dec 2020 17:35:10 +0200 Subject: [PATCH] fix --- test/jsonrpc_srv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/jsonrpc_srv.c b/test/jsonrpc_srv.c index 8bb2ff2..ba6ec06 100644 --- a/test/jsonrpc_srv.c +++ b/test/jsonrpc_srv.c @@ -4,7 +4,7 @@ net_srv_t *srv; int is_active = 1; jsonrpc_method_array_t *methods; -ev_id_t id_conn = 0; +ev_fd_t fd_conn = 0; pthread_rwlock_t locker; static void sigexit (int sig) { @@ -19,8 +19,8 @@ static void _connect () { if (!is_active) return; pthread_rwlock_wrlock(&locker); - while (0 == id_conn) { - id_conn = net_ev_connect(srv, CONST_STR_LEN("ws://127.0.0.1:7878/api/v2")); + while (0 == fd_conn) { + fd_conn = net_ev_connect(srv, CONST_STR_LEN("ws://127.0.0.1:7878/api/v2")); sleep(8); } pthread_rwlock_unlock(&locker); @@ -42,7 +42,7 @@ static int on_handle (ev_buf_t *ev) { return NET_OK; if (!jsonrpc_is_response(&ev->data.json.jsonrpc)) { if ((rc = jsonrpc_execute_parsed(&ev->buf, WS_EV_OFFSET(ev), methods, ev, &ev->data.json.jsonrpc)) < 0) - rc = ws_ev_send(srv, ev->id, 0, ev->buf.ptr, ev->buf.len, WS_FIN, WS_TEXT); + rc = ws_ev_send(srv, ev->fd, 0, ev->buf.ptr, ev->buf.len, WS_FIN, WS_TEXT); else rc = NET_OK; } else { @@ -73,7 +73,7 @@ static int cb_login (strbuf_t *buf, void *userdata) { static int login (strbuf_t *buf, json_item_t **params, size_t params_len, intptr_t id, int id_len, void *userdata) { cstr_t *s_login = mkcstr(params[0]->data.s.ptr, params[0]->data.s.len); ev_buf_t *ev = userdata; - ws_jsonrpc_response_send(srv, ev->id, buf, id, id_len, cb_login, s_login); + ws_jsonrpc_response_send(srv, ev->fd, buf, id, id_len, cb_login, s_login); free(s_login); return 0; } @@ -85,7 +85,7 @@ static int cb_ok (strbuf_t *buf, void *dummy) { static int getprops (strbuf_t *buf, json_item_t **params, size_t params_len, intptr_t id, int id_len, void *userdata) { ev_buf_t *ev = userdata; - ws_jsonrpc_response_send(srv, ev->id, buf, id, id_len, cb_ok, NULL); + ws_jsonrpc_response_send(srv, ev->fd, buf, id, id_len, cb_ok, NULL); return 0; } @@ -117,8 +117,8 @@ json_t *_send (char *method, size_t method_len, uint32_t flags, strbuf_t *buf, j if (!is_active) return NULL; pthread_rwlock_rdlock(&locker); - if (id_conn > 0) - json = ws_jsonrpc_request_send(srv, id_conn, method, method_len, flags, buf, cb, userdata); + if (fd_conn > 0) + json = ws_jsonrpc_request_send(srv, fd_conn, method, method_len, flags, buf, cb, userdata); pthread_rwlock_unlock(&locker); if (json && -1 != (intptr_t)json) return json; @@ -164,7 +164,7 @@ static void term () { json_free(json); if (buf.ptr) free(buf.ptr); - ws_ev_disconnect(srv, id_conn); + ws_ev_disconnect(srv, fd_conn); ws_srv_done(srv); } @@ -193,7 +193,7 @@ int main (int argc, const char *argv[]) { srv->tm_recv = 8; pthread_create(&th, NULL, on_start, NULL); sleep(1); - if (0 == (id_conn = net_ev_connect(srv, CONST_STR_LEN("wss://127.0.0.1:7878/api/v2")))) { + if (0 == (fd_conn = net_ev_connect(srv, CONST_STR_LEN("wss://127.0.0.1:7878/api/v2")))) { printf("(%d) %s\n", errno, strerror(errno)); sslws_srv_done(srv); free(methods); -- 2.11.4.GIT