Enabling microprofile webserver and adding a timeout.

This commit is contained in:
Ben Vanik 2015-01-03 01:06:19 -08:00
parent 718762746a
commit c6f0ce7a1e
2 changed files with 10 additions and 2 deletions

View File

@ -13,10 +13,14 @@
#define MICROPROFILEUI_ENABLED 1
#define MICROPROFILE_IMPL 1
#define MICROPROFILEUI_IMPL 1
#define MICROPROFILE_PER_THREAD_BUFFER_SIZE (1024 * 1024 * 10)
#define MICROPROFILE_USE_THREAD_NAME_CALLBACK 1
#define MICROPROFILE_PRINTF PLOGI
#define MICROPROFILE_WEBSERVER 0
#define MICROPROFILE_WEBSERVER 1
#define MICROPROFILE_DEBUG 0
#if MICROPROFILE_WEBSERVER
#include <winsock.h>
#endif // MICROPROFILE_WEBSERVER
#include <microprofile/microprofile.h>
#include <microprofile/microprofileui.h>

View File

@ -1985,7 +1985,11 @@ bool MicroProfileWebServerUpdate()
bool bServed = false;
if(!MP_INVALID_SOCKET(Connection))
{
std::lock_guard<std::recursive_mutex> Lock(MicroProfileMutex());
int timeout = 100;
setsockopt(Connection, SOL_SOCKET, SO_RCVTIMEO,
reinterpret_cast<char*>(&timeout), sizeof(timeout));
std::lock_guard<std::recursive_mutex> Lock(MicroProfileMutex());
char Req[8192];
MicroProfileSetNonBlocking(Connection, 0);
int nReceived = recv(Connection, Req, sizeof(Req)-1, 0);