Fix accept connection logic
This commit is contained in:
parent
4f1c1b3c1b
commit
f7c9b9bcd6
3 changed files with 6 additions and 3 deletions
|
@ -19,6 +19,7 @@ int on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
|||
in_len = sizeof(addr);
|
||||
conn_sock1 = accept(fdinfo->fd, (struct sockaddr*)&addr, &in_len);
|
||||
|
||||
if (conn_sock1 == -1 && errno == EAGAIN) return 1;
|
||||
if (conn_sock1 == -1) goto co_error;
|
||||
conn_sock2 = dup(conn_sock1);
|
||||
if (conn_sock2 == -1) goto co_error;
|
||||
|
@ -36,7 +37,7 @@ int on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
|||
sprintf(to_fdinfo.url, "tcp:write:127.0.0.1:%s", port);
|
||||
evt_core_add_fd (ctx, &to_fdinfo);
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
co_error:
|
||||
perror("Failed to handle new connection");
|
||||
|
|
|
@ -47,6 +47,7 @@ int rr_on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
|||
in_len = sizeof(addr);
|
||||
conn_sock1 = accept(fdinfo->fd, (struct sockaddr*)&addr, &in_len);
|
||||
|
||||
if (conn_sock1 == -1 && errno == EAGAIN) return 1;
|
||||
if (conn_sock1 == -1) goto co_error;
|
||||
conn_sock2 = dup(conn_sock1);
|
||||
if (conn_sock2 == -1) goto co_error;
|
||||
|
@ -64,7 +65,7 @@ int rr_on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
|||
sprintf(to_fdinfo.url, "tcp:write:127.0.0.1:%s", port);
|
||||
evt_core_add_fd (ctx, &to_fdinfo);
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
co_error:
|
||||
perror("Failed to handle new connection");
|
||||
|
|
|
@ -37,6 +37,7 @@ int te_on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
|||
in_len = sizeof(addr);
|
||||
conn_sock1 = accept(fdinfo->fd, (struct sockaddr*)&addr, &in_len);
|
||||
|
||||
if (conn_sock1 == -1 && errno == EAGAIN) return 1;
|
||||
if (conn_sock1 == -1) goto co_error;
|
||||
|
||||
url_get_port(port, fdinfo->url);
|
||||
|
@ -46,7 +47,7 @@ int te_on_tcp_co(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
|||
sprintf(to_fdinfo.url, "tcp:all:127.0.0.1:%s", port);
|
||||
evt_core_add_fd (ctx, &to_fdinfo);
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
co_error:
|
||||
perror("Failed to handle new connection");
|
||||
|
|
Loading…
Reference in a new issue