More work on moving engine into dlmalloc heap
This commit is contained in:
@@ -9,10 +9,6 @@
|
||||
#include "drivenengine.hpp"
|
||||
#include "dummycert.hpp"
|
||||
#include "util.hpp"
|
||||
#include "textgame.hpp"
|
||||
#include "lpxclient.hpp"
|
||||
#include "lpxserver.hpp"
|
||||
#include "eng-tests.hpp"
|
||||
#include "source.hpp"
|
||||
|
||||
#include <iostream>
|
||||
@@ -35,8 +31,8 @@
|
||||
#define CHBUF_SIZE (256*1024)
|
||||
#define POLLVEC_SIZE (DrivenEngine::MAX_CHAN+1)
|
||||
|
||||
static drv::unique_ptr<char[]> chbuf;
|
||||
static drv::unique_ptr<struct pollfd[]> pollvec;
|
||||
static std::unique_ptr<char[]> chbuf;
|
||||
static std::unique_ptr<struct pollfd[]> pollvec;
|
||||
|
||||
static void set_nonblocking(SOCKET sock) {
|
||||
u_long mode = 1; // 1 to enable non-blocking socket
|
||||
@@ -44,7 +40,7 @@ static void set_nonblocking(SOCKET sock) {
|
||||
assert(status == 0);
|
||||
}
|
||||
|
||||
static drv::string winsock_error_string(int errcode) {
|
||||
static std::string winsock_error_string(int errcode) {
|
||||
drv::ostringstream oss;
|
||||
oss << "error " << errcode;
|
||||
return oss.str();
|
||||
@@ -55,11 +51,11 @@ static PADDRINFOA find_good_addr(PADDRINFOA addrinfo) {
|
||||
if (addr->ai_family == AF_INET) {
|
||||
return addr;
|
||||
}
|
||||
}drv::string
|
||||
}std::string
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static SOCKET open_connection(std::string_view target, drv::string &err) {
|
||||
static SOCKET open_connection(std::string_view target, std::string &err) {
|
||||
PADDRINFOA addrs = nullptr;
|
||||
PADDRINFOA goodaddr = nullptr;
|
||||
SOCKET sock = INVALID_SOCKET;
|
||||
@@ -107,7 +103,7 @@ error:
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
SOCKET listen_on_port(int port, drv::string &err) {
|
||||
SOCKET listen_on_port(int port, std::string &err) {
|
||||
int status;
|
||||
err.clear();
|
||||
SOCKET sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@@ -140,7 +136,7 @@ error:
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
static SOCKET accept_on_socket(SOCKET listen_socket, drv::string &err) {
|
||||
static SOCKET accept_on_socket(SOCKET listen_socket, std::string &err) {
|
||||
SOCKET chsock = accept(listen_socket, nullptr, nullptr);
|
||||
if (chsock != INVALID_SOCKET) {
|
||||
set_nonblocking(chsock);
|
||||
@@ -156,7 +152,7 @@ static SOCKET accept_on_socket(SOCKET listen_socket, drv::string &err) {
|
||||
}
|
||||
}
|
||||
|
||||
static int socket_send(SOCKET socket, const char *bytes, int nbytes, drv::string &err) {
|
||||
static int socket_send(SOCKET socket, const char *bytes, int nbytes, std::string &err) {
|
||||
err.clear();
|
||||
int wbytes = send(socket, bytes, nbytes, 0);
|
||||
if (wbytes == SOCKET_ERROR) {
|
||||
@@ -173,7 +169,7 @@ static int socket_send(SOCKET socket, const char *bytes, int nbytes, drv::string
|
||||
}
|
||||
}
|
||||
|
||||
static int socket_recv(SOCKET socket, char *bytes, int nbytes, drv::string &err) {
|
||||
static int socket_recv(SOCKET socket, char *bytes, int nbytes, std::string &err) {
|
||||
err.clear();
|
||||
int nrecv = recv(socket, bytes, nbytes, 0);
|
||||
if (nrecv < 0) {
|
||||
@@ -195,7 +191,7 @@ static int socket_close(SOCKET socket) {
|
||||
return closesocket(socket);
|
||||
}
|
||||
|
||||
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, drv::string &err) {
|
||||
static int socket_poll(struct pollfd *pollvec, int pollcount, int mstimeout, std::string &err) {
|
||||
int status = WSAPoll(pollvec, pollcount, mstimeout);
|
||||
if (status < 0) {
|
||||
err = winsock_error_string(WSAGetLastError());
|
||||
@@ -276,7 +272,7 @@ int main(int argc, char **argv)
|
||||
allocate_buffers();
|
||||
init_winsock();
|
||||
OPENSSL_init_ssl(0, NULL);
|
||||
initialize_engine();
|
||||
SourceDB::register_lua_builtins();
|
||||
driver_drive(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user