Skip to content

Commit e7fff50

Browse files
committed
Cleanup
1 parent baaa832 commit e7fff50

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

include/asyncServer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ class StateMgmt : public StateMgmtIntf {
7575
m_server(_server),
7676
initPrepfunc_(initPrepFunc),
7777
handlerfunc_(handlerFunc) {
78-
std::cout <<"StateMgmt constructor called" << std::endl;
78+
// std::cout <<"StateMgmt constructor called" << std::endl;
7979
Proceed();
8080
}
8181
virtual ~StateMgmt() {
82-
std::cout <<this<<" destructed"<<std::endl;
82+
// std::cout <<this<<" destructed"<<std::endl;
8383
}
8484
void Proceed(io_uring_cqe *cqe = nullptr) {
8585
switch (status_) {

src/asyncServer.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ AsyncServer::AsyncServer() {
1111
}
1212

1313
AsyncServer::~AsyncServer() {
14-
std::cout <<"AsyncServer desctructed" << std::endl;
14+
// std::cout <<"AsyncServer desctructed" << std::endl;
1515
// io_uring_queue_exit(ring_);
1616
};
1717

@@ -49,7 +49,7 @@ void AsyncServer::Run() {
4949
sockfd_sctp = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
5050
}
5151

52-
if (sockfd_tcp < 0 || sockfd_udp < 0 || sockfd_sctp < 0) {
52+
if (sockfd_tcp < 0 && sockfd_udp < 0 && sockfd_sctp < 0) {
5353
perror("socket");
5454
// return;
5555
}
@@ -107,10 +107,10 @@ void AsyncServer::Run() {
107107
void AsyncServer::InitiateRequest() {
108108
/******* prepare and define the handler functions for read operation ******/
109109
auto prep_RECV = [this](StateMgmtIntf* instance) {
110-
std::cout << __FUNCTION__ <<" called prep_RECV"<< std::endl;
111-
//std::lock_guard<std::mutex> lock(mtx);
112-
std::cout <<"> this : "<<this << std::endl;
113-
std::cout <<"> this ring : "<<this->ring_ << std::endl;
110+
// std::cout << __FUNCTION__ <<" called prep_RECV"<< std::endl;
111+
// std::lock_guard<std::mutex> lock(mtx);
112+
// std::cout <<"> this : "<<this << std::endl;
113+
// std::cout <<"> this ring : "<<this->ring_ << std::endl;
114114
auto sqe = io_uring_get_sqe(this->ring_);
115115
io_uring_prep_rw(IORING_OP_RECV, sqe,instance->getReadFd(),
116116
instance->getBuffer(), READ_BUF_SIZE, 0);
@@ -121,8 +121,8 @@ void AsyncServer::InitiateRequest() {
121121
}
122122
};
123123
auto handle_CQE_PrintMsg = [this](StateMgmtIntf* instance,io_uring_cqe *cqe) {
124-
std::cout << __FUNCTION__ <<" called handle_CQE_PrintMsg"<< std::endl;
125-
std::cout <<"Number of bytes read : " << cqe->res << std::endl;
124+
//std::cout << __FUNCTION__ <<" called handle_CQE_PrintMsg"<< std::endl;
125+
// std::cout <<"Number of bytes read : " << cqe->res << std::endl;
126126
std::string x((char*)(instance->getBuffer()),cqe->res/*TODO replace with ??*/);
127127
std::cout <<"Client data : " << x << std::endl;
128128
return true;
@@ -140,10 +140,10 @@ void AsyncServer::InitiateRequest() {
140140

141141
/***** prepare and define the handler functions for accept Operation ******/
142142
auto prep_ACCEPT = [this](StateMgmtIntf* instance) {
143-
std::cout << __FUNCTION__ <<" called prep_ACCEPT"<< std::endl;
143+
// std::cout << __FUNCTION__ <<" called prep_ACCEPT"<< std::endl;
144144
//std::lock_guard<std::mutex> lock(mtx);
145-
std::cout <<"# this : "<<this << std::endl;
146-
std::cout <<"# this ring : "<<this->ring_ << std::endl;
145+
// std::cout <<"# this : "<<this << std::endl;
146+
// std::cout <<"# this ring : "<<this->ring_ << std::endl;
147147
auto sqe = io_uring_get_sqe(this->ring_);
148148
io_uring_prep_rw(IORING_OP_ACCEPT, sqe, this->sockfd_tcp, NULL, 0, 0);
149149
sqe->user_data = (__u64)(instance); // important
@@ -152,9 +152,9 @@ void AsyncServer::InitiateRequest() {
152152
fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
153153
}
154154
};
155-
auto handle_CQE_AcceptHandle = [this,/*reuser params,*/ prep_RECV,handle_CQE_PrintMsg]
155+
auto handle_CQE_AcceptHandle = [this,prep_RECV,handle_CQE_PrintMsg]
156156
(StateMgmtIntf* instance,io_uring_cqe *cqe) mutable {
157-
std::cout << __FUNCTION__ <<" called handle_CQE_AcceptHandle"<< std::endl;
157+
// std::cout << __FUNCTION__ <<" called handle_CQE_AcceptHandle"<< std::endl;
158158

159159
// std::lock_guard<std::mutex> lock{mtx};
160160
// we have to create a new instance for read operation on this new client fd
@@ -222,7 +222,7 @@ void AsyncServer::HandleRequest() {
222222
else
223223
std::cerr <<"Error in the cqe!" << std::endl;
224224
}
225-
std::cout <<"One cqe done! flags : "<<cqe->flags << std::endl;
225+
// std::cout <<"One cqe done! flags : "<<cqe->flags << std::endl;
226226
io_uring_cqe_seen(ring_, cqe);
227227
}
228228
}

0 commit comments

Comments
 (0)