Skip to content

Commit 1c54b2a

Browse files
adding debbuging statements and minor fix in exit condition of send_response()
1 parent 28fba9d commit 1c54b2a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/core/client.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <fcntl.h>
66
#include <unistd.h>
77

8+
#include <iostream>
9+
810
void Client::set_handler(Handler* handler)
911
{
1012
handler_ = handler;
@@ -46,6 +48,7 @@ Client::Client(int fd, const sockaddr_in& addr)
4648

4749
{
4850
set_nonblocking();
51+
std::cout << "Client constructor called" << std::endl;
4952
}
5053

5154
Client::~Client()
@@ -56,6 +59,7 @@ Client::~Client()
5659
if (handler_) {
5760
delete (handler_);
5861
}
62+
std::cout << "Client destructor called" << std::endl;
5963
}
6064

6165
void Client::set_nonblocking()

src/core/server.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,16 @@ void Server::send_response(Client* conn)
231231
conn->flush_send_bufffer();
232232

233233
if (conn->send_buffer().empty()) {
234+
std::cout << "calling on writable" << std::endl;
234235
conn->on_writable();
235236
}
236-
if (conn->handler_is_done() && conn->send_buffer().empty()) {
237+
// if (conn->handler_is_done() && conn->send_buffer().empty()) {
238+
if (conn->handler_is_done()) {
237239
// assuming HTTP/1.0 for testing
238240
if (epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, conn->fd(), NULL) == -1) {
239241
throw UnrecoverableError("epoll_ctl", errno);
240242
}
243+
std::cout << "attempting to remove the connection" << std::endl;
241244
remove_connection(conn);
242245
}
243246
}

0 commit comments

Comments
 (0)