diff options
author | irungentoo <irungentoo@gmail.com> | 2015-04-01 13:31:28 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-04-01 13:31:28 -0400 |
commit | a2df5f2f5716e1288ff1cde054fba5651a35f570 (patch) | |
tree | e27583386c6019abc730cde9a9bc30f2baf29d26 /toxcore/TCP_server.c | |
parent | a47fad15e08ab006c235d1203f731570ffea1ba0 (diff) |
Increased max possible amount of TCP connections in TCP server when using epoll.
Diffstat (limited to 'toxcore/TCP_server.c')
-rw-r--r-- | toxcore/TCP_server.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index e85a506d..d7401de8 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -1187,7 +1187,7 @@ static void do_TCP_epoll(TCP_Server *TCP_server) | |||
1187 | 1187 | ||
1188 | for (n = 0; n < nfds; ++n) { | 1188 | for (n = 0; n < nfds; ++n) { |
1189 | sock_t sock = events[n].data.u64 & 0xFFFFFFFF; | 1189 | sock_t sock = events[n].data.u64 & 0xFFFFFFFF; |
1190 | int status = (events[n].data.u64 >> 32) & 0xFFFF, index = (events[n].data.u64 >> 48); | 1190 | int status = (events[n].data.u64 >> 32) & 0xFF, index = (events[n].data.u64 >> 40); |
1191 | 1191 | ||
1192 | if ((events[n].events & EPOLLERR) || (events[n].events & EPOLLHUP) || (events[n].events & EPOLLRDHUP)) { | 1192 | if ((events[n].events & EPOLLERR) || (events[n].events & EPOLLHUP) || (events[n].events & EPOLLRDHUP)) { |
1193 | switch (status) { | 1193 | switch (status) { |
@@ -1241,7 +1241,7 @@ static void do_TCP_epoll(TCP_Server *TCP_server) | |||
1241 | 1241 | ||
1242 | struct epoll_event ev = { | 1242 | struct epoll_event ev = { |
1243 | .events = EPOLLIN | EPOLLET | EPOLLRDHUP, | 1243 | .events = EPOLLIN | EPOLLET | EPOLLRDHUP, |
1244 | .data.u64 = sock_new | ((uint64_t)TCP_SOCKET_INCOMING << 32) | ((uint64_t)index_new << 48) | 1244 | .data.u64 = sock_new | ((uint64_t)TCP_SOCKET_INCOMING << 32) | ((uint64_t)index_new << 40) |
1245 | }; | 1245 | }; |
1246 | 1246 | ||
1247 | if (epoll_ctl(TCP_server->efd, EPOLL_CTL_ADD, sock_new, &ev) == -1) { | 1247 | if (epoll_ctl(TCP_server->efd, EPOLL_CTL_ADD, sock_new, &ev) == -1) { |
@@ -1258,7 +1258,7 @@ static void do_TCP_epoll(TCP_Server *TCP_server) | |||
1258 | 1258 | ||
1259 | if ((index_new = do_incoming(TCP_server, index)) != -1) { | 1259 | if ((index_new = do_incoming(TCP_server, index)) != -1) { |
1260 | events[n].events = EPOLLIN | EPOLLET | EPOLLRDHUP; | 1260 | events[n].events = EPOLLIN | EPOLLET | EPOLLRDHUP; |
1261 | events[n].data.u64 = sock | ((uint64_t)TCP_SOCKET_UNCONFIRMED << 32) | ((uint64_t)index_new << 48); | 1261 | events[n].data.u64 = sock | ((uint64_t)TCP_SOCKET_UNCONFIRMED << 32) | ((uint64_t)index_new << 40); |
1262 | 1262 | ||
1263 | if (epoll_ctl(TCP_server->efd, EPOLL_CTL_MOD, sock, &events[n]) == -1) { | 1263 | if (epoll_ctl(TCP_server->efd, EPOLL_CTL_MOD, sock, &events[n]) == -1) { |
1264 | kill_TCP_connection(&TCP_server->unconfirmed_connection_queue[index_new]); | 1264 | kill_TCP_connection(&TCP_server->unconfirmed_connection_queue[index_new]); |
@@ -1274,7 +1274,7 @@ static void do_TCP_epoll(TCP_Server *TCP_server) | |||
1274 | 1274 | ||
1275 | if ((index_new = do_unconfirmed(TCP_server, index)) != -1) { | 1275 | if ((index_new = do_unconfirmed(TCP_server, index)) != -1) { |
1276 | events[n].events = EPOLLIN | EPOLLET | EPOLLRDHUP; | 1276 | events[n].events = EPOLLIN | EPOLLET | EPOLLRDHUP; |
1277 | events[n].data.u64 = sock | ((uint64_t)TCP_SOCKET_CONFIRMED << 32) | ((uint64_t)index_new << 48); | 1277 | events[n].data.u64 = sock | ((uint64_t)TCP_SOCKET_CONFIRMED << 32) | ((uint64_t)index_new << 40); |
1278 | 1278 | ||
1279 | if (epoll_ctl(TCP_server->efd, EPOLL_CTL_MOD, sock, &events[n]) == -1) { | 1279 | if (epoll_ctl(TCP_server->efd, EPOLL_CTL_MOD, sock, &events[n]) == -1) { |
1280 | //remove from confirmed connections | 1280 | //remove from confirmed connections |