Skip to content

Commit

Permalink
feat: use "closed" as error msg for write and send when errno i…
Browse files Browse the repository at this point in the history
…s `EPIPE`

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Sep 16, 2023
1 parent 5d51a19 commit 9f85bbf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ static int eco_file_write_data(lua_State *L, int fd, const void *data, size_t le
if (errno == EINTR)
goto again;
lua_pushnil(L);
lua_pushstring(L, strerror(errno));
if (errno == EPIPE)
lua_pushliteral(L, "closed");
else
lua_pushstring(L, strerror(errno));
return 2;
}

Expand Down
5 changes: 4 additions & 1 deletion socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ static int eco_socket_send(lua_State *L)
if (errno == EINTR)
goto again;
lua_pushnil(L);
lua_pushstring(L, strerror(errno));
if (errno == EPIPE)
lua_pushliteral(L, "closed");
else
lua_pushstring(L, strerror(errno));
return 2;
}

Expand Down

0 comments on commit 9f85bbf

Please sign in to comment.