Skip to content

Commit be2fe7b

Browse files
committed
perf: wip queue for sending reponse
- rather than a bunch of sendall
1 parent 39e5b3f commit be2fe7b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

source/prime-time/main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
#define MAX_EVENTS 10
3333
#define PORT "18898"
3434

35-
int handle_request(int fd, char* raw_req, size_t size)
35+
int handle_request(struct queue *sdq, int fd, char* raw_req, size_t size)
3636
{
3737
assert(fd > 0);
38+
assert(sdq != NULL);
3839
assert(raw_req != NULL);
3940
if (size == 0) {
4041
log_error("handle_request: raw request size is zero");
@@ -117,8 +118,9 @@ int main()
117118
char* data;
118119
int n, fd, res, size;
119120
struct epoll_ctl_info epci = {epollfd, 0, 0};
120-
struct queue* qu = nullptr;
121-
queue_init(&qu, QUEUE_CAPACITY);
121+
struct queue* rcqu = NULL, *sdqu = NULL;
122+
queue_init(&rcqu, QUEUE_CAPACITY);
123+
queue_init(&sdqu, QUEUE_CAPACITY);
122124

123125
for (;;) {
124126
log_trace("main epoll loop: epoll listening...");
@@ -142,8 +144,8 @@ int main()
142144

143145
// Echo data now then while there is any
144146
log_trace("main epoll loop: handling POLLIN event on fd '%d'", fd);
145-
res = recv_request(fd, qu);
146-
size = queue_pop_no_copy(qu, &data);
147+
res = recv_request(fd, rcqu);
148+
size = queue_pop_no_copy(rcqu, &data);
147149

148150
// Handle error case while recv data
149151
if (res < -1) {

0 commit comments

Comments
 (0)