Skip to content

Commit

Permalink
vcpu support http server (#616)
Browse files Browse the repository at this point in the history
Signed-off-by: liulanzheng <[email protected]>
  • Loading branch information
liulanzheng committed Nov 6, 2024
1 parent 45ff630 commit 8cf352f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions net/http/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ limitations under the License.
#include "client.h"
#include "message.h"
#include "body.h"
#include <atomic>


#ifndef MSG_MORE
Expand Down Expand Up @@ -65,8 +66,9 @@ class HTTPServerImpl : public HTTPServer {
} status = Status::running;

HandlerRecord m_default_handler = {"", nullptr, false, {this, &HTTPServerImpl::not_found_handler}};
uint64_t m_workers = 0;
std::atomic<uint64_t> m_workers{0};
intrusive_list<SockItem> m_connection_list;
photon::spinlock m_connection_list_lock;
std::vector<HandlerRecord> m_handlers;

HTTPServerImpl() {}
Expand Down Expand Up @@ -107,8 +109,14 @@ class HTTPServerImpl : public HTTPServer {
m_workers++;
DEFER(m_workers--);
SockItem sock_item(sock);
m_connection_list.push_back(&sock_item);
DEFER(m_connection_list.erase(&sock_item));
{
SCOPED_LOCK(m_connection_list_lock);
m_connection_list.push_back(&sock_item);
}
DEFER({
SCOPED_LOCK(m_connection_list_lock);
m_connection_list.erase(&sock_item);
});

char req_buf[64*1024];
char resp_buf[64*1024];
Expand Down

0 comments on commit 8cf352f

Please sign in to comment.