Skip to content

Commit

Permalink
move build system to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
nickorlow committed May 10, 2024
1 parent c31db4d commit 734e37d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 53 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM alpine as build-env

RUN apk add --no-cache build-base python3
RUN apk add --no-cache build-base python3 cmake
COPY ./src/ .
RUN make build-release
RUN rm -rf CMakeCache.txt CMakeFiles
RUN cmake -DCMAKE_BUILD_TYPE=Release .
RUN make anthracite-bin

FROM alpine
RUN apk add --no-cache build-base
Expand Down
34 changes: 0 additions & 34 deletions src/Makefile

This file was deleted.

30 changes: 15 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ constexpr int max_worker_threads = 128;

void handle_client(anthracite_socket s, backend& b, file_backend& fb, std::mutex& thread_wait_mutex, std::condition_variable& thread_wait_condvar, int& active_threads)
{
while(true) {
std::string raw_request = s.recv_message(HTTP_HEADER_BYTES);
if(raw_request == "") {
break;
}
http_request req(raw_request, s.get_client_ip());
std::unique_ptr<http_response> resp = req.is_supported_version() ? b.handle_request(req) : fb.handle_error(http_status_codes::HTTP_VERSION_NOT_SUPPORTED);
log_request_and_response(req, resp);
std::string header = resp->header_to_string();
s.send_message(header);
s.send_message(resp->content());
resp.reset();
if(req.close_connection()) {
break;
}
while (true) {
std::string raw_request = s.recv_message(HTTP_HEADER_BYTES);
if (raw_request == "") {
break;
}
http_request req(raw_request, s.get_client_ip());
std::unique_ptr<http_response> resp = req.is_supported_version() ? b.handle_request(req) : fb.handle_error(http_status_codes::HTTP_VERSION_NOT_SUPPORTED);
log_request_and_response(req, resp);
std::string header = resp->header_to_string();
s.send_message(header);
s.send_message(resp->content());
resp.reset();
if (req.close_connection()) {
break;
}
}
s.close_conn();
{
Expand Down
4 changes: 2 additions & 2 deletions src/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <netinet/in.h>
#include <sstream>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
#include <unordered_map>
#include <sys/time.h>

constexpr int MAX_QUEUE_LENGTH = 100;

Expand Down Expand Up @@ -79,7 +79,7 @@ class anthracite_socket {
int result = recv(client_socket, response, sizeof(response), 0);

if (result < 1) {
return "";
return "";
}

response[buffer_size] = '\0';
Expand Down

0 comments on commit 734e37d

Please sign in to comment.