Skip to content

Commit f186297

Browse files
committed
fix TCP_NODELAY error
1 parent 0417848 commit f186297

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

stubs/socket.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ std::unordered_map<int, std::unordered_map<int, int>> SOCK_OPTS = {
7676
{21, 4101},
7777
}},
7878
{6,
79-
{{1, TCP_NODELAY}}}};
79+
{{LEVEL_TRANSLATE, IPPROTO_TCP},
80+
{1, TCP_NODELAY}}}};
8081

8182
int translateSockOpt(int *level, int *option_name)
8283
{
@@ -134,11 +135,14 @@ int jmp_setsockopt(int socket, int level, int option_name,
134135
}
135136

136137
int ret = setsockopt(socket, lvl, opt_name, option_value, option_len);
137-
if (ret < 0) {
138+
if (ret < 0)
139+
{
138140
printf("setsockopt error socket=%d level=%d optname=%d, errno=%d\n", socket, level, option_name, errno);
139141

140142
// just act like its successful
141-
if (lvl == IPPROTO_TCP && opt_name == SO_KEEPALIVE && errno == EINVAL) {
143+
// maybe it doesnt like changing TCP_NODELAY while its connecting?
144+
if (lvl == IPPROTO_TCP && opt_name == TCP_NODELAY && errno == EINVAL)
145+
{
142146
errno = 0;
143147
return 0;
144148
}

0 commit comments

Comments
 (0)