Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
more win32 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
weigon committed Jun 14, 2018
1 parent 863a787 commit 83f309d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/http/include/mysqlrouter/http_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class HTTP_COMMON_EXPORT HttpHeaders {

std::unique_ptr<impl> pImpl;
public:
class Iterator {
class HTTP_COMMON_EXPORT Iterator {
evkeyval *node_;
public:
Iterator(evkeyval *node):
Expand Down
5 changes: 1 addition & 4 deletions src/http/src/http_server_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,13 @@ static void start(PluginFuncEnv* env) {
}
}

const char *plugin_requires[] = {
};

extern "C" {
Plugin HTTP_SERVER_EXPORT harness_plugin_http_server = {
PLUGIN_ABI_VERSION,
ARCHITECTURE_DESCRIPTOR,
"HTTP_SERVER",
VERSION_NUMBER(0, 0, 1),
sizeof(plugin_requires)/sizeof(plugin_requires[0]), plugin_requires, // requires
0, nullptr, // requires
0, nullptr, // conflicts
init, // init
nullptr, // deinit
Expand Down
12 changes: 8 additions & 4 deletions src/http/src/rest_cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,16 @@ int main(int argc, char **argv) {
if (frontend_config.request_data_stdin) {
while (true) {
char buf[128];
ssize_t bytes_read = ::fread(buf, 1, sizeof(buf), stdin);
auto bytes_read = ::fread(buf, 1, sizeof(buf), stdin);

if (bytes_read == 0) {
break;
} else if (bytes_read < 0) {
throw std::system_error(errno, std::generic_category());
if (feof(stdin)) {
break;
} else if (ferror(stdin)) {
throw std::runtime_error("reading from stdin failed");
} else {
throw std::runtime_error("fread() returned 0, but no EOF nor error?");
}
}
request_data.append(buf, buf + bytes_read);
}
Expand Down
2 changes: 1 addition & 1 deletion src/http/src/static_files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void HttpStaticFolderHandler::handle_request(HttpRequest &req) {
}

// if we have a directory, check if it contains a index.html file
if (S_ISDIR(st.st_mode)) {
if ((st.st_mode & S_IFMT) == S_IFDIR) {
file_path += "/index.html";

if (-1 == stat(file_path.c_str(), &st)) {
Expand Down
10 changes: 10 additions & 0 deletions src/mock_server/src/rest_mock_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@

IMPORT_LOG_FUNCTIONS()

#ifdef _WIN32
// workaround error C2039: 'GetObjectA': is not a member of ...
//
// as winnt.h #defines GetObject(...) GetObjectA(...)
// and we call json_doc.GetObject() which gets replaced by the c-pre-processor
# ifdef GetObject
# undef GetObject
# endif
#endif

static const char* kSectionName { "rest_mock_server" };

using mysql_harness::ARCHITECTURE_DESCRIPTOR;
Expand Down
5 changes: 5 additions & 0 deletions tests/component/test_rest_mock_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifdef _WIN32
// ensure windows.h doesn't expose min() nor max()
# define NOMINMAX
#endif

#include <thread>

#include "gmock/gmock.h"
Expand Down
1 change: 1 addition & 0 deletions tests/helpers/router_component_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class RouterComponentTest {
* standard output
* @param http_port port number where the http_server module of the mock server
* will accept REST client requests
* @param module_prefix base-path for javascript modules used by the tests
*
* @returns handle to the launched proccess
*/
Expand Down

0 comments on commit 83f309d

Please sign in to comment.