Add simple http request function

This commit is contained in:
Vitaliy Filippov
2020-04-11 12:05:58 +03:00
parent 0880a77c1a
commit 298b013eae
6 changed files with 299 additions and 33 deletions
+26 -17
View File
@@ -245,27 +245,36 @@ restart:
}
else
{
auto & cl = clients[events[i].data.fd];
if (cl.peer_state == PEER_CONNECTING)
auto cl_it = clients.find(events[i].data.fd);
if (cl_it != clients.end())
{
// Either OUT (connected) or HUP
handle_connect_result(cl.peer_fd);
}
else if (events[i].events & EPOLLRDHUP)
{
// Stop client
printf("osd: client %d disconnected\n", cl.peer_fd);
stop_client(cl.peer_fd);
auto & cl = cl_it->second;
if (cl.peer_state == PEER_CONNECTING)
{
// Either OUT (connected) or HUP
handle_connect_result(cl.peer_fd);
}
else if (events[i].events & EPOLLRDHUP)
{
// Stop client
printf("osd: client %d disconnected\n", cl.peer_fd);
stop_client(cl.peer_fd);
}
else
{
// Mark client as ready (i.e. some data is available)
cl.read_ready++;
if (cl.read_ready == 1)
{
read_ready_clients.push_back(cl.peer_fd);
ringloop->wakeup();
}
}
}
else
{
// Mark client as ready (i.e. some data is available)
cl.read_ready++;
if (cl.read_ready == 1)
{
read_ready_clients.push_back(cl.peer_fd);
ringloop->wakeup();
}
auto & cb = epoll_handlers[events[i].data.fd];
cb(events[i].events, events[i].data.fd);
}
}
}