Skip to content

Commit

Permalink
fix typo, use better name
Browse files Browse the repository at this point in the history
  • Loading branch information
liudongmiao committed Apr 10, 2024
1 parent 0a9a3b7 commit e26dfde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions wss-proxy-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ static void udp_timeout_cb(evutil_socket_t sock, short event, void *ctx) {
}
}

static struct bufferevent_udp *init_udp_client(struct bufferevent_udp *key, struct udp_context *context,
static struct bufferevent_udp *init_udp_server(struct bufferevent_udp *key, struct udp_context *context,
evutil_socket_t sock, int port) {
struct bufferevent_udp *data;
struct bufferevent *raw;
Expand Down Expand Up @@ -461,7 +461,7 @@ static struct bufferevent_udp *init_udp_client(struct bufferevent_udp *key, stru
return data;
}

static void udp_read_cb_client(evutil_socket_t sock, short event, void *ctx) {
static void udp_read_cb_server(evutil_socket_t sock, short event, void *ctx) {
struct udp_context *context = ctx;
struct bufferevent_udp key, *data;
struct udp_frame udp_frame;
Expand All @@ -474,7 +474,7 @@ static void udp_read_cb_client(evutil_socket_t sock, short event, void *ctx) {
if ((size = udp_read(sock, &udp_frame, key.sockaddr, &(key.socklen))) < 0) {
break;
}
if ((data = init_udp_client(&key, context, sock, get_port(key.sockaddr))) == NULL) {
if ((data = init_udp_server(&key, context, sock, get_port(key.sockaddr))) == NULL) {
break;
}
evbuffer_add(data->be.input, &udp_frame, size + UDP_FRAME_LENGTH_SIZE);
Expand Down Expand Up @@ -520,7 +520,7 @@ static int init_server_context(struct server_context *server_context, struct eve
server_context->udp_context.base = base;
server_context->udp_context.wss_context = wss_context;

server_context->udp_event = event_new(base, server_context->udp_sock, EV_READ | EV_PERSIST, udp_read_cb_client,
server_context->udp_event = event_new(base, server_context->udp_sock, EV_READ | EV_PERSIST, udp_read_cb_server,
&(server_context->udp_context));
if (!server_context->udp_event) {
LOGE("cannot create event for %d", get_port(sockaddr));
Expand Down
4 changes: 2 additions & 2 deletions wss-proxy-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int do_websocket_handshake(struct evhttp_request *req, char *sec_websocke
return 1;
}

static void udp_read_cb_server(evutil_socket_t sock, short event, void *ctx) {
static void udp_read_cb_client(evutil_socket_t sock, short event, void *ctx) {
struct bufferevent *raw = ctx;
struct evhttp_connection *wss = get_wss(raw);
if (event & EV_TIMEOUT) {
Expand Down Expand Up @@ -166,7 +166,7 @@ static struct bufferevent *init_udp_client(struct event_base *base, struct raw_s
raw->input = evbuffer_new();
raw->output = evbuffer_new();
evbuffer_add_cb(raw->output, udp_send_cb, raw);
event_assign(&(raw->ev_read), base, sock, EV_READ | EV_PERSIST, udp_read_cb_server, raw);
event_assign(&(raw->ev_read), base, sock, EV_READ | EV_PERSIST, udp_read_cb_client, raw);
event_add(&(raw->ev_read), &one_minute);
return raw;
error:
Expand Down

0 comments on commit e26dfde

Please sign in to comment.