Skip to content

Commit

Permalink
fix compiling warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
idealvin committed Apr 26, 2021
1 parent ec20a01 commit ea7437a
Show file tree
Hide file tree
Showing 153 changed files with 61 additions and 14,715 deletions.
5 changes: 2 additions & 3 deletions include/co/so/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <functional>
#include <vector>

namespace so {
namespace http {

enum Version {
Expand Down Expand Up @@ -309,6 +308,8 @@ class Client {

} // http

namespace so {

/**
* start a static http server
* - This function will block the calling thread.
Expand All @@ -333,5 +334,3 @@ void easy(const char* root_dir=".", const char* ip="0.0.0.0", int port=80);
void easy(const char* root_dir, const char* ip, int port, const char* key, const char* ca);

} // so

namespace http = so::http;
13 changes: 2 additions & 11 deletions include/co/so/rpc.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#pragma once

#include "tcp.h"
#include "../json.h"

namespace so {
namespace rpc {

class Service {
Expand Down Expand Up @@ -31,7 +29,7 @@ class Server {
class Client {
public:
Client(const char* ip, int port, const char* passwd);
~Client() = default;
~Client();

void call(const Json& req, Json& res);

Expand All @@ -42,16 +40,9 @@ class Client {
}

private:
tcp::Client _tcp_cli;
fastring _passwd;
fastream _fs;
void* _p;

bool auth();
bool connect();
DISALLOW_COPY_AND_ASSIGN(Client);
};

} // rpc
} // so

namespace rpc = so::rpc;
6 changes: 1 addition & 5 deletions include/co/so/ssl.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#pragma once

#ifdef CO_SSL
#include "tcp.h"
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "tcp.h"

namespace so {
namespace ssl {

/**
Expand Down Expand Up @@ -360,8 +359,5 @@ class Client {
};

} // ssl
} // so

namespace ssl = so::ssl;

#endif
4 changes: 0 additions & 4 deletions include/co/so/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "../co.h"

namespace so {
namespace tcp {

/**
Expand Down Expand Up @@ -138,6 +137,3 @@ class Client {
};

} // tcp
} // so

namespace tcp = so::tcp;
5 changes: 2 additions & 3 deletions makevsprj.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
xmake project -k vs2015 -m "debug;release" vs
xmake project -k vs2017 -m "debug;release" vs
xmake project -k vs2019 -m "debug;release" vs
mkdir -p vs
xmake project -k vs2019 -a "x64,x86" -m "release" vs
2 changes: 1 addition & 1 deletion src/co/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static inline void wsa_cleanup() {}
SchedulerManager::SchedulerManager() {
wsa_startup();
if (FLG_co_sched_num == 0 || FLG_co_sched_num > os::cpunum()) FLG_co_sched_num = os::cpunum();
if (FLG_co_sched_num == 0 || FLG_co_sched_num > (uint32)os::cpunum()) FLG_co_sched_num = os::cpunum();
if (FLG_co_stack_size == 0) FLG_co_stack_size = 1024 * 1024;
_n = -1;
Expand Down
4 changes: 2 additions & 2 deletions src/co/sock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ int recvfrom(sock_t fd, void* buf, int n, void* addr, int* addrlen, int ms) {
IoEvent ev(fd, EV_read);

do {
int r = ::recvfrom(fd, (char*)buf, n, 0, (sockaddr*)addr, addrlen);
r = ::recvfrom(fd, (char*)buf, n, 0, (sockaddr*)addr, addrlen);
if (r != -1) return r;

if (co::error() == WSAEWOULDBLOCK) {
Expand Down Expand Up @@ -289,7 +289,7 @@ class Error {
FORMAT_MESSAGE_IGNORE_INSERTS,
0, e,
MAKELANGID(LANG_ENGLISH /*LANG_NEUTRAL*/, SUBLANG_DEFAULT),
(LPTSTR)&s, 0, 0
(LPSTR)&s, 0, 0
);

if (s) {
Expand Down
3 changes: 2 additions & 1 deletion src/so/http.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ DEF_bool(http_log, true, "#2 enable http log if true");

#define HTTPLOG LOG_IF(FLG_http_log)

namespace so {
namespace http {

class ServerImpl {
Expand Down Expand Up @@ -906,6 +905,8 @@ const char* status_str(int n) {

} // http

namespace so {

void easy(const char* root_dir, const char* ip, int port) {
return so::easy(root_dir, ip, port, NULL, NULL);
}
Expand Down
44 changes: 34 additions & 10 deletions src/so/rpc.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include "co/so/rpc.h"
#include "co/so/tcp.h"
#include "co/co.h"
#include "co/flag.h"
#include "co/log.h"
#include "co/fastring.h"
#include "co/fastream.h"
#include "co/str.h"
#include "co/hash.h"
#include "co/hash/md5.h"
#include "co/time.h"
#include <memory>

Expand All @@ -20,7 +19,6 @@ DEF_bool(rpc_log, true, "#2 enable rpc log if true");

#define RPCLOG LOG_IF(FLG_rpc_log)

namespace so {
namespace rpc {

struct Header {
Expand Down Expand Up @@ -322,12 +320,39 @@ bool ServerImpl::auth(sock_t fd) {
return false;
}

Client::Client(const char* serv_ip, int serv_port, const char* passwd)
: _tcp_cli(serv_ip, serv_port) {
if (passwd && *passwd) _passwd = md5sum(passwd);
class ClientImpl {
public:
ClientImpl(const char* ip, int port, const char* passwd)
: _tcp_cli(ip, port) {
if (passwd && *passwd) _passwd = md5sum(passwd);
}

~ClientImpl() = default;

void call(const Json& req, Json& res);

private:
tcp::Client _tcp_cli;
fastring _passwd;
fastream _fs;

bool auth();
bool connect();
};

Client::Client(const char* ip, int port, const char* passwd) {
_p = new ClientImpl(ip, port, passwd);
}

Client::~Client() {
delete (ClientImpl*)_p;
}

bool Client::connect() {
void Client::call(const Json& req, Json& res) {
return ((ClientImpl*)_p)->call(req, res);
}

bool ClientImpl::connect() {
if (!_tcp_cli.connect(FLG_rpc_conn_timeout)) return false;
if (!_passwd.empty() && !this->auth()) {
_tcp_cli.disconnect();
Expand All @@ -336,7 +361,7 @@ bool Client::connect() {
return true;
}

void Client::call(const Json& req, Json& res) {
void ClientImpl::call(const Json& req, Json& res) {
int r = 0, len = 0;
Header header;

Expand Down Expand Up @@ -397,7 +422,7 @@ void Client::call(const Json& req, Json& res) {
_tcp_cli.disconnect();
}

bool Client::auth() {
bool ClientImpl::auth() {
int r = 0, len = 0;
Header header;
fastream fs;
Expand Down Expand Up @@ -507,4 +532,3 @@ bool Client::auth() {
}

} // rpc
} // so
2 changes: 0 additions & 2 deletions src/so/ssl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

DEF_int32(ssl_handshake_timeout, 3000, "#2 ssl handshake timeout in ms");

namespace so {
namespace ssl {

static int errcb(const char* p, size_t n, void* u) {
Expand Down Expand Up @@ -327,6 +326,5 @@ void Client::disconnect() {
}

} // ssl
} // so

#endif
2 changes: 0 additions & 2 deletions src/so/tcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "co/log.h"
#include "co/str.h"

namespace so {
namespace tcp {

struct ServerParam {
Expand Down Expand Up @@ -114,4 +113,3 @@ void Client::disconnect() {
}

} // tcp
} // so
Loading

0 comments on commit ea7437a

Please sign in to comment.