mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
sync
This commit is contained in:
parent
77eb3b1643
commit
b5184ba45e
|
@ -14,6 +14,7 @@
|
|||
#include <ulib/ui/dialog.h>
|
||||
#include <ulib/query/parser.h>
|
||||
#include <ulib/net/udpsocket.h>
|
||||
#include <ulib/event/event_db.h>
|
||||
#include <ulib/mime/multipart.h>
|
||||
#include <ulib/net/client/ftp.h>
|
||||
#include <ulib/net/client/http.h>
|
||||
|
|
|
@ -186,28 +186,29 @@ U_DO_PRAGMA(message ("Sorry I was compiled without thread enabled so I cannot us
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int (*iPF) (void);
|
||||
typedef bool (*bPF) (void);
|
||||
typedef void (*vPF) (void);
|
||||
typedef void* (*pvPF) (void);
|
||||
typedef bool (*bPFi) (int);
|
||||
typedef void (*vPFi) (int);
|
||||
typedef void (*vPFu) (uint32_t);
|
||||
typedef void (*vPFpv) (void*);
|
||||
typedef bool (*bPFpv) (void*);
|
||||
typedef int (*iPFpv) (void*);
|
||||
typedef bool (*bPFpc) (const char*);
|
||||
typedef void (*vPFpc) (const char*);
|
||||
typedef void* (*pvPFpv) (void*);
|
||||
typedef void (*vpFpcu) (const char*,uint32_t);
|
||||
typedef bool (*bPFpcu) (const char*,uint32_t);
|
||||
typedef void (*vPFpvu) (void*,uint32_t);
|
||||
typedef int (*iPFpvpv) (void*,void*);
|
||||
typedef bool (*bPFpvpv) (void*,void*);
|
||||
typedef bool (*bPFpcpv) (const char*,void*);
|
||||
typedef bool (*bPFpcpc) (const char*,const char*);
|
||||
typedef void (*vPFpvpc) (void*,char*);
|
||||
typedef void (*vPFpvpv) (void*,void*);
|
||||
typedef int (*iPF) (void);
|
||||
typedef bool (*bPF) (void);
|
||||
typedef void (*vPF) (void);
|
||||
typedef void* (*pvPF) (void);
|
||||
typedef bool (*bPFi) (int);
|
||||
typedef void (*vPFi) (int);
|
||||
typedef void (*vPFu) (uint32_t);
|
||||
typedef void (*vPFpv) (void*);
|
||||
typedef bool (*bPFpv) (void*);
|
||||
typedef int (*iPFpv) (void*);
|
||||
typedef bool (*bPFpc) (const char*);
|
||||
typedef void (*vPFpc) (const char*);
|
||||
typedef void* (*pvPFpv) (void*);
|
||||
typedef void (*vpFpcu) (const char*,uint32_t);
|
||||
typedef bool (*bPFpcu) (const char*,uint32_t);
|
||||
typedef void (*vPFpvu) (void*,uint32_t);
|
||||
typedef int (*iPFpvpv) (void*,void*);
|
||||
typedef bool (*bPFpvpv) (void*,void*);
|
||||
typedef bool (*bPFpcpv) (const char*,void*);
|
||||
typedef bool (*bPFpcpc) (const char*,const char*);
|
||||
typedef void (*vPFpvpc) (void*,char*);
|
||||
typedef void (*vPFpvpv) (void*,void*);
|
||||
typedef void (*vPFpvpvu) (void*,void*,uint32_t);
|
||||
|
||||
typedef char* (*pcPFdpc) (double,char*);
|
||||
typedef char* (*pcPFu32pc) (uint32_t,char*);
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
UCache()
|
||||
{
|
||||
U_TRACE_CTOR(0, UCache, "", 0)
|
||||
U_TRACE_CTOR(0, UCache, "")
|
||||
|
||||
fd = -1;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
UCommand()
|
||||
{
|
||||
U_TRACE_CTOR(0, UCommand, "", 0)
|
||||
U_TRACE_CTOR(0, UCommand, "")
|
||||
|
||||
zero();
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ protected:
|
|||
public:
|
||||
UGenericHashMap()
|
||||
{
|
||||
U_TRACE_CTOR(0, UGenericHashMap, "", 0)
|
||||
U_TRACE_CTOR(0, UGenericHashMap, "")
|
||||
|
||||
node = U_NULLPTR;
|
||||
table = U_NULLPTR;
|
||||
|
|
|
@ -284,6 +284,15 @@ public:
|
|||
U_RETURN(U_NOT_FOUND);
|
||||
}
|
||||
|
||||
bool isContained(const void* elem)
|
||||
{
|
||||
U_TRACE(0, "UVector<void*>::isContained(%p)", elem)
|
||||
|
||||
if (find(elem) != U_NOT_FOUND) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// EXTENSION
|
||||
|
||||
static int qscomp(const void* p, const void* q)
|
||||
|
@ -1136,12 +1145,14 @@ public:
|
|||
|
||||
U_INTERNAL_DUMP("_length = %u _capacity = %u", _length, _capacity)
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(_capacity & (_capacity-1), 0) // must be a power of 2
|
||||
|
||||
if (lend < _capacity) push_back(str);
|
||||
else
|
||||
{
|
||||
++lstart;
|
||||
|
||||
replace(lend % _capacity, str);
|
||||
replace(lend & (_capacity-1), str);
|
||||
}
|
||||
|
||||
++lend;
|
||||
|
@ -1153,7 +1164,9 @@ public:
|
|||
|
||||
U_INTERNAL_DUMP("_length = %u _capacity = %u", _length, _capacity)
|
||||
|
||||
for (uint32_t i = (llast < lstart ? lstart : llast); i < lend; ++i) _vec.push_back(at(i % _capacity));
|
||||
U_INTERNAL_ASSERT_EQUALS(_capacity & (_capacity-1), 0) // must be a power of 2
|
||||
|
||||
for (uint32_t i = (llast < lstart ? lstart : llast); i < lend; ++i) _vec.push_back(at(i & (_capacity-1)));
|
||||
}
|
||||
|
||||
// BINARY HEAP
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
UTimeDate()
|
||||
{
|
||||
U_TRACE_CTOR(0, UTimeDate, "", 0)
|
||||
U_TRACE_CTOR(0, UTimeDate, "")
|
||||
|
||||
_day =
|
||||
_month = 1;
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
UTDB()
|
||||
{
|
||||
U_TRACE_CTOR(0, UTDB, "", 0)
|
||||
U_TRACE_CTOR(0, UTDB, "")
|
||||
|
||||
context = U_NULLPTR;
|
||||
}
|
||||
|
|
69
include/ulib/event/event_db.h
Normal file
69
include/ulib/event/event_db.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// = LIBRARY
|
||||
// ULib - c++ library
|
||||
//
|
||||
// = FILENAME
|
||||
// event_db.h
|
||||
//
|
||||
// = AUTHOR
|
||||
// Stefano Casazza
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifndef ULIB_EVENT_DB_H
|
||||
#define ULIB_EVENT_DB_H 1
|
||||
|
||||
#include <ulib/event/event_fd.h>
|
||||
|
||||
class UClientImage_Base;
|
||||
|
||||
class U_EXPORT UEventDB : public UEventFd {
|
||||
public:
|
||||
|
||||
// Check for memory error
|
||||
U_MEMORY_TEST
|
||||
|
||||
typedef struct query_info {
|
||||
vPFpvu handlerResult;
|
||||
UClientImage_Base* pClientImage;
|
||||
uint32_t num_query, num_result;
|
||||
} query_info;
|
||||
|
||||
UEventDB()
|
||||
{
|
||||
U_TRACE_CTOR(0, UEventDB, "")
|
||||
|
||||
conn = U_NULLPTR;
|
||||
|
||||
start = end = 0;
|
||||
|
||||
(void) U_SYSCALL(memset, "%p,%d,%u", query, 0, sizeof(query));
|
||||
}
|
||||
|
||||
~UEventDB()
|
||||
{
|
||||
U_TRACE_DTOR(0, UEventDB)
|
||||
}
|
||||
|
||||
// SERVICES
|
||||
|
||||
void setConnection(void* connection);
|
||||
void addClientImage(vPFpvu handlerResult, uint32_t num_query = 1);
|
||||
|
||||
// define method VIRTUAL
|
||||
|
||||
virtual int handlerRead();
|
||||
|
||||
#if defined(U_STDCPP_ENABLE) && defined(DEBUG)
|
||||
const char* dump(bool reset) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void* conn;
|
||||
uint32_t start, end;
|
||||
query_info query[512];
|
||||
|
||||
U_DISALLOW_COPY_AND_ASSIGN(UEventDB)
|
||||
};
|
||||
#endif
|
|
@ -67,6 +67,14 @@ public:
|
|||
# endif
|
||||
}
|
||||
|
||||
UEventFd(const UEventFd& ev)
|
||||
{
|
||||
U_TRACE_CTOR(0, UEventFd, "%p", &ev)
|
||||
|
||||
fd = ev.fd;
|
||||
op_mask = ev.op_mask;
|
||||
}
|
||||
|
||||
virtual ~UEventFd()
|
||||
{
|
||||
# ifdef USE_LIBEVENT
|
||||
|
@ -97,7 +105,7 @@ public:
|
|||
#endif
|
||||
|
||||
private:
|
||||
U_DISALLOW_COPY_AND_ASSIGN(UEventFd)
|
||||
U_DISALLOW_ASSIGN(UEventFd)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -170,7 +170,7 @@ public:
|
|||
|
||||
WiAuthDataStorage() : UDataStorage(*UString::str_storage_keyid)
|
||||
{
|
||||
U_TRACE_CTOR(5, WiAuthDataStorage, "", 0)
|
||||
U_TRACE_CTOR(5, WiAuthDataStorage, "")
|
||||
|
||||
utenti_connessi_giornaliero_globale =
|
||||
tempo_permanenza_utenti_giornaliero_globale = 0;
|
||||
|
@ -250,7 +250,7 @@ public:
|
|||
|
||||
WiAuthVirtualAccessPoint()
|
||||
{
|
||||
U_TRACE_CTOR(5, WiAuthVirtualAccessPoint, "", 0)
|
||||
U_TRACE_CTOR(5, WiAuthVirtualAccessPoint, "")
|
||||
|
||||
_index_access_point =
|
||||
_num_users_connected = 0;
|
||||
|
@ -422,7 +422,7 @@ public:
|
|||
|
||||
WiAuthAccessPoint()
|
||||
{
|
||||
U_TRACE_CTOR(5, WiAuthAccessPoint, "", 0)
|
||||
U_TRACE_CTOR(5, WiAuthAccessPoint, "")
|
||||
|
||||
reset();
|
||||
|
||||
|
@ -583,7 +583,7 @@ public:
|
|||
|
||||
WiAuthNodog()
|
||||
{
|
||||
U_TRACE_CTOR(5, WiAuthNodog, "", 0)
|
||||
U_TRACE_CTOR(5, WiAuthNodog, "")
|
||||
|
||||
sz = 0;
|
||||
port = 5280;
|
||||
|
@ -2048,7 +2048,7 @@ public:
|
|||
|
||||
WiAuthUser()
|
||||
{
|
||||
U_TRACE_CTOR(5, WiAuthUser, "", 0)
|
||||
U_TRACE_CTOR(5, WiAuthUser, "")
|
||||
|
||||
login_time = last_modified = 0L;
|
||||
_traffic_done = _traffic_available = _traffic_consumed = 0ULL;
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
|
||||
UFile()
|
||||
{
|
||||
U_TRACE_CTOR(0, UFile, "", 0)
|
||||
U_TRACE_CTOR(0, UFile, "")
|
||||
|
||||
reset();
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
UBison()
|
||||
{
|
||||
U_TRACE_CTOR(0, UBison, "", 0)
|
||||
U_TRACE_CTOR(0, UBison, "")
|
||||
}
|
||||
|
||||
UBison(const UString& data_) : UFlexer(data_)
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
UFlexer() : yyFlexLexer()
|
||||
{
|
||||
U_TRACE_CTOR(0, UFlexer, "", 0)
|
||||
U_TRACE_CTOR(0, UFlexer, "")
|
||||
|
||||
parsed_chars = write_position = 0;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
|
||||
ULDAP()
|
||||
{
|
||||
U_TRACE_CTOR(0, ULDAP, "", 0)
|
||||
U_TRACE_CTOR(0, ULDAP, "")
|
||||
|
||||
ld = U_NULLPTR;
|
||||
ludpp = U_NULLPTR;
|
||||
|
|
|
@ -326,7 +326,7 @@ public:
|
|||
|
||||
UMimeMultipart() : UMimeEntity()
|
||||
{
|
||||
U_TRACE_CTOR(0, UMimeMultipart, "", 0)
|
||||
U_TRACE_CTOR(0, UMimeMultipart, "")
|
||||
|
||||
buf = bbuf = U_NULLPTR;
|
||||
blen = boundaryStart = boundaryEnd = endPos = 0;
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
|
||||
UMimeHeader()
|
||||
{
|
||||
U_TRACE_CTOR(0, UMimeHeader, "", 0)
|
||||
U_TRACE_CTOR(0, UMimeHeader, "")
|
||||
}
|
||||
|
||||
~UMimeHeader()
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
UElasticSearchClient() : uri(U_CAPACITY)
|
||||
{
|
||||
U_TRACE_CTOR(0, UElasticSearchClient, "", 0)
|
||||
U_TRACE_CTOR(0, UElasticSearchClient, "")
|
||||
|
||||
client = U_NULLPTR;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
UMongoDBClient() : uri(100)
|
||||
{
|
||||
U_TRACE_CTOR(0, UMongoDBClient, "", 0)
|
||||
U_TRACE_CTOR(0, UMongoDBClient, "")
|
||||
|
||||
# ifdef USE_MONGODB
|
||||
puri = U_NULLPTR;
|
||||
|
|
|
@ -348,6 +348,28 @@ public:
|
|||
|
||||
UString getRedisVersion() { return getInfoData("default", U_CONSTANT_TO_PARAM("redis_version:")); }
|
||||
|
||||
// GEO (@see https://redis.io/commands#geo)
|
||||
|
||||
// GEOADD key longitude latitude member [longitude latitude member ...]
|
||||
bool geoadd(const char* param, uint32_t len)
|
||||
{
|
||||
U_TRACE(0, "UREDISClient_Base::geoadd(%.*S,%u)", len, param, len)
|
||||
|
||||
if (processRequest(U_RC_INT, U_CONSTANT_TO_PARAM("GEOADD"), param, len)) return getBool();
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// GEORADIUS key longitude latitude radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count] [ASC|DESC] [STORE key] [STOREDIST key]
|
||||
bool georadius(const char* param, uint32_t len)
|
||||
{
|
||||
U_TRACE(0, "UREDISClient_Base::georadius(%.*S,%u)", len, param, len)
|
||||
|
||||
if (processRequest(U_RC_MULTIBULK, U_CONSTANT_TO_PARAM("GEORADIUS"), param, len)) return getBool();
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// SET (@see http://redis.io/commands#set)
|
||||
|
||||
bool sadd(const char* key, uint32_t keylen, const char* param, uint32_t len) // Add one or more members to a set
|
||||
|
@ -715,7 +737,7 @@ protected:
|
|||
|
||||
UREDISClient_Base() : UClient_Base(U_NULLPTR)
|
||||
{
|
||||
U_TRACE_CTOR(0, UREDISClient_Base, "", 0)
|
||||
U_TRACE_CTOR(0, UREDISClient_Base, "")
|
||||
|
||||
err = 0;
|
||||
}
|
||||
|
@ -791,7 +813,7 @@ public:
|
|||
|
||||
UREDISClient() : UREDISClient_Base()
|
||||
{
|
||||
U_TRACE_CTOR(0, UREDISClient, "", 0)
|
||||
U_TRACE_CTOR(0, UREDISClient, "")
|
||||
|
||||
U_NEW(Socket, UClient_Base::socket, Socket(UClient_Base::bIPv6));
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
UWebSocketClient()
|
||||
{
|
||||
U_TRACE_CTOR(0, UWebSocketClient, "", 0)
|
||||
U_TRACE_CTOR(0, UWebSocketClient, "")
|
||||
|
||||
U_NEW(UClient<USSLSocket>, client, UClient<USSLSocket>(U_NULLPTR));
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
UIPAllow()
|
||||
{
|
||||
U_TRACE_CTOR(0, UIPAllow, "", 0)
|
||||
U_TRACE_CTOR(0, UIPAllow, "")
|
||||
|
||||
mask = addr = network = 0;
|
||||
bnot = false;
|
||||
|
@ -225,7 +225,7 @@ public:
|
|||
|
||||
UIPAddress()
|
||||
{
|
||||
U_TRACE_CTOR(0, UIPAddress, "", 0)
|
||||
U_TRACE_CTOR(0, UIPAddress, "")
|
||||
|
||||
pcStrAddress[0] = '\0';
|
||||
iAddressLength =
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
URPCEncoder() : buffer(U_CAPACITY), encodedValue(U_CAPACITY)
|
||||
{
|
||||
U_TRACE_CTOR(0, URPCEncoder, "", 0)
|
||||
U_TRACE_CTOR(0, URPCEncoder, "")
|
||||
|
||||
bIsResponse = false;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
URPCEnvelope()
|
||||
{
|
||||
U_TRACE_CTOR(0, URPCEnvelope, "", 0)
|
||||
U_TRACE_CTOR(0, URPCEnvelope, "")
|
||||
|
||||
arg = U_NULLPTR;
|
||||
mustUnderstand = false;
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
URPCFault() : detail(U_CAPACITY)
|
||||
{
|
||||
U_TRACE_CTOR(0, URPCFault, "", 0)
|
||||
U_TRACE_CTOR(0, URPCFault, "")
|
||||
|
||||
faultCode = Sender;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
URPCMethod()
|
||||
{
|
||||
U_TRACE_CTOR(0, URPCMethod, "", 0)
|
||||
U_TRACE_CTOR(0, URPCMethod, "")
|
||||
}
|
||||
|
||||
URPCMethod(const UString& n, const UString& _ns) : method_name(n), ns(_ns)
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
URPCObject()
|
||||
{
|
||||
U_TRACE_CTOR(0, URPCObject, "", 0)
|
||||
U_TRACE_CTOR(0, URPCObject, "")
|
||||
}
|
||||
|
||||
virtual ~URPCObject()
|
||||
|
|
|
@ -346,6 +346,59 @@ public:
|
|||
static UString* _buffer;
|
||||
static UString* _encoded;
|
||||
|
||||
bool isOpen()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UClientImage_Base::isOpen()")
|
||||
|
||||
if (socket->isOpen()) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool writeResponse();
|
||||
void writeResponseCompact()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UClientImage_Base::writeResponseCompact()")
|
||||
|
||||
uint32_t sz = wbuffer->size();
|
||||
|
||||
U_ASSERT(body->empty())
|
||||
U_INTERNAL_ASSERT_MAJOR(sz, 0)
|
||||
|
||||
iov_vec[2].iov_len = sz;
|
||||
iov_vec[2].iov_base = (caddr_t)wbuffer->data();
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(iov_vec[0].iov_len, 17)
|
||||
U_INTERNAL_ASSERT_EQUALS(iov_vec[1].iov_len, 51)
|
||||
|
||||
# ifndef U_PIPELINE_HOMOGENEOUS_DISABLE
|
||||
if (nrequest)
|
||||
{
|
||||
struct iovec iov[256];
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(nrequest, 1)
|
||||
|
||||
char* ptr = (char*)iov;
|
||||
|
||||
U_MEMCPY(ptr, iov_vec, sizeof(struct iovec) * 3);
|
||||
|
||||
for (uint32_t i = 1; i < nrequest; ++i)
|
||||
{
|
||||
ptr += sizeof(struct iovec) * 3;
|
||||
U_MEMCPY(ptr, iov_vec, sizeof(struct iovec) * 3);
|
||||
}
|
||||
|
||||
(void) USocketExt::writev(socket, iov, 3*nrequest, (17+51+sz)*nrequest, 0);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(nrequest, 0)
|
||||
|
||||
(void) USocketExt::writev(socket, iov_vec, 3, 17+51+sz, 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
USocket* socket;
|
||||
#ifdef U_THROTTLING_SUPPORT
|
||||
|
@ -401,6 +454,8 @@ protected:
|
|||
U_INTERNAL_DUMP("wbuffer(%u) = %V", wbuffer->size(), wbuffer->rep)
|
||||
|
||||
wbuffer->setBuffer(U_CAPACITY); // NB: this string can be referenced more than one (often if U_SUBSTR_INC_REF is defined)...
|
||||
|
||||
wbuffer->rep->setNullTerminated();
|
||||
}
|
||||
|
||||
int handlerResponse()
|
||||
|
@ -430,7 +485,6 @@ protected:
|
|||
U_RETURN(U_SINGLE_READ);
|
||||
}
|
||||
|
||||
bool writeResponse();
|
||||
bool logCertificate(); // append on log the peer certicate of client ("issuer","serial")
|
||||
bool askForClientCertificate();
|
||||
|
||||
|
@ -531,7 +585,7 @@ public:
|
|||
|
||||
UClientImage() : UClientImage_Base()
|
||||
{
|
||||
U_TRACE_CTOR(0, UClientImage<Socket>, "", 0)
|
||||
U_TRACE_CTOR(0, UClientImage<Socket>, "")
|
||||
|
||||
U_NEW(Socket, socket, Socket(UClientImage_Base::bIPv6))
|
||||
|
||||
|
@ -559,7 +613,7 @@ public:
|
|||
|
||||
UClientImage() : UClientImage_Base()
|
||||
{
|
||||
U_TRACE_CTOR(0, UClientImage<USSLSocket>, "", 0)
|
||||
U_TRACE_CTOR(0, UClientImage<USSLSocket>, "")
|
||||
|
||||
U_NEW(USSLSocket, socket, USSLSocket(UClientImage_Base::bIPv6, USSLSocket::sctx, true))
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
URDBClientImage() : UClientImage<UTCPSocket>()
|
||||
{
|
||||
U_TRACE_CTOR(0, URDBClientImage, "", 0)
|
||||
U_TRACE_CTOR(0, URDBClientImage, "")
|
||||
}
|
||||
|
||||
virtual ~URDBClientImage()
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
UEchoPlugIn()
|
||||
{
|
||||
U_TRACE_CTOR(0, UEchoPlugIn, "", 0)
|
||||
U_TRACE_CTOR(0, UEchoPlugIn, "")
|
||||
}
|
||||
|
||||
virtual ~UEchoPlugIn();
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
UHttpPlugIn()
|
||||
{
|
||||
U_TRACE_CTOR(0, UHttpPlugIn, "", 0)
|
||||
U_TRACE_CTOR(0, UHttpPlugIn, "")
|
||||
}
|
||||
|
||||
virtual ~UHttpPlugIn();
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
UModNoCatPeer() : UEventTime(0L,1L), mac(*UString::str_without_mac)
|
||||
{
|
||||
U_TRACE_CTOR(0, UModNoCatPeer, "", 0)
|
||||
U_TRACE_CTOR(0, UModNoCatPeer, "")
|
||||
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
UModNoDogPeer() : UEventTime(30L,0L), mac(*UString::str_without_mac)
|
||||
{
|
||||
U_TRACE_CTOR(0, UModNoDogPeer, "", 0)
|
||||
U_TRACE_CTOR(0, UModNoDogPeer, "")
|
||||
|
||||
_ctime = u_now->tv_sec;
|
||||
ctraffic =
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
URpcPlugIn()
|
||||
{
|
||||
U_TRACE_CTOR(0, URpcPlugIn, "", 0)
|
||||
U_TRACE_CTOR(0, URpcPlugIn, "")
|
||||
|
||||
UString::str_allocate(STR_ALLOCATE_SOAP);
|
||||
}
|
||||
|
|
|
@ -257,8 +257,19 @@ public:
|
|||
// -------------------------------------------------------------------
|
||||
|
||||
static char mod_name[2][32];
|
||||
static UEventFd* handler_other;
|
||||
static UEventFd* handler_db1;
|
||||
static UEventFd* handler_db2;
|
||||
static UEventFd* handler_inotify;
|
||||
static UVector<UEventFd*>* handler_other;
|
||||
|
||||
static void addHandlerEvent(UEventFd* item)
|
||||
{
|
||||
U_TRACE(0, "UServer_Base::addHandlerEvent(%p)", item)
|
||||
|
||||
if (handler_other == U_NULLPTR) U_NEW(UVector<UEventFd*>, handler_other, UVector<UEventFd*>);
|
||||
|
||||
handler_other->push_back(item);
|
||||
}
|
||||
|
||||
static int loadPlugins(UString& plugin_dir, const UString& plugin_list); // load plugin modules and call server-wide hooks handlerConfig()...
|
||||
|
||||
|
@ -1241,6 +1252,8 @@ protected:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0+256, "UServer<Socket>::preallocate()")
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(UNotifier::max_connection, 0)
|
||||
|
||||
// NB: array are not pointers (virtual table can shift the address of this)...
|
||||
|
||||
vClientImage = new client_type[UNotifier::max_connection];
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
UMySqlStatementBindParam()
|
||||
{
|
||||
U_TRACE_CTOR(0, UMySqlStatementBindParam, "", 0)
|
||||
U_TRACE_CTOR(0, UMySqlStatementBindParam, "")
|
||||
|
||||
type = MYSQL_TYPE_NULL;
|
||||
is_unsigned = false;
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
UPgSqlStatementBindParam()
|
||||
{
|
||||
U_TRACE_CTOR(0, UPgSqlStatementBindParam, "", 0)
|
||||
U_TRACE_CTOR(0, UPgSqlStatementBindParam, "")
|
||||
|
||||
type = 0;
|
||||
length = 0;
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
USqliteStatementBindParam()
|
||||
{
|
||||
U_TRACE_CTOR(0, USqliteStatementBindParam, "", 0)
|
||||
U_TRACE_CTOR(0, USqliteStatementBindParam, "")
|
||||
|
||||
type = U_NULL_VALUE;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
USqlStatementBindParam()
|
||||
{
|
||||
U_TRACE_CTOR(0, USqlStatementBindParam, "", 0)
|
||||
U_TRACE_CTOR(0, USqlStatementBindParam, "")
|
||||
|
||||
buffer = U_NULLPTR;
|
||||
pstr = U_NULLPTR;
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
UProcess()
|
||||
{
|
||||
U_TRACE_CTOR(0, UProcess, "", 0)
|
||||
U_TRACE_CTOR(0, UProcess, "")
|
||||
|
||||
_pid = (pid_t)-1;
|
||||
status = 0;
|
||||
|
|
|
@ -177,7 +177,7 @@ public:
|
|||
|
||||
UQueryParser()
|
||||
{
|
||||
U_TRACE_CTOR(0, UQueryParser, "", 0)
|
||||
U_TRACE_CTOR(0, UQueryParser, "")
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(UString::str_not);
|
||||
|
||||
|
|
|
@ -339,7 +339,7 @@ public:
|
|||
|
||||
UFlatBuffer()
|
||||
{
|
||||
U_TRACE_CTOR(0, UFlatBuffer, "", 0)
|
||||
U_TRACE_CTOR(0, UFlatBuffer, "")
|
||||
|
||||
// coverity[uninit_ctor]
|
||||
# ifdef U_COVERITY_FALSE_POSITIVE
|
||||
|
@ -2108,7 +2108,7 @@ public:
|
|||
|
||||
UFlatBufferSpaceShort()
|
||||
{
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceShort, "", 0)
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceShort, "")
|
||||
|
||||
prev_stack = UFlatBuffer::getStack();
|
||||
prev_buffer = UFlatBuffer::getBuffer();
|
||||
|
@ -2156,7 +2156,7 @@ public:
|
|||
|
||||
UFlatBufferSpaceMedium()
|
||||
{
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceMedium, "", 0)
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceMedium, "")
|
||||
|
||||
prev_stack = UFlatBuffer::getStack();
|
||||
prev_buffer = UFlatBuffer::getBuffer();
|
||||
|
@ -2204,7 +2204,7 @@ public:
|
|||
|
||||
UFlatBufferSpaceLarge()
|
||||
{
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceLarge, "", 0)
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceLarge, "")
|
||||
|
||||
prev_stack = UFlatBuffer::getStack();
|
||||
prev_buffer = UFlatBuffer::getBuffer();
|
||||
|
@ -2259,7 +2259,7 @@ public:
|
|||
|
||||
UFlatBufferSpaceUser()
|
||||
{
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceUser, "", 0)
|
||||
U_TRACE_CTOR(0, UFlatBufferSpaceUser, "")
|
||||
|
||||
prev_stack = UFlatBuffer::getStack();
|
||||
prev_buffer = UFlatBuffer::getBuffer();
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
USSLSession()
|
||||
{
|
||||
U_TRACE_CTOR(0, USSLSession, "", 0)
|
||||
U_TRACE_CTOR(0, USSLSession, "")
|
||||
}
|
||||
|
||||
virtual ~USSLSession() U_DECL_FINAL
|
||||
|
|
|
@ -961,6 +961,17 @@ private:
|
|||
|
||||
void _release();
|
||||
|
||||
void setEmpty()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UStringRep::setEmpty()")
|
||||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
((char*)str)[_length = 0] = '\0';
|
||||
|
||||
U_INTERNAL_ASSERT(invariant())
|
||||
}
|
||||
|
||||
void shift(ptrdiff_t diff)
|
||||
{
|
||||
U_TRACE(0, "UStringRep::shift(%p)", diff)
|
||||
|
@ -1419,7 +1430,7 @@ public:
|
|||
|
||||
UString() : rep(UStringRep::string_rep_null)
|
||||
{
|
||||
U_TRACE_CTOR(0, UString, "", 0)
|
||||
U_TRACE_CTOR(0, UString, "")
|
||||
|
||||
rep->hold();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
UTimer()
|
||||
{
|
||||
U_TRACE_CTOR(0, UTimer, "", 0)
|
||||
U_TRACE_CTOR(0, UTimer, "")
|
||||
|
||||
next = U_NULLPTR;
|
||||
alarm = U_NULLPTR;
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
UTimeVal()
|
||||
{
|
||||
U_TRACE_CTOR(0, UTimeVal, "", 0)
|
||||
U_TRACE_CTOR(0, UTimeVal, "")
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS((void*)this, (void*)&tv_sec)
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
|
||||
Url()
|
||||
{
|
||||
U_TRACE_CTOR(0, Url, "", 0)
|
||||
U_TRACE_CTOR(0, Url, "")
|
||||
|
||||
service_end =
|
||||
user_begin =
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
|
||||
UDataStorage()
|
||||
{
|
||||
U_TRACE_CTOR(0, UDataStorage, "", 0)
|
||||
U_TRACE_CTOR(0, UDataStorage, "")
|
||||
|
||||
# ifdef DEBUG
|
||||
recdata = U_NULLPTR;
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
|
||||
UDataSession()
|
||||
{
|
||||
U_TRACE_CTOR(0, UDataSession, "", 0)
|
||||
U_TRACE_CTOR(0, UDataSession, "")
|
||||
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ public:
|
|||
{
|
||||
U_TRACE(0+256, "UHTTP2::Connection::preallocate(%u)", max_connection)
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(max_connection, 0)
|
||||
U_INTERNAL_ASSERT_EQUALS(vConnection, U_NULLPTR)
|
||||
|
||||
U_INTERNAL_DUMP("sizeof(Connection) = %u sizeof(Stream) = %u", sizeof(Connection), sizeof(Stream))
|
||||
|
@ -404,8 +405,6 @@ protected:
|
|||
{
|
||||
U_TRACE(0, "UHTTP2::writev(%p,%d,%u)", iov, iovcnt, count)
|
||||
|
||||
U_DUMP_IOVEC(iov,iovcnt)
|
||||
|
||||
if (USocketExt::writev(UServer_Base::csocket, iov, iovcnt, count, 0) == count) U_RETURN(true);
|
||||
|
||||
nerror = CONNECT_ERROR;
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
USemaphore()
|
||||
{
|
||||
U_TRACE_CTOR(0, USemaphore, "", 0)
|
||||
U_TRACE_CTOR(0, USemaphore, "")
|
||||
|
||||
next = U_NULLPTR;
|
||||
psem = U_NULLPTR;
|
||||
|
|
|
@ -982,7 +982,7 @@ private:
|
|||
|
||||
UCServletPage()
|
||||
{
|
||||
U_TRACE_CTOR(0, UCServletPage, "", 0)
|
||||
U_TRACE_CTOR(0, UCServletPage, "")
|
||||
|
||||
size = 0;
|
||||
relocated = U_NULLPTR;
|
||||
|
@ -1018,7 +1018,7 @@ private:
|
|||
|
||||
UPHP()
|
||||
{
|
||||
U_TRACE_CTOR(0, UPHP, "", 0)
|
||||
U_TRACE_CTOR(0, UPHP, "")
|
||||
|
||||
initPHP =
|
||||
runPHP = U_NULLPTR;
|
||||
|
@ -1053,7 +1053,7 @@ private:
|
|||
|
||||
URUBY()
|
||||
{
|
||||
U_TRACE_CTOR(0, URUBY, "", 0)
|
||||
U_TRACE_CTOR(0, URUBY, "")
|
||||
|
||||
initRUBY =
|
||||
runRUBY = U_NULLPTR;
|
||||
|
@ -1088,7 +1088,7 @@ private:
|
|||
|
||||
UPYTHON()
|
||||
{
|
||||
U_TRACE_CTOR(0, UPYTHON, "", 0)
|
||||
U_TRACE_CTOR(0, UPYTHON, "")
|
||||
|
||||
initPYTHON =
|
||||
runPYTHON = U_NULLPTR;
|
||||
|
@ -1129,7 +1129,7 @@ private:
|
|||
|
||||
UPageSpeed()
|
||||
{
|
||||
U_TRACE_CTOR(0, UPageSpeed, "", 0)
|
||||
U_TRACE_CTOR(0, UPageSpeed, "")
|
||||
|
||||
minify_html = 0;
|
||||
optimize_gif = optimize_png = optimize_jpg = 0;
|
||||
|
@ -1159,7 +1159,7 @@ private:
|
|||
|
||||
UV8JavaScript()
|
||||
{
|
||||
U_TRACE_CTOR(0, UV8JavaScript, "", 0)
|
||||
U_TRACE_CTOR(0, UV8JavaScript, "")
|
||||
|
||||
runv8 = U_NULLPTR;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
UXMLAttribute()
|
||||
{
|
||||
U_TRACE_CTOR(0, UXMLAttribute, "", 0)
|
||||
U_TRACE_CTOR(0, UXMLAttribute, "")
|
||||
}
|
||||
|
||||
UXMLAttribute(const UString& s, const UString& a, const UString& n, const UString& v)
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
UXMLElement()
|
||||
{
|
||||
U_TRACE_CTOR(0, UXMLElement, "", 0)
|
||||
U_TRACE_CTOR(0, UXMLElement, "")
|
||||
}
|
||||
|
||||
UXMLElement(const UString& s, const UString& a, const UString& n) : str(s), accessorName(a), namespaceName(n)
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
UXMLParser()
|
||||
{
|
||||
U_TRACE_CTOR(0, UXMLParser, "", 0)
|
||||
U_TRACE_CTOR(0, UXMLParser, "")
|
||||
|
||||
m_parser = U_NULLPTR;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
UXML2Document()
|
||||
{
|
||||
U_TRACE_CTOR(0, UXML2Document, "", 0)
|
||||
U_TRACE_CTOR(0, UXML2Document, "")
|
||||
|
||||
impl_ = (xmlDocPtr) U_SYSCALL(xmlNewDoc, "%S", (xmlChar*)"1.0");
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
USOAPEncoder()
|
||||
{
|
||||
U_TRACE_CTOR(0, USOAPEncoder, "", 0)
|
||||
U_TRACE_CTOR(0, USOAPEncoder, "")
|
||||
}
|
||||
|
||||
virtual ~USOAPEncoder()
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
USOAPFault()
|
||||
{
|
||||
U_TRACE_CTOR(0, USOAPFault, "", 0)
|
||||
U_TRACE_CTOR(0, USOAPFault, "")
|
||||
}
|
||||
|
||||
virtual ~USOAPFault()
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
USOAPObject()
|
||||
{
|
||||
U_TRACE_CTOR(0, USOAPObject, "", 0)
|
||||
U_TRACE_CTOR(0, USOAPObject, "")
|
||||
}
|
||||
|
||||
virtual ~USOAPObject()
|
||||
|
|
|
@ -176,7 +176,7 @@ public:
|
|||
|
||||
USOAPParser(UVector<UString>* arg = U_NULLPTR) : URPCParser(arg), tree(U_NULLPTR,U_NULLPTR,2)
|
||||
{
|
||||
U_TRACE_CTOR(0, USOAPParser, "", 0)
|
||||
U_TRACE_CTOR(0, USOAPParser, "")
|
||||
|
||||
# ifdef U_SOAP_NAMESPACE
|
||||
XMLNStoURN.allocate();
|
||||
|
|
|
@ -47,7 +47,7 @@ SRC_CPP = internal/common.cpp internal/error.cpp \
|
|||
net/client/http.cpp net/client/client.cpp net/client/redis.cpp net/client/elasticsearch.cpp \
|
||||
net/ipt_ACCOUNT.cpp \
|
||||
json/value.cpp serialize/flatbuffers.cpp \
|
||||
query/query_parser.cpp event/event_time.cpp \
|
||||
query/query_parser.cpp event/event_time.cpp event/event_db.cpp \
|
||||
timeval.cpp timer.cpp notifier.cpp string.cpp file.cpp process.cpp file_config.cpp log.cpp \
|
||||
options.cpp application.cpp cache.cpp date.cpp url.cpp tokenizer.cpp command.cpp
|
||||
|
||||
|
|
|
@ -256,21 +256,21 @@ am__lib@ULIB@_la_SOURCES_DIST = base/base.c base/base_error.c \
|
|||
net/client/imap.cpp net/client/http.cpp net/client/client.cpp \
|
||||
net/client/redis.cpp net/client/elasticsearch.cpp \
|
||||
net/ipt_ACCOUNT.cpp json/value.cpp serialize/flatbuffers.cpp \
|
||||
query/query_parser.cpp event/event_time.cpp timeval.cpp \
|
||||
timer.cpp notifier.cpp string.cpp file.cpp process.cpp \
|
||||
file_config.cpp log.cpp options.cpp application.cpp cache.cpp \
|
||||
date.cpp url.cpp tokenizer.cpp command.cpp db/tdb.cpp \
|
||||
net/client/mongodb.cpp utility/http2.cpp internal/objectIO.cpp \
|
||||
thread.cpp debug/debug_common.cpp debug/trace.cpp \
|
||||
debug/error_memory.cpp debug/error_simulation.cpp \
|
||||
debug/objectDB.cpp internal/memory_pool.cpp zip/zip.cpp \
|
||||
flex/flexer.cpp flex/bison.cpp pcre/pcre.cpp \
|
||||
ssl/certificate.cpp ssl/pkcs7.cpp ssl/crl.cpp ssl/pkcs10.cpp \
|
||||
net/client/twilio.cpp net/client/uwebsocket.cpp \
|
||||
ssl/mime/mime_pkcs7.cpp ssl/net/sslsocket.cpp \
|
||||
ssl/net/ssl_session.cpp utility/des3.cpp ssl/timestamp.cpp \
|
||||
ssh/net/sshsocket.cpp ldap/ldap.cpp curl/curl.cpp \
|
||||
xml/expat/attribute.cpp xml/expat/element.cpp \
|
||||
query/query_parser.cpp event/event_time.cpp event/event_db.cpp \
|
||||
timeval.cpp timer.cpp notifier.cpp string.cpp file.cpp \
|
||||
process.cpp file_config.cpp log.cpp options.cpp \
|
||||
application.cpp cache.cpp date.cpp url.cpp tokenizer.cpp \
|
||||
command.cpp db/tdb.cpp net/client/mongodb.cpp \
|
||||
utility/http2.cpp internal/objectIO.cpp thread.cpp \
|
||||
debug/debug_common.cpp debug/trace.cpp debug/error_memory.cpp \
|
||||
debug/error_simulation.cpp debug/objectDB.cpp \
|
||||
internal/memory_pool.cpp zip/zip.cpp flex/flexer.cpp \
|
||||
flex/bison.cpp pcre/pcre.cpp ssl/certificate.cpp ssl/pkcs7.cpp \
|
||||
ssl/crl.cpp ssl/pkcs10.cpp net/client/twilio.cpp \
|
||||
net/client/uwebsocket.cpp ssl/mime/mime_pkcs7.cpp \
|
||||
ssl/net/sslsocket.cpp ssl/net/ssl_session.cpp utility/des3.cpp \
|
||||
ssl/timestamp.cpp ssh/net/sshsocket.cpp ldap/ldap.cpp \
|
||||
curl/curl.cpp xml/expat/attribute.cpp xml/expat/element.cpp \
|
||||
xml/expat/xml_parser.cpp xml/expat/xml2txt.cpp \
|
||||
xml/soap/soap_fault.cpp xml/soap/soap_gen_method.cpp \
|
||||
xml/soap/soap_parser.cpp xml/soap/soap_encoder.cpp \
|
||||
|
@ -420,23 +420,23 @@ am__objects_68 = internal/common.lo internal/error.lo ui/dialog.lo \
|
|||
net/client/http.lo net/client/client.lo net/client/redis.lo \
|
||||
net/client/elasticsearch.lo net/ipt_ACCOUNT.lo json/value.lo \
|
||||
serialize/flatbuffers.lo query/query_parser.lo \
|
||||
event/event_time.lo timeval.lo timer.lo notifier.lo string.lo \
|
||||
file.lo process.lo file_config.lo log.lo options.lo \
|
||||
application.lo cache.lo date.lo url.lo tokenizer.lo command.lo \
|
||||
$(am__objects_27) $(am__objects_28) $(am__objects_29) \
|
||||
$(am__objects_30) $(am__objects_31) $(am__objects_32) \
|
||||
$(am__objects_33) $(am__objects_34) $(am__objects_35) \
|
||||
$(am__objects_36) $(am__objects_37) $(am__objects_38) \
|
||||
$(am__objects_39) $(am__objects_40) $(am__objects_41) \
|
||||
$(am__objects_42) $(am__objects_43) $(am__objects_44) \
|
||||
$(am__objects_45) $(am__objects_46) $(am__objects_47) \
|
||||
$(am__objects_48) $(am__objects_49) $(am__objects_50) \
|
||||
$(am__objects_51) $(am__objects_52) $(am__objects_53) \
|
||||
$(am__objects_54) $(am__objects_55) $(am__objects_56) \
|
||||
$(am__objects_57) $(am__objects_58) $(am__objects_59) \
|
||||
$(am__objects_60) $(am__objects_61) $(am__objects_62) \
|
||||
$(am__objects_63) $(am__objects_64) $(am__objects_65) \
|
||||
$(am__objects_66) $(am__objects_67)
|
||||
event/event_time.lo event/event_db.lo timeval.lo timer.lo \
|
||||
notifier.lo string.lo file.lo process.lo file_config.lo log.lo \
|
||||
options.lo application.lo cache.lo date.lo url.lo tokenizer.lo \
|
||||
command.lo $(am__objects_27) $(am__objects_28) \
|
||||
$(am__objects_29) $(am__objects_30) $(am__objects_31) \
|
||||
$(am__objects_32) $(am__objects_33) $(am__objects_34) \
|
||||
$(am__objects_35) $(am__objects_36) $(am__objects_37) \
|
||||
$(am__objects_38) $(am__objects_39) $(am__objects_40) \
|
||||
$(am__objects_41) $(am__objects_42) $(am__objects_43) \
|
||||
$(am__objects_44) $(am__objects_45) $(am__objects_46) \
|
||||
$(am__objects_47) $(am__objects_48) $(am__objects_49) \
|
||||
$(am__objects_50) $(am__objects_51) $(am__objects_52) \
|
||||
$(am__objects_53) $(am__objects_54) $(am__objects_55) \
|
||||
$(am__objects_56) $(am__objects_57) $(am__objects_58) \
|
||||
$(am__objects_59) $(am__objects_60) $(am__objects_61) \
|
||||
$(am__objects_62) $(am__objects_63) $(am__objects_64) \
|
||||
$(am__objects_65) $(am__objects_66) $(am__objects_67)
|
||||
@FINAL_FALSE@am_lib@ULIB@_la_OBJECTS = $(am__objects_26) \
|
||||
@FINAL_FALSE@ $(am__objects_68)
|
||||
@FINAL_TRUE@am_lib@ULIB@_la_OBJECTS = all_c.lo base/xxhash/xxhash.lo \
|
||||
|
@ -810,24 +810,24 @@ SRC_CPP = internal/common.cpp internal/error.cpp ui/dialog.cpp \
|
|||
net/client/imap.cpp net/client/http.cpp net/client/client.cpp \
|
||||
net/client/redis.cpp net/client/elasticsearch.cpp \
|
||||
net/ipt_ACCOUNT.cpp json/value.cpp serialize/flatbuffers.cpp \
|
||||
query/query_parser.cpp event/event_time.cpp timeval.cpp \
|
||||
timer.cpp notifier.cpp string.cpp file.cpp process.cpp \
|
||||
file_config.cpp log.cpp options.cpp application.cpp cache.cpp \
|
||||
date.cpp url.cpp tokenizer.cpp command.cpp $(am__append_1) \
|
||||
$(am__append_2) $(am__append_3) $(am__append_4) \
|
||||
$(am__append_5) $(am__append_7) $(am__append_8) \
|
||||
$(am__append_28) $(am__append_31) $(am__append_33) \
|
||||
$(am__append_34) $(am__append_36) $(am__append_37) \
|
||||
$(am__append_38) $(am__append_39) $(am__append_40) \
|
||||
$(am__append_41) $(am__append_42) $(am__append_43) \
|
||||
$(am__append_44) $(am__append_45) $(am__append_47) \
|
||||
$(am__append_48) $(am__append_49) $(am__append_50) \
|
||||
$(am__append_51) $(am__append_52) $(am__append_53) \
|
||||
$(am__append_54) $(am__append_55) $(am__append_56) \
|
||||
$(am__append_57) $(am__append_58) $(am__append_59) \
|
||||
$(am__append_60) $(am__append_61) $(am__append_62) \
|
||||
$(am__append_63) $(am__append_64) $(am__append_65) \
|
||||
$(am__append_68)
|
||||
query/query_parser.cpp event/event_time.cpp event/event_db.cpp \
|
||||
timeval.cpp timer.cpp notifier.cpp string.cpp file.cpp \
|
||||
process.cpp file_config.cpp log.cpp options.cpp \
|
||||
application.cpp cache.cpp date.cpp url.cpp tokenizer.cpp \
|
||||
command.cpp $(am__append_1) $(am__append_2) $(am__append_3) \
|
||||
$(am__append_4) $(am__append_5) $(am__append_7) \
|
||||
$(am__append_8) $(am__append_28) $(am__append_31) \
|
||||
$(am__append_33) $(am__append_34) $(am__append_36) \
|
||||
$(am__append_37) $(am__append_38) $(am__append_39) \
|
||||
$(am__append_40) $(am__append_41) $(am__append_42) \
|
||||
$(am__append_43) $(am__append_44) $(am__append_45) \
|
||||
$(am__append_47) $(am__append_48) $(am__append_49) \
|
||||
$(am__append_50) $(am__append_51) $(am__append_52) \
|
||||
$(am__append_53) $(am__append_54) $(am__append_55) \
|
||||
$(am__append_56) $(am__append_57) $(am__append_58) \
|
||||
$(am__append_59) $(am__append_60) $(am__append_61) \
|
||||
$(am__append_62) $(am__append_63) $(am__append_64) \
|
||||
$(am__append_65) $(am__append_68)
|
||||
lib@ULIB@_la_LDFLAGS = @ULIB_LIBS@ $(am__append_66) -version-info \
|
||||
1:0:0 -release @ULIB_VERSION@ $(am__append_67)
|
||||
@MINGW_TRUE@lib@ULIB@_la_DEPENDENCIES = ULib-win32-res.o
|
||||
|
@ -1258,6 +1258,8 @@ event/$(DEPDIR)/$(am__dirstamp):
|
|||
@: > event/$(DEPDIR)/$(am__dirstamp)
|
||||
event/event_time.lo: event/$(am__dirstamp) \
|
||||
event/$(DEPDIR)/$(am__dirstamp)
|
||||
event/event_db.lo: event/$(am__dirstamp) \
|
||||
event/$(DEPDIR)/$(am__dirstamp)
|
||||
db/tdb.lo: db/$(am__dirstamp) db/$(DEPDIR)/$(am__dirstamp)
|
||||
net/client/mongodb.lo: net/client/$(am__dirstamp) \
|
||||
net/client/$(DEPDIR)/$(am__dirstamp)
|
||||
|
@ -1639,6 +1641,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@debug/$(DEPDIR)/trace.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@dynamic/$(DEPDIR)/dynamic.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@dynamic/$(DEPDIR)/plugin.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/event_db.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@event/$(DEPDIR)/event_time.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@flex/$(DEPDIR)/bison.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@flex/$(DEPDIR)/flexer.Plo@am__quote@
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "container/vector.cpp"
|
||||
#include "container/hash_map.cpp"
|
||||
#include "container/tree.cpp"
|
||||
#include "event/event_db.cpp"
|
||||
#include "event/event_time.cpp"
|
||||
#include "net/socket.cpp"
|
||||
#include "net/ipaddress.cpp"
|
||||
|
|
137
src/ulib/event/event_db.cpp
Normal file
137
src/ulib/event/event_db.cpp
Normal file
|
@ -0,0 +1,137 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// = LIBRARY
|
||||
// ULib - c++ library
|
||||
//
|
||||
// = FILENAME
|
||||
// event_db.cpp
|
||||
//
|
||||
// = AUTHOR
|
||||
// Stefano Casazza
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#include <ulib/event/event_db.h>
|
||||
#include <ulib/net/server/server.h>
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
# include <ulib/orm/driver/orm_driver_pgsql.h>
|
||||
#endif
|
||||
|
||||
void UEventDB::setConnection(void* connection)
|
||||
{
|
||||
U_TRACE(0, "UEventDB::setConnection(%p)", connection)
|
||||
|
||||
conn = connection;
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
UEventFd::fd = U_SYSCALL(PQsocket, "%p", (PGconn*)conn);
|
||||
|
||||
(void) U_SYSCALL(PQsetnonblocking, "%p,%u", (PGconn*)conn, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void UEventDB::addClientImage(vPFpvu handlerResult, uint32_t num_query)
|
||||
{
|
||||
U_TRACE(0, "UEventDB::addClientImage(%p,%u)", handlerResult, num_query)
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
(void) U_SYSCALL(PQflush, "%p", (PGconn*)conn);
|
||||
#endif
|
||||
|
||||
UClientImage_Base::setRequestProcessed();
|
||||
|
||||
U_INTERNAL_DUMP("start = %u end = %u", start, end)
|
||||
|
||||
query_info* pquery = query+end;
|
||||
|
||||
pquery->handlerResult = handlerResult;
|
||||
pquery->pClientImage = UServer_Base::pClientImage;
|
||||
pquery->num_query = num_query;
|
||||
pquery->num_result = 0;
|
||||
|
||||
end = (end+1) & 511;
|
||||
|
||||
U_INTERNAL_DUMP("start = %u end = %u", start, end)
|
||||
|
||||
U_INTERNAL_ASSERT_DIFFERS(end, start)
|
||||
}
|
||||
|
||||
int UEventDB::handlerRead()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UEventDB::handlerRead()")
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
if (U_SYSCALL(PQconsumeInput, "%p", (PGconn*)conn))
|
||||
{
|
||||
bool bopen;
|
||||
PGresult* result;
|
||||
query_info* pquery;
|
||||
|
||||
loop: U_INTERNAL_DUMP("start = %u end = %u", start, end)
|
||||
|
||||
pquery = query+start;
|
||||
|
||||
U_INTERNAL_DUMP("pquery->pClientImage = %p pquery->num_query = %u pquery->num_result = %u", pquery->pClientImage, pquery->num_query, pquery->num_result)
|
||||
|
||||
bopen = pquery->pClientImage->isOpen();
|
||||
|
||||
while (U_SYSCALL(PQisBusy, "%p", (PGconn*)conn) == 0)
|
||||
{
|
||||
result = (PGresult*) U_SYSCALL(PQgetResult, "%p", (PGconn*)conn);
|
||||
|
||||
if (result == U_NULLPTR) U_RETURN(U_NOTIFIER_OK);
|
||||
|
||||
pquery->num_result++;
|
||||
|
||||
U_INTERNAL_DUMP("Result status: %d (%s) for num_result(%u), tuples(%d)", PQresultStatus(result), PQresStatus(PQresultStatus(result)), pquery->num_result, PQntuples(result))
|
||||
|
||||
if (bopen) pquery->handlerResult(result, pquery->num_result);
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", result);
|
||||
|
||||
U_INTERNAL_DUMP("pquery->num_query = %u pquery->num_result = %u", pquery->num_query, pquery->num_result)
|
||||
|
||||
if (pquery->num_query == pquery->num_result)
|
||||
{
|
||||
pquery->pClientImage->writeResponseCompact();
|
||||
|
||||
start = (start+1) & 511;
|
||||
|
||||
if (start == end)
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(PQgetResult((PGconn*)conn), U_NULLPTR)
|
||||
|
||||
U_RETURN(U_NOTIFIER_OK);
|
||||
}
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
U_RETURN(U_NOTIFIER_OK);
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* UEventDB::dump(bool _reset) const
|
||||
{
|
||||
*UObjectIO::os << "end " << end << '\n'
|
||||
<< "conn " << (void*)conn << '\n'
|
||||
<< "start " << start;
|
||||
|
||||
if (_reset)
|
||||
{
|
||||
UObjectIO::output();
|
||||
|
||||
return UObjectIO::buffer_output;
|
||||
}
|
||||
|
||||
return U_NULLPTR;
|
||||
}
|
||||
#endif
|
|
@ -135,11 +135,7 @@ UClientImage_Base::UClientImage_Base()
|
|||
|
||||
// NB: array are not pointers (virtual table can shift the address of 'this')...
|
||||
|
||||
if (UServer_Base::pClientImage == U_NULLPTR)
|
||||
{
|
||||
UServer_Base::pClientImage = this;
|
||||
UServer_Base::eClientImage = this + UNotifier::max_connection;
|
||||
}
|
||||
if (UServer_Base::pClientImage == U_NULLPTR) UServer_Base::eClientImage = (UServer_Base::pClientImage = this) + UNotifier::max_connection;
|
||||
}
|
||||
|
||||
UClientImage_Base::~UClientImage_Base()
|
||||
|
@ -460,13 +456,13 @@ void UClientImage_Base::handlerDelete()
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UClientImage_Base::handlerDelete()")
|
||||
|
||||
bool bsocket_open = socket->isOpen();
|
||||
bool bsocket_open = isOpen();
|
||||
|
||||
#if !defined(USE_LIBEVENT) && defined(HAVE_EPOLL_WAIT) && defined(DEBUG)
|
||||
if (UNLIKELY(UNotifier::num_connection <= UNotifier::min_connection))
|
||||
{
|
||||
U_WARNING("handlerDelete(): "
|
||||
"UEventFd::fd = %d socket->iSockDesc = %d socket->isOpen() = %b "
|
||||
"UEventFd::fd = %d socket->iSockDesc = %d isOpen() = %b "
|
||||
"UNotifier::num_connection = %d UNotifier::min_connection = %d "
|
||||
"UServer_Base::isParallelizationChild() = %b sfd = %d UEventFd::op_mask = %B",
|
||||
UEventFd::fd, socket->iSockDesc, bsocket_open, UNotifier::num_connection, UNotifier::min_connection, UServer_Base::isParallelizationChild(), sfd, UEventFd::op_mask);
|
||||
|
@ -1114,8 +1110,8 @@ bool UClientImage_Base::genericRead()
|
|||
{
|
||||
if (USocketExt::read(socket, *rbuffer, U_SINGLE_READ, 0) == false) // NB: timeout == 0 means that we put the socket fd on epoll queue if EAGAIN...
|
||||
{
|
||||
U_ClientImage_state = (socket->isOpen() ? U_PLUGIN_HANDLER_AGAIN
|
||||
: U_PLUGIN_HANDLER_ERROR);
|
||||
U_ClientImage_state = (isOpen() ? U_PLUGIN_HANDLER_AGAIN
|
||||
: U_PLUGIN_HANDLER_ERROR);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
@ -1186,7 +1182,7 @@ start:
|
|||
if (U_ClientImage_state == U_PLUGIN_HANDLER_AGAIN &&
|
||||
U_ClientImage_parallelization != U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_ASSERT(isOpen())
|
||||
|
||||
# ifdef DEBUG
|
||||
UServer_Base::nread_again++;
|
||||
|
@ -1199,7 +1195,7 @@ start:
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_ASSERT(isOpen())
|
||||
|
||||
UServer_Base::nread++;
|
||||
#endif
|
||||
|
@ -1270,7 +1266,7 @@ data_missing:
|
|||
|
||||
U_INTERNAL_DUMP("data_pending(%u) = %V", data_pending->size(), data_pending->rep)
|
||||
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_ASSERT(isOpen())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
|
||||
|
||||
U_RETURN(U_NOTIFIER_OK);
|
||||
|
@ -1331,7 +1327,7 @@ cls: if (U_ClientImage_parallelization == U_PARALLELIZATION_PARENT)
|
|||
U_INTERNAL_DUMP("U_ClientImage_pipeline = %b U_ClientImage_parallelization = %d U_ClientImage_data_missing = %b",
|
||||
U_ClientImage_pipeline, U_ClientImage_parallelization, U_ClientImage_data_missing)
|
||||
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_ASSERT(isOpen())
|
||||
U_INTERNAL_ASSERT_EQUALS(U_ClientImage_state & U_PLUGIN_HANDLER_ERROR, 0)
|
||||
|
||||
if (U_ClientImage_data_missing) goto data_missing;
|
||||
|
@ -1454,6 +1450,18 @@ check: U_INTERNAL_DUMP("nrequest = %u resto = %u", nrequest, resto)
|
|||
|
||||
if (UNLIKELY(socket->isClosed())) goto cls;
|
||||
}
|
||||
#if defined(U_SERVER_CAPTIVE_PORTAL) && defined(ENABLE_THREAD)
|
||||
else
|
||||
{
|
||||
writeResponseCompact();
|
||||
|
||||
U_INTERNAL_DUMP("U_ClientImage_request_is_cached = %b", U_ClientImage_request_is_cached)
|
||||
|
||||
if (U_ClientImage_request_is_cached == false) endRequest();
|
||||
|
||||
U_RETURN(U_NOTIFIER_OK);
|
||||
}
|
||||
#endif
|
||||
|
||||
U_INTERNAL_DUMP("socket->isClosed() = %b U_http_info.nResponseCode = %u U_ClientImage_close = %b U_ClientImage_state = %d %B",
|
||||
socket->isClosed(), U_http_info.nResponseCode, U_ClientImage_close, U_ClientImage_state, U_ClientImage_state)
|
||||
|
@ -1563,15 +1571,7 @@ error:
|
|||
if (uri) UServer_Base::clearThrottling();
|
||||
#endif
|
||||
|
||||
#if defined(U_SERVER_CAPTIVE_PORTAL) && defined(ENABLE_THREAD)
|
||||
U_INTERNAL_DUMP("U_ClientImage_request_is_cached = %b", U_ClientImage_request_is_cached)
|
||||
|
||||
if (U_ClientImage_request_is_cached == false) endRequest();
|
||||
|
||||
U_RETURN(U_NOTIFIER_OK);
|
||||
#else
|
||||
endRequest();
|
||||
#endif
|
||||
|
||||
U_DUMP("U_ClientImage_close = %b UServer_Base::isParallelizationChild() = %b", U_ClientImage_close, UServer_Base::isParallelizationChild())
|
||||
|
||||
|
@ -1601,7 +1601,7 @@ death:
|
|||
|
||||
last_event = u_now->tv_sec;
|
||||
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_ASSERT(isOpen())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_PARENT)
|
||||
|
||||
|
@ -1616,8 +1616,8 @@ bool UClientImage_Base::writeResponse()
|
|||
|
||||
U_INTERNAL_DUMP("U_ClientImage_pipeline = %b U_ClientImage_close = %b nrequest = %u", U_ClientImage_pipeline, U_ClientImage_close, nrequest)
|
||||
|
||||
U_ASSERT(isOpen())
|
||||
U_INTERNAL_ASSERT(*wbuffer)
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_http_version, '2')
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_PARENT)
|
||||
|
||||
|
@ -1719,8 +1719,6 @@ bool UClientImage_Base::writeResponse()
|
|||
else
|
||||
#endif
|
||||
{
|
||||
U_DUMP_IOVEC(iov,iovcnt)
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(nrequest, 0)
|
||||
|
||||
iBytesWrite = USocketExt::writev(socket, iov, iovcnt, ncount, U_ClientImage_pipeline ? U_TIMEOUT_MS : 0);
|
||||
|
@ -1865,9 +1863,9 @@ int UClientImage_Base::handlerWrite()
|
|||
}
|
||||
#endif
|
||||
|
||||
U_ASSERT(isOpen())
|
||||
U_INTERNAL_ASSERT_MAJOR(sfd, 0)
|
||||
U_INTERNAL_ASSERT_MAJOR(count, 0)
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
|
||||
bool bwrite = (UEventFd::op_mask == EPOLLOUT);
|
||||
|
||||
|
@ -1926,7 +1924,7 @@ write:
|
|||
|
||||
U_INTERNAL_ASSERT_MAJOR(count, 0)
|
||||
|
||||
if (socket->isOpen() == false) goto end;
|
||||
if (isOpen() == false) goto end;
|
||||
|
||||
if (bwrite) U_RETURN(U_NOTIFIER_OK);
|
||||
|
||||
|
|
|
@ -14,10 +14,23 @@ usp_translator_LDFLAGS = $(PRG_LDFLAGS)
|
|||
|
||||
bin_PROGRAMS = usp_translator
|
||||
|
||||
libWorld_la_SOURCES = libWorld.cxx
|
||||
libWorldNoSql_la_SOURCES = libWorldNoSql.cxx
|
||||
libFortune_la_SOURCES = libFortune.cxx
|
||||
LDADD = @ULIBS@ $(top_builddir)/src/ulib/lib@ULIB@.la @ULIB_LIBS@
|
||||
|
||||
libWorld_la_SOURCES = libWorld.cxx
|
||||
libWorld_la_LIBADD = $(LDADD)
|
||||
libWorld_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
|
||||
libWorldNoSql_la_SOURCES = libWorldNoSql.cxx
|
||||
libWorldNoSql_la_LIBADD = $(LDADD)
|
||||
libWorldNoSql_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
|
||||
libFortune_la_SOURCES = libFortune.cxx
|
||||
libFortune_la_LIBADD = $(LDADD)
|
||||
libFortune_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
|
||||
libFortuneNoSql_la_SOURCES = libFortuneNoSql.cxx
|
||||
libFortuneNoSql_la_LIBADD = $(LDADD)
|
||||
libFortuneNoSql_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
|
||||
## for convenience library
|
||||
noinst_LTLIBRARIES = libWorld.la libWorldNoSql.la libFortune.la libFortuneNoSql.la
|
||||
|
|
|
@ -110,27 +110,42 @@ CONFIG_HEADER = $(top_builddir)/include/ulib/internal/config.h
|
|||
CONFIG_CLEAN_FILES = usp_compile.sh
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libFortune_la_LIBADD =
|
||||
am__DEPENDENCIES_1 = $(top_builddir)/src/ulib/lib@ULIB@.la
|
||||
libFortune_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libFortune_la_OBJECTS = libFortune.lo
|
||||
libFortune_la_OBJECTS = $(am_libFortune_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
libFortuneNoSql_la_LIBADD =
|
||||
libFortune_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS) $(libFortune_la_LDFLAGS) $(LDFLAGS) \
|
||||
-o $@
|
||||
libFortuneNoSql_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libFortuneNoSql_la_OBJECTS = libFortuneNoSql.lo
|
||||
libFortuneNoSql_la_OBJECTS = $(am_libFortuneNoSql_la_OBJECTS)
|
||||
libWorld_la_LIBADD =
|
||||
libFortuneNoSql_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS) $(libFortuneNoSql_la_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
libWorld_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libWorld_la_OBJECTS = libWorld.lo
|
||||
libWorld_la_OBJECTS = $(am_libWorld_la_OBJECTS)
|
||||
libWorldNoSql_la_LIBADD =
|
||||
libWorld_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
$(CXXFLAGS) $(libWorld_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
libWorldNoSql_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libWorldNoSql_la_OBJECTS = libWorldNoSql.lo
|
||||
libWorldNoSql_la_OBJECTS = $(am_libWorldNoSql_la_OBJECTS)
|
||||
libWorldNoSql_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
$(AM_CXXFLAGS) $(CXXFLAGS) $(libWorldNoSql_la_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_usp_translator_OBJECTS = usp_translator.$(OBJEXT)
|
||||
usp_translator_OBJECTS = $(am_usp_translator_OBJECTS)
|
||||
am__DEPENDENCIES_1 = $(top_builddir)/src/ulib/lib@ULIB@.la
|
||||
usp_translator_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
usp_translator_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
|
||||
|
@ -399,10 +414,19 @@ ulib_la = @ULIBS@ $(top_builddir)/src/ulib/lib@ULIB@.la
|
|||
usp_translator_LDADD = $(ulib_la) @ULIB_LIBS@
|
||||
usp_translator_SOURCES = usp_translator.cpp
|
||||
usp_translator_LDFLAGS = $(PRG_LDFLAGS)
|
||||
LDADD = @ULIBS@ $(top_builddir)/src/ulib/lib@ULIB@.la @ULIB_LIBS@
|
||||
libWorld_la_SOURCES = libWorld.cxx
|
||||
libWorld_la_LIBADD = $(LDADD)
|
||||
libWorld_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
libWorldNoSql_la_SOURCES = libWorldNoSql.cxx
|
||||
libWorldNoSql_la_LIBADD = $(LDADD)
|
||||
libWorldNoSql_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
libFortune_la_SOURCES = libFortune.cxx
|
||||
libFortune_la_LIBADD = $(LDADD)
|
||||
libFortune_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
libFortuneNoSql_la_SOURCES = libFortuneNoSql.cxx
|
||||
libFortuneNoSql_la_LIBADD = $(LDADD)
|
||||
libFortuneNoSql_la_LDFLAGS = -module -rpath /nowhere @MODULE_LIBTOOL_OPTIONS@
|
||||
noinst_LTLIBRARIES = libWorld.la libWorldNoSql.la libFortune.la libFortuneNoSql.la
|
||||
@CROSS_COMPILING_FALSE@moduledir = @ULIB_MODULEDIR@/usp
|
||||
@CROSS_COMPILING_FALSE@AM_CPPFLAGS = @USP_FLAGS@
|
||||
|
@ -455,16 +479,16 @@ clean-noinstLTLIBRARIES:
|
|||
}
|
||||
|
||||
libFortune.la: $(libFortune_la_OBJECTS) $(libFortune_la_DEPENDENCIES) $(EXTRA_libFortune_la_DEPENDENCIES)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(libFortune_la_OBJECTS) $(libFortune_la_LIBADD) $(LIBS)
|
||||
$(AM_V_CXXLD)$(libFortune_la_LINK) $(libFortune_la_OBJECTS) $(libFortune_la_LIBADD) $(LIBS)
|
||||
|
||||
libFortuneNoSql.la: $(libFortuneNoSql_la_OBJECTS) $(libFortuneNoSql_la_DEPENDENCIES) $(EXTRA_libFortuneNoSql_la_DEPENDENCIES)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(libFortuneNoSql_la_OBJECTS) $(libFortuneNoSql_la_LIBADD) $(LIBS)
|
||||
$(AM_V_CXXLD)$(libFortuneNoSql_la_LINK) $(libFortuneNoSql_la_OBJECTS) $(libFortuneNoSql_la_LIBADD) $(LIBS)
|
||||
|
||||
libWorld.la: $(libWorld_la_OBJECTS) $(libWorld_la_DEPENDENCIES) $(EXTRA_libWorld_la_DEPENDENCIES)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(libWorld_la_OBJECTS) $(libWorld_la_LIBADD) $(LIBS)
|
||||
$(AM_V_CXXLD)$(libWorld_la_LINK) $(libWorld_la_OBJECTS) $(libWorld_la_LIBADD) $(LIBS)
|
||||
|
||||
libWorldNoSql.la: $(libWorldNoSql_la_OBJECTS) $(libWorldNoSql_la_DEPENDENCIES) $(EXTRA_libWorldNoSql_la_DEPENDENCIES)
|
||||
$(AM_V_CXXLD)$(CXXLINK) $(libWorldNoSql_la_OBJECTS) $(libWorldNoSql_la_LIBADD) $(LIBS)
|
||||
$(AM_V_CXXLD)$(libWorldNoSql_la_LINK) $(libWorldNoSql_la_OBJECTS) $(libWorldNoSql_la_LIBADD) $(LIBS)
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
|
|
|
@ -5,26 +5,33 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
static void handlerResult(void* res, uint32_t num_result)
|
||||
{
|
||||
U_TRACE(5, "::handlerResult(%p,%u)", res, num_result)
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(num_result, 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields((PGresult*)res), 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQntuples((PGresult*)res), 1)
|
||||
|
||||
char* randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, 0, 0);
|
||||
|
||||
World::handlerOneResult(ntohl(*(uint32_t*)randomNumber));
|
||||
}
|
||||
#endif
|
||||
|
||||
static void usp_init_db() { World::handlerInitSql(); }
|
||||
static void usp_fork_db() { World::handlerForkSql(); }
|
||||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#code
|
||||
World::initOneResult();
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
if (World::pdrv)
|
||||
{
|
||||
PGresult* res = World::execPrepared();
|
||||
World::sendQueryPrepared();
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQntuples(res), 1)
|
||||
|
||||
char* randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
|
||||
|
||||
World::handlerOneResult(World::rnumber[0], ntohl(*(uint32_t*)randomNumber));
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
((UEventDB*)UServer_Base::handler_db1)->addClientImage(handlerResult);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -33,8 +40,6 @@ World::pworld_query->id = World::rnumber[0];
|
|||
|
||||
(void) World::pstmt_query->execute();
|
||||
|
||||
World::handlerOneResult(World::pworld_query->id, World::pworld_query->randomNumber);
|
||||
World::handlerOneResult(World::pworld_query->randomNumber);
|
||||
}
|
||||
|
||||
World::endOneResult();
|
||||
-->
|
||||
|
|
|
@ -11,10 +11,11 @@
|
|||
#include <ulib/net/server/client_image.h>
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
# include <ulib/event/event_db.h>
|
||||
# include <ulib/orm/driver/orm_driver_pgsql.h>
|
||||
#endif
|
||||
|
||||
class Fortune {
|
||||
class U_EXPORT Fortune {
|
||||
public:
|
||||
// Check for memory error
|
||||
U_MEMORY_TEST
|
||||
|
@ -109,12 +110,35 @@ public:
|
|||
}
|
||||
|
||||
static uint32_t uid;
|
||||
static char* pwbuffer;
|
||||
static UString* pmessage;
|
||||
static UVector<Fortune*>* pvfortune;
|
||||
|
||||
static UOrmSession* psql_fortune;
|
||||
static UOrmStatement* pstmt_fortune;
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
static PGconn* conn;
|
||||
static UOrmDriverPgSql* pdrv;
|
||||
static UPgSqlStatement* pstmt;
|
||||
|
||||
static PGresult* execPrepared()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "Fortune::execPrepared()")
|
||||
|
||||
PGresult* res = (PGresult*) U_SYSCALL(PQexecPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 0, 0, 0, 0, 1);
|
||||
|
||||
U_RETURN_POINTER(res, PGresult);
|
||||
}
|
||||
|
||||
static void sendQueryPrepared()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "Fortune::sendQueryPrepared()")
|
||||
|
||||
(void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 0, 0, 0, 0, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void replace(uint32_t i, uint32_t _id, const char* msg, uint32_t len)
|
||||
{
|
||||
U_TRACE(5, "Fortune::replace(%u,%u,%.*S,%u)", i, _id, len, msg, len)
|
||||
|
@ -133,42 +157,55 @@ public:
|
|||
static void replace(uint32_t i, const UString& message) { replace(i, i+1, U_STRING_TO_PARAM(message)); }
|
||||
static void replace(uint32_t i, uint32_t _id, const UString& message) { replace(i, _id, U_STRING_TO_PARAM(message)); }
|
||||
|
||||
static void doQuery(vPF handlerQuery)
|
||||
static void initQuery()
|
||||
{
|
||||
U_TRACE(5, "Fortune::doQuery(%p)", handlerQuery)
|
||||
U_TRACE_NO_PARAM(5, "::initQuery()")
|
||||
|
||||
char* ptr = UClientImage_Base::wbuffer->data();
|
||||
|
||||
U_INTERNAL_DUMP("wbuffer(%u) = %#.10S", UClientImage_Base::wbuffer->size(), ptr)
|
||||
|
||||
if (*ptr == '\0')
|
||||
{
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('1','2','2','7','\r','\n','C','o'));
|
||||
u_put_unalignedp64(ptr+24, U_MULTICHAR_CONSTANT64('n','t','e','n','t','-','T','y'));
|
||||
u_put_unalignedp64(ptr+32, U_MULTICHAR_CONSTANT64('p','e',':',' ','t','e','x','t'));
|
||||
u_put_unalignedp64(ptr+40, U_MULTICHAR_CONSTANT64('/','h','t','m','l',';',' ','c'));
|
||||
u_put_unalignedp64(ptr+48, U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U'));
|
||||
u_put_unalignedp64(ptr+56, U_MULTICHAR_CONSTANT64('T','F','-','8','\r','\n','\r','\n'));
|
||||
u_put_unalignedp64(ptr+64, U_MULTICHAR_CONSTANT64('<','!','d','o','c','t','y','p'));
|
||||
u_put_unalignedp64(ptr+72, U_MULTICHAR_CONSTANT64('e',' ','h','t','m','l','>','<'));
|
||||
u_put_unalignedp64(ptr+80, U_MULTICHAR_CONSTANT64('h','t','m','l','>','<','h','e'));
|
||||
u_put_unalignedp64(ptr+88, U_MULTICHAR_CONSTANT64('a','d','>','<','t','i','t','l'));
|
||||
u_put_unalignedp64(ptr+96, U_MULTICHAR_CONSTANT64('e','>','F','o','r','t','u','n'));
|
||||
u_put_unalignedp64(ptr+104, U_MULTICHAR_CONSTANT64('e','s','<','/','t','i','t','l'));
|
||||
u_put_unalignedp64(ptr+112, U_MULTICHAR_CONSTANT64('e','>','<','/','h','e','a','d'));
|
||||
u_put_unalignedp64(ptr+120, U_MULTICHAR_CONSTANT64('>','<','b','o','d','y','>','<'));
|
||||
u_put_unalignedp64(ptr+128, U_MULTICHAR_CONSTANT64('t','a','b','l','e','>','<','t'));
|
||||
u_put_unalignedp64(ptr+136, U_MULTICHAR_CONSTANT64('r','>','<','t','h','>','i','d'));
|
||||
u_put_unalignedp64(ptr+144, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','t','h'));
|
||||
u_put_unalignedp64(ptr+152, U_MULTICHAR_CONSTANT64('>','m','e','s','s','a','g','e'));
|
||||
u_put_unalignedp64(ptr+160, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','/','t'));
|
||||
u_put_unalignedp16(ptr+168, U_MULTICHAR_CONSTANT16('r','>'));
|
||||
|
||||
pwbuffer = ptr + U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n"
|
||||
"<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>");
|
||||
|
||||
UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n") + 1227);
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->data()), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->c_pointer(48)), U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U'))
|
||||
}
|
||||
|
||||
static void endQuery()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "::endQuery()")
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(pvfortune)
|
||||
|
||||
char* pwbuffer = UClientImage_Base::wbuffer->data();
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp64(pwbuffer+16, U_MULTICHAR_CONSTANT64('1','2','2','7','\r','\n','C','o'));
|
||||
u_put_unalignedp64(pwbuffer+24, U_MULTICHAR_CONSTANT64('n','t','e','n','t','-','T','y'));
|
||||
u_put_unalignedp64(pwbuffer+32, U_MULTICHAR_CONSTANT64('p','e',':',' ','t','e','x','t'));
|
||||
u_put_unalignedp64(pwbuffer+40, U_MULTICHAR_CONSTANT64('/','h','t','m','l',';',' ','c'));
|
||||
u_put_unalignedp64(pwbuffer+48, U_MULTICHAR_CONSTANT64('h','a','r','s','e','t','=','U'));
|
||||
u_put_unalignedp64(pwbuffer+56, U_MULTICHAR_CONSTANT64('T','F','-','8','\r','\n','\r','\n'));
|
||||
u_put_unalignedp64(pwbuffer+64, U_MULTICHAR_CONSTANT64('<','!','d','o','c','t','y','p'));
|
||||
u_put_unalignedp64(pwbuffer+72, U_MULTICHAR_CONSTANT64('e',' ','h','t','m','l','>','<'));
|
||||
u_put_unalignedp64(pwbuffer+80, U_MULTICHAR_CONSTANT64('h','t','m','l','>','<','h','e'));
|
||||
u_put_unalignedp64(pwbuffer+88, U_MULTICHAR_CONSTANT64('a','d','>','<','t','i','t','l'));
|
||||
u_put_unalignedp64(pwbuffer+96, U_MULTICHAR_CONSTANT64('e','>','F','o','r','t','u','n'));
|
||||
u_put_unalignedp64(pwbuffer+104, U_MULTICHAR_CONSTANT64('e','s','<','/','t','i','t','l'));
|
||||
u_put_unalignedp64(pwbuffer+112, U_MULTICHAR_CONSTANT64('e','>','<','/','h','e','a','d'));
|
||||
u_put_unalignedp64(pwbuffer+120, U_MULTICHAR_CONSTANT64('>','<','b','o','d','y','>','<'));
|
||||
u_put_unalignedp64(pwbuffer+128, U_MULTICHAR_CONSTANT64('t','a','b','l','e','>','<','t'));
|
||||
u_put_unalignedp64(pwbuffer+136, U_MULTICHAR_CONSTANT64('r','>','<','t','h','>','i','d'));
|
||||
u_put_unalignedp64(pwbuffer+144, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','t','h'));
|
||||
u_put_unalignedp64(pwbuffer+152, U_MULTICHAR_CONSTANT64('>','m','e','s','s','a','g','e'));
|
||||
u_put_unalignedp64(pwbuffer+160, U_MULTICHAR_CONSTANT64('<','/','t','h','>','<','/','t'));
|
||||
u_put_unalignedp16(pwbuffer+168, U_MULTICHAR_CONSTANT16('r','>'));
|
||||
|
||||
pwbuffer += U_CONSTANT_SIZE("Content-Length: 1227\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n"
|
||||
"<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>");
|
||||
|
||||
handlerQuery();
|
||||
|
||||
Fortune* elem = pvfortune->last();
|
||||
|
||||
elem->id = 0;
|
||||
|
@ -176,32 +213,55 @@ public:
|
|||
|
||||
pvfortune->sort(Fortune::cmp_obj);
|
||||
|
||||
char* ptr = pwbuffer;
|
||||
|
||||
for (uint32_t sz, i = 0, n = pvfortune->size(); i < n; ++i)
|
||||
{
|
||||
elem = pvfortune->at(i);
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>'));
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>'));
|
||||
|
||||
pwbuffer = u_num2str32(elem->id, pwbuffer+8);
|
||||
ptr = u_num2str32(elem->id, ptr+8);
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d'));
|
||||
pwbuffer += 8;
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d'));
|
||||
ptr += 8;
|
||||
|
||||
*pwbuffer++ = '>';
|
||||
*ptr++ = '>';
|
||||
|
||||
(void) memcpy(pwbuffer, elem->message.data(), sz = elem->message.size());
|
||||
pwbuffer += sz;
|
||||
(void) memcpy(ptr, elem->message.data(), sz = elem->message.size());
|
||||
ptr += sz;
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
||||
u_put_unalignedp16(pwbuffer+8, U_MULTICHAR_CONSTANT16('r','>'));
|
||||
pwbuffer += 8+2;
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
|
||||
u_put_unalignedp16(ptr+8, U_MULTICHAR_CONSTANT16('r','>'));
|
||||
ptr += 8+2;
|
||||
}
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('<','/','t','a','b','l','e','>'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('<','/','b','o','d','y','>','<'));
|
||||
u_put_unalignedp64(pwbuffer+16, U_MULTICHAR_CONSTANT64('/','h','t','m','l','>','\0','\0'));
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','a','b','l','e','>'));
|
||||
u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('<','/','b','o','d','y','>','<'));
|
||||
u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64('/','h','t','m','l','>','\0','\0'));
|
||||
}
|
||||
|
||||
UClientImage_Base::wbuffer->size_adjust_constant(pwbuffer + U_CONSTANT_SIZE("</table></body></html>"));
|
||||
static void doQuery(vPF handlerQuery)
|
||||
{
|
||||
U_TRACE(5, "Fortune::doQuery(%p)", handlerQuery)
|
||||
|
||||
initQuery();
|
||||
handlerQuery();
|
||||
endQuery();
|
||||
}
|
||||
|
||||
static void handlerInitSql()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "Fortune::handlerInitSql()")
|
||||
|
||||
# ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
U_INTERNAL_DUMP("UServer_Base::handler_db2 = %p", UServer_Base::handler_db2)
|
||||
|
||||
if (UServer_Base::handler_db2 == U_NULLPTR)
|
||||
{
|
||||
U_NEW_WITHOUT_CHECK_MEMORY(UEventDB, UServer_Base::handler_db2, UEventDB);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
static void handlerFork()
|
||||
|
@ -246,6 +306,18 @@ public:
|
|||
handlerFork();
|
||||
|
||||
pstmt_fortune->into(uid, *pmessage);
|
||||
|
||||
# ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
if (UOrmDriver::isPGSQL())
|
||||
{
|
||||
conn = (PGconn*)(pdrv = (UOrmDriverPgSql*)psql_fortune->getDriver())->UOrmDriver::connection;
|
||||
pstmt = (UPgSqlStatement*)pstmt_fortune->getStatement();
|
||||
|
||||
pstmt->prepareStatement(pdrv);
|
||||
|
||||
((UEventDB*)UServer_Base::handler_db2)->setConnection(conn);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,6 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "fortune.h"
|
||||
|
||||
static vPF handle_query;
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
static UOrmDriverPgSql* pdrv;
|
||||
static UPgSqlStatement* pstmt;
|
||||
#endif
|
||||
|
||||
static void handlerQuery()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "::handlerQuery()")
|
||||
|
@ -25,53 +19,49 @@ static void handlerQuery()
|
|||
while (Fortune::pstmt_fortune->nextRow());
|
||||
}
|
||||
|
||||
static void handlerQueryPGSQL()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "::handlerQueryPGSQL()")
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
static void handlerResult(void* res, uint32_t num_result)
|
||||
{
|
||||
U_TRACE(5, "::handlerResult(%p,%u)", res, num_result)
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(num_result, 1)
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields((PGresult*)res), 2)
|
||||
|
||||
int sz;
|
||||
char* id;
|
||||
char* ptr;
|
||||
PGresult* res = pdrv->execPrepared(pstmt);
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(PQnfields(res), 2)
|
||||
Fortune::initQuery();
|
||||
|
||||
for (uint32_t i = 0, n = U_SYSCALL(PQntuples, "%p", res); i < n; ++i)
|
||||
for (uint32_t i = 0, n = U_SYSCALL(PQntuples, "%p", (PGresult*)res); i < n; ++i)
|
||||
{
|
||||
id = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, i, 0);
|
||||
ptr = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, i, 1);
|
||||
sz = U_SYSCALL(PQgetlength, "%p,%d,%d", res, i, 1);
|
||||
id = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 0);
|
||||
ptr = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 1);
|
||||
sz = U_SYSCALL(PQgetlength, "%p,%d,%d", (PGresult*)res, i, 1);
|
||||
|
||||
Fortune::replace(i, ntohl(*(uint32_t*)id), ptr, sz);
|
||||
}
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
Fortune::endQuery();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void usp_fork_fortune()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "::usp_fork_fortune()")
|
||||
|
||||
Fortune::handlerForkSql();
|
||||
|
||||
if (UOrmDriver::isPGSQL() == false) handle_query = handlerQuery;
|
||||
else
|
||||
{
|
||||
handle_query = handlerQueryPGSQL;
|
||||
|
||||
# ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
pdrv = (UOrmDriverPgSql*) Fortune::psql_fortune->getDriver();
|
||||
pstmt = (UPgSqlStatement*) Fortune::pstmt_fortune->getStatement();
|
||||
|
||||
pstmt->prepareStatement(pdrv);
|
||||
# endif
|
||||
}
|
||||
}
|
||||
static void usp_init_fortune() { Fortune::handlerInitSql(); }
|
||||
static void usp_fork_fortune() { Fortune::handlerForkSql(); }
|
||||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#code
|
||||
Fortune::doQuery(handle_query);
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
if (Fortune::pdrv)
|
||||
{
|
||||
Fortune::sendQueryPrepared();
|
||||
|
||||
((UEventDB*)UServer_Base::handler_db2)->addClientImage(handlerResult);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Fortune::doQuery(handlerQuery);
|
||||
}
|
||||
-->
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# include <ulib/net/client/mongodb.h>
|
||||
#endif
|
||||
|
||||
class FortuneNoSql {
|
||||
class U_EXPORT FortuneNoSql {
|
||||
public:
|
||||
|
||||
#ifdef USE_MONGODB
|
||||
|
|
|
@ -19,18 +19,26 @@ static void usp_init_json()
|
|||
<!--#code
|
||||
char* pwbuffer = UClientImage_Base::wbuffer->data();
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp32(pwbuffer+16, U_MULTICHAR_CONSTANT32('2','7','\r','\n'));
|
||||
u_put_unalignedp64(pwbuffer+20, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(pwbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','a','p'));
|
||||
u_put_unalignedp64(pwbuffer+36, U_MULTICHAR_CONSTANT64('p','l','i','c','a','t','i','o'));
|
||||
u_put_unalignedp64(pwbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'));
|
||||
u_put_unalignedp16(pwbuffer+52, U_MULTICHAR_CONSTANT16('\r','\n'));
|
||||
U_INTERNAL_DUMP("pwbuffer = %#.10S", pwbuffer)
|
||||
|
||||
UValue::pstringify = pwbuffer + U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n");
|
||||
if (*pwbuffer == '\0')
|
||||
{
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp32(pwbuffer+16, U_MULTICHAR_CONSTANT32('2','7','\r','\n'));
|
||||
u_put_unalignedp64(pwbuffer+20, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(pwbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','a','p'));
|
||||
u_put_unalignedp64(pwbuffer+36, U_MULTICHAR_CONSTANT64('p','l','i','c','a','t','i','o'));
|
||||
u_put_unalignedp64(pwbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'));
|
||||
u_put_unalignedp16(pwbuffer+52, U_MULTICHAR_CONSTANT16('\r','\n'));
|
||||
|
||||
UValue::pstringify = pwbuffer + U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n");
|
||||
|
||||
UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 27\r\nContent-Type: application/json\r\n\r\n") + 27);
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->data()), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(UClientImage_Base::wbuffer->c_pointer(44)), U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'))
|
||||
|
||||
UValue(*pkey, *pvalue).stringify();
|
||||
|
||||
UClientImage_Base::wbuffer->size_adjust_constant(UValue::pstringify);
|
||||
-->
|
||||
|
|
|
@ -2,11 +2,17 @@
|
|||
|
||||
#include "fortune.h"
|
||||
|
||||
char* Fortune::pwbuffer;
|
||||
uint32_t Fortune::uid;
|
||||
UString* Fortune::pmessage;
|
||||
UOrmSession* Fortune::psql_fortune;
|
||||
UOrmStatement* Fortune::pstmt_fortune;
|
||||
UVector<Fortune*>* Fortune::pvfortune;
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
PGconn* Fortune::conn;
|
||||
UOrmDriverPgSql* Fortune::pdrv;
|
||||
UPgSqlStatement* Fortune::pstmt;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
const char* Fortune::dump(bool breset) const
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
#include "world.h"
|
||||
|
||||
char World::wbuffer[18000];
|
||||
char* World::ptr;
|
||||
char* World::pwbuffer;
|
||||
World* World::pworld_query;
|
||||
uint32_t World::rnum;
|
||||
uint32_t World::rnumber[500];
|
||||
uint32_t World::rnumber[501];
|
||||
UOrmSession* World::psql_query;
|
||||
UOrmStatement* World::pstmt_query;
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
|
|
|
@ -1 +1,18 @@
|
|||
Hello, World!
|
||||
<!--#header
|
||||
-->
|
||||
<!--#code
|
||||
char* pwbuffer = UClientImage_Base::wbuffer->data();
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp32(pwbuffer+16, U_MULTICHAR_CONSTANT32('1','3','\r','\n'));
|
||||
u_put_unalignedp64(pwbuffer+20, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(pwbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','t','e'));
|
||||
u_put_unalignedp64(pwbuffer+36, U_MULTICHAR_CONSTANT64('x','t','/','p','l','a','i','n'));
|
||||
u_put_unalignedp32(pwbuffer+44, U_MULTICHAR_CONSTANT32('\r','\n','\r','\n'));
|
||||
|
||||
UClientImage_Base::wbuffer->size_adjust_constant(U_CONSTANT_SIZE("Content-Length: 13\r\nContent-Type: text/plain\r\n\r\n") + 13);
|
||||
|
||||
u_put_unalignedp64(pwbuffer+48, U_MULTICHAR_CONSTANT64('H','e','l','l','o',',',' ','W'));
|
||||
u_put_unalignedp64(pwbuffer+56, U_MULTICHAR_CONSTANT64('o','r','l','d','!','\0','\0','\0'));
|
||||
-->
|
||||
|
|
|
@ -5,6 +5,7 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static void usp_init_query() { World::handlerInitSql(); }
|
||||
static void usp_fork_query() { World::handlerForkSql(); }
|
||||
-->
|
||||
<!--#header
|
||||
|
@ -29,7 +30,7 @@ if (World::pdrv)
|
|||
|
||||
randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", res, 0, 0);
|
||||
|
||||
World::handlerResult(World::rnumber[i], ntohl(*(uint32_t*)randomNumber));
|
||||
World::handlerResult(i, ntohl(*(uint32_t*)randomNumber));
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
|
@ -43,7 +44,7 @@ for (; i < num_queries; ++i)
|
|||
|
||||
World::pstmt_query->execute();
|
||||
|
||||
World::handlerResultSql(i);
|
||||
World::handlerResult(i, World::pworld_query->randomNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ static char query[8192];
|
|||
#endif
|
||||
static UOrmStatement* pstmt_update;
|
||||
|
||||
static void usp_init_update() { World::handlerInitSql(); }
|
||||
static void usp_fork_update()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_update()")
|
||||
|
@ -63,7 +64,7 @@ if (World::pdrv)
|
|||
u_put_unalignedp16(pquery, U_MULTICHAR_CONSTANT16(')',','));
|
||||
pquery += 2;
|
||||
|
||||
World::handlerResult(World::rnumber[i], World::rnum);
|
||||
World::handlerResult(i, World::rnum);
|
||||
|
||||
U_SYSCALL_VOID(PQclear, "%p", res);
|
||||
}
|
||||
|
@ -92,7 +93,7 @@ for (; i < num_queries; ++i)
|
|||
|
||||
pstmt_update->execute();
|
||||
|
||||
World::handlerResultSql(i);
|
||||
World::handlerResult(i, World::pworld_query->randomNumber);
|
||||
}
|
||||
|
||||
World::endResult();
|
||||
|
|
|
@ -473,7 +473,7 @@ public:
|
|||
{
|
||||
bhttp_header_empty = true;
|
||||
|
||||
# if !defined(U_SERVER_CAPTIVE_PORTAL) || !defined(ENABLE_THREAD)
|
||||
# if !defined(U_SERVER_CAPTIVE_PORTAL) || !defined(ENABLE_THREAD) || !defined(U_CACHE_REQUEST_DISABLE)
|
||||
(void) output1.append(U_CONSTANT_TO_PARAM("\n\tU_http_info.endHeader = U_NOT_FOUND;\n"));
|
||||
# endif
|
||||
}
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
#include <ulib/net/server/client_image.h>
|
||||
|
||||
#ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
# include <ulib/event/event_db.h>
|
||||
# include <ulib/orm/driver/orm_driver_pgsql.h>
|
||||
#endif
|
||||
|
||||
class World {
|
||||
class U_EXPORT World {
|
||||
public:
|
||||
// Check for memory error
|
||||
U_MEMORY_TEST
|
||||
|
@ -111,9 +112,10 @@ public:
|
|||
# endif
|
||||
}
|
||||
|
||||
static char* ptr;
|
||||
static char* pwbuffer;
|
||||
static char wbuffer[18000];
|
||||
static uint32_t rnum, rnumber[500];
|
||||
static uint32_t rnum, rnumber[501];
|
||||
|
||||
static World* pworld_query;
|
||||
static UOrmSession* psql_query;
|
||||
|
@ -125,21 +127,6 @@ public:
|
|||
static UPgSqlStatement* pstmt;
|
||||
static char num2str[sizeof(unsigned int)];
|
||||
|
||||
static bool initPipeline()
|
||||
{
|
||||
U_TRACE(5, "World::initPipeline()")
|
||||
|
||||
if (pdrv)
|
||||
{
|
||||
(void) U_SYSCALL(PQsetnonblocking, "%p,%u", conn, 1);
|
||||
(void) U_SYSCALL(PQenterBatchMode, "%p", conn);
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
static PGresult* execPrepared()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "World::execPrepared()")
|
||||
|
@ -166,6 +153,17 @@ public:
|
|||
U_RETURN_POINTER(res, PGresult);
|
||||
}
|
||||
|
||||
static void sendQueryPrepared()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "World::sendQueryPrepared()")
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(rnumber[0], 0)
|
||||
|
||||
*(unsigned int*)num2str = htonl(rnumber[0]);
|
||||
|
||||
(void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 1, pstmt->paramValues, pstmt->paramLengths, pstmt->paramFormats, 1);
|
||||
}
|
||||
|
||||
static void sendQueryPrepared(uint32_t i)
|
||||
{
|
||||
U_TRACE(5, "World::sendQueryPrepared(%u)", i)
|
||||
|
@ -174,122 +172,146 @@ public:
|
|||
|
||||
*(unsigned int*)num2str = htonl(rnumber[i]);
|
||||
|
||||
# ifdef DEBUG
|
||||
if (U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 1, pstmt->paramValues, pstmt->paramLengths, pstmt->paramFormats, 1) == 0)
|
||||
{
|
||||
pdrv->printError(__PRETTY_FUNCTION__);
|
||||
}
|
||||
# else
|
||||
(void) U_SYSCALL(PQsendQueryPrepared, "%p,%S,%u,%p,%p,%p,%u", conn, pstmt->stmtName, 1, pstmt->paramValues, pstmt->paramLengths, pstmt->paramFormats, 1);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static void initResult()
|
||||
{
|
||||
U_TRACE(5, "World::initResult()")
|
||||
|
||||
u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp64(wbuffer+16, U_MULTICHAR_CONSTANT64('1','3','3','3','1','\r','\n','C'));
|
||||
u_put_unalignedp64(wbuffer+24, U_MULTICHAR_CONSTANT64('o','n','t','e','n','t','-','T'));
|
||||
u_put_unalignedp64(wbuffer+32, U_MULTICHAR_CONSTANT64('y','p','e',':',' ','a','p','p'));
|
||||
u_put_unalignedp64(wbuffer+40, U_MULTICHAR_CONSTANT64('l','i','c','a','t','i','o','n'));
|
||||
u_put_unalignedp64(wbuffer+48, U_MULTICHAR_CONSTANT64('/','j','s','o','n','\r','\n','\r'));
|
||||
u_put_unalignedp16(wbuffer+56, U_MULTICHAR_CONSTANT16('\n','['));
|
||||
|
||||
pwbuffer = wbuffer + U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n[");
|
||||
}
|
||||
|
||||
static void endResult()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "World::endResult()")
|
||||
|
||||
*(pwbuffer-1) = ']';
|
||||
|
||||
uint32_t len = pwbuffer-wbuffer,
|
||||
body_len = len - U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n");
|
||||
|
||||
pwbuffer = u_num2str32(body_len, wbuffer + U_CONSTANT_SIZE("Content-Length: "));
|
||||
|
||||
while (*pwbuffer != '\r') *pwbuffer++ = ' ';
|
||||
|
||||
UClientImage_Base::wbuffer->setConstant(wbuffer, len);
|
||||
}
|
||||
|
||||
static void initOneResult()
|
||||
{
|
||||
U_TRACE(5, "World::initOneResult()")
|
||||
U_TRACE_NO_PARAM(5, "World::initOneResult()")
|
||||
|
||||
u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp32(wbuffer+16, U_MULTICHAR_CONSTANT32('3','1','\r','\n'));
|
||||
u_put_unalignedp64(wbuffer+20, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(wbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','a','p'));
|
||||
u_put_unalignedp64(wbuffer+36, U_MULTICHAR_CONSTANT64('p','l','i','c','a','t','i','o'));
|
||||
u_put_unalignedp64(wbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'));
|
||||
u_put_unalignedp32(wbuffer+52, U_MULTICHAR_CONSTANT32('\r','\n','{','\0'));
|
||||
U_INTERNAL_DUMP("wbuffer = %#.10S", wbuffer)
|
||||
|
||||
pwbuffer = wbuffer + U_CONSTANT_SIZE("Content-Length: 31\r\nContent-Type: application/json\r\n\r\n{");
|
||||
if (*wbuffer == '\0')
|
||||
{
|
||||
u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp32(wbuffer+16, U_MULTICHAR_CONSTANT32('3','1','\r','\n'));
|
||||
u_put_unalignedp64(wbuffer+20, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(wbuffer+28, U_MULTICHAR_CONSTANT64('T','y','p','e',':',' ','a','p'));
|
||||
u_put_unalignedp64(wbuffer+36, U_MULTICHAR_CONSTANT64('p','l','i','c','a','t','i','o'));
|
||||
u_put_unalignedp64(wbuffer+44, U_MULTICHAR_CONSTANT64('n','/','j','s','o','n','\r','\n'));
|
||||
u_put_unalignedp64(wbuffer+52, U_MULTICHAR_CONSTANT64('\r','\n','{','"','i','d','"',':'));
|
||||
|
||||
pwbuffer = u_num2str32(rnumber[0], wbuffer + U_CONSTANT_SIZE("Content-Length: 31\r\nContent-Type: application/json\r\n\r\n{\"id\":"));
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer+52), U_MULTICHAR_CONSTANT64('\r','\n','{','"','i','d','"',':'))
|
||||
}
|
||||
|
||||
static void endOneResult()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "World::endOneResult()")
|
||||
|
||||
*pwbuffer = '}';
|
||||
*ptr = '}';
|
||||
|
||||
uint32_t len = pwbuffer-wbuffer+1,
|
||||
uint32_t len = ptr-wbuffer+1,
|
||||
body_len = len - U_CONSTANT_SIZE("Content-Length: 31\r\nContent-Type: application/json\r\n\r\n");
|
||||
|
||||
(void) u_num2str32(body_len, wbuffer+U_CONSTANT_SIZE("Content-Length: "));
|
||||
U_NUM2STR16(wbuffer+U_CONSTANT_SIZE("Content-Length: "), body_len);
|
||||
|
||||
UClientImage_Base::wbuffer->setConstant(wbuffer, len);
|
||||
}
|
||||
|
||||
static void handlerOneResult(uint32_t uid, uint32_t random)
|
||||
static void handlerOneResult(uint32_t random)
|
||||
{
|
||||
U_TRACE(5, "World::handlerOneResult(%u,%u)", uid, random)
|
||||
U_TRACE(5, "World::handlerOneResult(%u)", random)
|
||||
|
||||
u_put_unalignedp32(pwbuffer, U_MULTICHAR_CONSTANT32('"','i','d','"'));
|
||||
initOneResult();
|
||||
|
||||
pwbuffer[4] = ':';
|
||||
ptr = u_num2str32(random, pwbuffer+16);
|
||||
|
||||
pwbuffer = u_num2str32(uid, pwbuffer+5);
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
|
||||
|
||||
pwbuffer = u_num2str32(random, pwbuffer+16);
|
||||
endOneResult();
|
||||
}
|
||||
|
||||
static void handlerResult(uint32_t uid, uint32_t random)
|
||||
static void initResult()
|
||||
{
|
||||
U_TRACE(5, "World::handlerResult(%u,%u)", uid, random)
|
||||
U_TRACE_NO_PARAM(5, "World::initResult()")
|
||||
|
||||
u_put_unalignedp32(pwbuffer, U_MULTICHAR_CONSTANT32('{','"','i','d'));
|
||||
u_put_unalignedp16(pwbuffer+4, U_MULTICHAR_CONSTANT16('"',':'));
|
||||
U_INTERNAL_DUMP("wbuffer = %#.10S", wbuffer)
|
||||
|
||||
pwbuffer = u_num2str32(uid, pwbuffer+6);
|
||||
if (*wbuffer == '\0')
|
||||
{
|
||||
u_put_unalignedp64(wbuffer, U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'));
|
||||
u_put_unalignedp64(wbuffer+8, U_MULTICHAR_CONSTANT64('L','e','n','g','t','h',':',' '));
|
||||
u_put_unalignedp64(wbuffer+16, U_MULTICHAR_CONSTANT64('1','3','3','3','1','\r','\n','C'));
|
||||
u_put_unalignedp64(wbuffer+24, U_MULTICHAR_CONSTANT64('o','n','t','e','n','t','-','T'));
|
||||
u_put_unalignedp64(wbuffer+32, U_MULTICHAR_CONSTANT64('y','p','e',':',' ','a','p','p'));
|
||||
u_put_unalignedp64(wbuffer+40, U_MULTICHAR_CONSTANT64('l','i','c','a','t','i','o','n'));
|
||||
u_put_unalignedp64(wbuffer+48, U_MULTICHAR_CONSTANT64('/','j','s','o','n','\r','\n','\r'));
|
||||
u_put_unalignedp64(wbuffer+56, U_MULTICHAR_CONSTANT64('\n','[','{','"','i','d','"',':'));
|
||||
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
|
||||
pwbuffer = u_num2str32(rnumber[0], wbuffer + U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n[{\"id\":"));
|
||||
|
||||
pwbuffer = u_num2str32(random, pwbuffer+16);
|
||||
u_put_unalignedp64(pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
|
||||
u_put_unalignedp64(pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
|
||||
}
|
||||
|
||||
u_put_unalignedp16(pwbuffer, U_MULTICHAR_CONSTANT16('}',','));
|
||||
pwbuffer += 2;
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer), U_MULTICHAR_CONSTANT64('C','o','n','t','e','n','t','-'))
|
||||
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(wbuffer+56), U_MULTICHAR_CONSTANT64('\n','[','{','"','i','d','"',':'))
|
||||
|
||||
ptr = pwbuffer;
|
||||
}
|
||||
|
||||
static void handlerResult(uint32_t i)
|
||||
static void endResult()
|
||||
{
|
||||
U_TRACE(5, "World::handlerResult(%u)", i)
|
||||
U_TRACE_NO_PARAM(5, "World::endResult()")
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(pworld_query)
|
||||
*(ptr-1) = ']';
|
||||
|
||||
U_INTERNAL_DUMP("pworld_query->randomNumber = %u", pworld_query->randomNumber)
|
||||
uint32_t len = ptr-wbuffer,
|
||||
body_len = len - U_CONSTANT_SIZE("Content-Length: 13331\r\nContent-Type: application/json\r\n\r\n");
|
||||
|
||||
ptr = u_num2str32(body_len, wbuffer + U_CONSTANT_SIZE("Content-Length: "));
|
||||
|
||||
while (*ptr != '\r') *ptr++ = ' ';
|
||||
|
||||
UClientImage_Base::wbuffer->setConstant(wbuffer, len);
|
||||
}
|
||||
|
||||
static void handlerResultSql(uint32_t i)
|
||||
static void addResult(uint32_t i)
|
||||
{
|
||||
U_TRACE(5, "World::handlerResultSql(%u)", i)
|
||||
U_TRACE(5, "World::addResult(%u)", i)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(pworld_query)
|
||||
U_INTERNAL_ASSERT_MAJOR(i, 0)
|
||||
|
||||
handlerResult(rnumber[i], pworld_query->randomNumber);
|
||||
u_put_unalignedp32(ptr, U_MULTICHAR_CONSTANT32('{','"','i','d'));
|
||||
u_put_unalignedp16(ptr+4, U_MULTICHAR_CONSTANT16('"',':'));
|
||||
|
||||
ptr = u_num2str32(rnumber[i], ptr+6);
|
||||
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
|
||||
u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
|
||||
}
|
||||
|
||||
static void addRandom(uint32_t random)
|
||||
{
|
||||
U_TRACE(5, "World::addRandom(%u)", random)
|
||||
|
||||
ptr = u_num2str32(random, ptr+16);
|
||||
|
||||
u_put_unalignedp16(ptr, U_MULTICHAR_CONSTANT16('}',','));
|
||||
ptr += 2;
|
||||
}
|
||||
|
||||
static void handlerResult(uint32_t i, uint32_t random)
|
||||
{
|
||||
U_TRACE(5, "World::handlerResult(%u,%u)", i, random)
|
||||
|
||||
if (i) addResult(i);
|
||||
|
||||
addRandom(random);
|
||||
}
|
||||
|
||||
static void doUpdateNoSql(vPFu handlerUpdateNoSql)
|
||||
|
@ -302,17 +324,31 @@ public:
|
|||
{
|
||||
handlerUpdateNoSql(i);
|
||||
|
||||
handlerResult(rnumber[i], rnum);
|
||||
handlerResult(i, rnum);
|
||||
}
|
||||
|
||||
endResult();
|
||||
}
|
||||
|
||||
static void handlerInitSql()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "World::handlerInitSql()")
|
||||
|
||||
# ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
U_INTERNAL_DUMP("UServer_Base::handler_db1 = %p", UServer_Base::handler_db1)
|
||||
|
||||
if (UServer_Base::handler_db1 == U_NULLPTR)
|
||||
{
|
||||
U_NEW_WITHOUT_CHECK_MEMORY(UEventDB, UServer_Base::handler_db1, UEventDB);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
static void handlerFork()
|
||||
{
|
||||
U_TRACE_NO_PARAM(5, "World::handlerFork()")
|
||||
|
||||
if (rnumber[0] == 0) for (uint32_t i = 0; i < 500; ++i) rnumber[i] = u_get_num_random_range1(10000);
|
||||
if (rnumber[0] == 0) for (uint32_t i = 0; i <= 500; ++i) rnumber[i] = u_get_num_random_range1(10000);
|
||||
}
|
||||
|
||||
static void handlerForkSql()
|
||||
|
@ -344,13 +380,15 @@ public:
|
|||
# ifdef U_STATIC_ORM_DRIVER_PGSQL
|
||||
if (UOrmDriver::isPGSQL())
|
||||
{
|
||||
conn = (PGconn*)(pdrv = (UOrmDriverPgSql*)psql_query->getDriver())->UOrmDriver::connection;
|
||||
conn = (PGconn*)(pdrv = (UOrmDriverPgSql*)psql_query->getDriver())->UOrmDriver::connection;
|
||||
pstmt = (UPgSqlStatement*)pstmt_query->getStatement();
|
||||
|
||||
(void) pstmt->setBindParam(pdrv);
|
||||
|
||||
pstmt->paramValues[0] = num2str;
|
||||
pstmt->paramLengths[0] = sizeof(unsigned int);
|
||||
|
||||
((UEventDB*)UServer_Base::handler_db1)->setConnection(conn);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
|
|
@ -12,74 +12,48 @@
|
|||
# include <ulib/net/client/mongodb.h>
|
||||
#endif
|
||||
|
||||
class WorldNoSql {
|
||||
class U_EXPORT WorldNoSql {
|
||||
public:
|
||||
|
||||
static UString* str_rnumber;
|
||||
|
||||
static void handlerOneResult(uint32_t uid)
|
||||
{
|
||||
U_TRACE(5, "WorldNoSql::handlerOneResult(%u)", uid)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(str_rnumber)
|
||||
U_INTERNAL_ASSERT_POINTER(World::pwbuffer)
|
||||
|
||||
u_put_unalignedp32(World::pwbuffer, U_MULTICHAR_CONSTANT32('"','i','d','"'));
|
||||
|
||||
World::pwbuffer[4] = ':';
|
||||
|
||||
World::pwbuffer = u_num2str32(uid, World::pwbuffer+5);
|
||||
|
||||
u_put_unalignedp64(World::pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
|
||||
u_put_unalignedp64(World::pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
|
||||
World::pwbuffer += 16;
|
||||
|
||||
uint32_t sz = str_rnumber->size();
|
||||
|
||||
(void) memcpy(World::pwbuffer, str_rnumber->data(), sz);
|
||||
World::pwbuffer += sz;
|
||||
|
||||
str_rnumber->clear();
|
||||
}
|
||||
|
||||
static void handlerResult(uint32_t uid)
|
||||
{
|
||||
U_TRACE(5, "WorldNoSql::handlerResult(%u)", uid)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(str_rnumber)
|
||||
U_INTERNAL_ASSERT_POINTER(World::pwbuffer)
|
||||
|
||||
u_put_unalignedp32(World::pwbuffer, U_MULTICHAR_CONSTANT32('{','"','i','d'));
|
||||
u_put_unalignedp16(World::pwbuffer+4, U_MULTICHAR_CONSTANT16('"',':'));
|
||||
|
||||
World::pwbuffer = u_num2str32(uid, World::pwbuffer+6);
|
||||
|
||||
u_put_unalignedp64(World::pwbuffer, U_MULTICHAR_CONSTANT64(',','"','r','a','n','d','o','m'));
|
||||
u_put_unalignedp64(World::pwbuffer+8, U_MULTICHAR_CONSTANT64('N','u','m','b','e','r','"',':'));
|
||||
World::pwbuffer += 16;
|
||||
|
||||
uint32_t sz = str_rnumber->size();
|
||||
|
||||
(void) memcpy(World::pwbuffer, str_rnumber->data(), sz);
|
||||
World::pwbuffer += sz;
|
||||
|
||||
str_rnumber->clear();
|
||||
|
||||
u_put_unalignedp16(World::pwbuffer, U_MULTICHAR_CONSTANT16('}',','));
|
||||
World::pwbuffer += 2;
|
||||
}
|
||||
|
||||
static void doOneQuery(vPFu handlerQuery)
|
||||
{
|
||||
U_TRACE(5, "WorldNoSql::doOneQuery(%p)", handlerQuery)
|
||||
|
||||
World::initOneResult();
|
||||
|
||||
handlerQuery(World::rnumber[0]);
|
||||
|
||||
handlerOneResult(World::rnumber[0]);
|
||||
uint32_t sz = str_rnumber->size();
|
||||
|
||||
World::initOneResult();
|
||||
|
||||
(void) memcpy(World::pwbuffer+16, str_rnumber->data(), sz);
|
||||
|
||||
World::ptr = World::pwbuffer+16+sz;
|
||||
|
||||
World::endOneResult();
|
||||
|
||||
str_rnumber->clear();
|
||||
}
|
||||
|
||||
static void handlerResult(uint32_t i)
|
||||
{
|
||||
U_TRACE(5, "WorldNoSql::handlerResult(%u)", i)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(str_rnumber)
|
||||
U_INTERNAL_ASSERT_POINTER(World::pwbuffer)
|
||||
|
||||
if (i) World::addResult(i);
|
||||
|
||||
uint32_t sz = str_rnumber->size();
|
||||
|
||||
(void) memcpy(World::ptr+16, str_rnumber->data(), sz);
|
||||
World::ptr += 16+ sz;
|
||||
|
||||
u_put_unalignedp16(World::ptr, U_MULTICHAR_CONSTANT16('}',','));
|
||||
World::ptr += 2;
|
||||
|
||||
str_rnumber->clear();
|
||||
}
|
||||
|
||||
static void doQuery(vPFu handlerQuery)
|
||||
|
@ -92,7 +66,7 @@ public:
|
|||
{
|
||||
handlerQuery(World::rnumber[i]);
|
||||
|
||||
handlerResult(World::rnumber[i]);
|
||||
handlerResult(i);
|
||||
}
|
||||
|
||||
World::endResult();
|
||||
|
|
|
@ -139,7 +139,8 @@ UString* UServer_Base::crashEmailAddress;
|
|||
USocket* UServer_Base::socket;
|
||||
USocket* UServer_Base::csocket;
|
||||
UProcess* UServer_Base::proc;
|
||||
UEventFd* UServer_Base::handler_other;
|
||||
UEventFd* UServer_Base::handler_db1;
|
||||
UEventFd* UServer_Base::handler_db2;
|
||||
UEventFd* UServer_Base::handler_inotify;
|
||||
UEventTime* UServer_Base::ptime;
|
||||
UUDPSocket* UServer_Base::udp_sock;
|
||||
|
@ -162,6 +163,7 @@ UVector<UString>* UServer_Base::vplugin_name_static;
|
|||
UClientImage_Base* UServer_Base::vClientImage;
|
||||
UClientImage_Base* UServer_Base::pClientImage;
|
||||
UClientImage_Base* UServer_Base::eClientImage;
|
||||
UVector<UEventFd*>* UServer_Base::handler_other;
|
||||
UVector<UServerPlugIn*>* UServer_Base::vplugin;
|
||||
UVector<UServerPlugIn*>* UServer_Base::vplugin_static;
|
||||
UVector<UServer_Base::file_LOG*>* UServer_Base::vlog;
|
||||
|
@ -230,7 +232,7 @@ public:
|
|||
|
||||
UTimeStat() : UEventTime(U_ONE_HOUR_IN_SECOND, 0L)
|
||||
{
|
||||
U_TRACE_CTOR(0, UTimeStat, "", 0)
|
||||
U_TRACE_CTOR(0, UTimeStat, "")
|
||||
}
|
||||
|
||||
virtual ~UTimeStat() U_DECL_FINAL
|
||||
|
@ -272,7 +274,7 @@ public:
|
|||
|
||||
UTimeoutConnection() : UEventTime(UServer_Base::timeoutMS / 1000L, 0L)
|
||||
{
|
||||
U_TRACE_CTOR(0, UTimeoutConnection, "", 0)
|
||||
U_TRACE_CTOR(0, UTimeoutConnection, "")
|
||||
}
|
||||
|
||||
virtual ~UTimeoutConnection() U_DECL_FINAL
|
||||
|
@ -361,7 +363,7 @@ public:
|
|||
|
||||
UBandWidthThrottling() : UEventTime(U_THROTTLE_TIME, 0L)
|
||||
{
|
||||
U_TRACE_CTOR(0, UBandWidthThrottling, "", 0)
|
||||
U_TRACE_CTOR(0, UBandWidthThrottling, "")
|
||||
}
|
||||
|
||||
virtual ~UBandWidthThrottling() U_DECL_FINAL
|
||||
|
@ -528,11 +530,14 @@ public:
|
|||
|
||||
U_INTERNAL_ASSERT_POINTER(cimg)
|
||||
|
||||
U_INTERNAL_DUMP("pthis = %p handler_other = %p handler_inotify = %p ", UServer_Base::pthis, UServer_Base::handler_other, UServer_Base::handler_inotify)
|
||||
U_INTERNAL_DUMP("pthis = %p handler_other = %p handler_inotify = %p handler_db1 = %p handler_db2 = %p",
|
||||
UServer_Base::pthis, UServer_Base::handler_other, UServer_Base::handler_inotify, UServer_Base::handler_db1, UServer_Base::handler_db2)
|
||||
|
||||
if (cimg == UServer_Base::pthis ||
|
||||
cimg == UServer_Base::handler_other ||
|
||||
cimg == UServer_Base::handler_inotify)
|
||||
if (cimg == UServer_Base::pthis ||
|
||||
cimg == UServer_Base::handler_db1 ||
|
||||
cimg == UServer_Base::handler_db2 ||
|
||||
cimg == UServer_Base::handler_inotify ||
|
||||
(UServer_Base::handler_other && UServer_Base::handler_other->isContained(cimg)))
|
||||
{
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
@ -1463,7 +1468,9 @@ public:
|
|||
UVector<UString> vec;
|
||||
UVector<UString> vmessage;
|
||||
UString row, _id, token, rID, message, tmp;
|
||||
uint32_t pos, mr, sz, last_event_id, i, n, k, start = 0, end = 0;
|
||||
uint32_t pos, mr, sz, last_event_id, i, n, k, start = 0, end = 0, mask = vmessage.capacity()-1;
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(mask & (mask+1), 0) // must be a power of 2
|
||||
|
||||
char buffer_input[ 64U * 1024U],
|
||||
buffer_output[64U * 1024U];
|
||||
|
@ -1522,7 +1529,7 @@ public:
|
|||
|
||||
pos = message.find('=');
|
||||
|
||||
U_INTERNAL_DUMP("vmessage[%u] = %V pos = %u", i % vmessage.capacity(), message.rep, pos)
|
||||
U_INTERNAL_DUMP("vmessage[%u] = %V pos = %u", i & mask, message.rep, pos)
|
||||
|
||||
if (ball ||
|
||||
token.equal(message.data(), pos))
|
||||
|
@ -1829,6 +1836,10 @@ UServer_Base::~UServer_Base()
|
|||
# endif
|
||||
#endif
|
||||
|
||||
if (handler_db1) delete handler_db1;
|
||||
if (handler_db2) delete handler_db2;
|
||||
if (handler_other) handler_other->clear();
|
||||
|
||||
UClientImage_Base::clear();
|
||||
|
||||
U_DELETE(socket)
|
||||
|
@ -2211,9 +2222,11 @@ void UServer_Base::loadConfigParam()
|
|||
USocket::iBackLog = cfg->readLong(U_CONSTANT_TO_PARAM("LISTEN_BACKLOG"), SOMAXCONN);
|
||||
min_size_for_sendfile = cfg->readLong(U_CONSTANT_TO_PARAM("MIN_SIZE_FOR_SENDFILE"), 500 * 1024); // 500k: for major size we assume is better to use sendfile()
|
||||
num_client_threshold = cfg->readLong(U_CONSTANT_TO_PARAM("CLIENT_THRESHOLD"));
|
||||
UNotifier::max_connection = cfg->readLong(U_CONSTANT_TO_PARAM("MAX_KEEP_ALIVE"));
|
||||
UNotifier::max_connection = cfg->readLong(U_CONSTANT_TO_PARAM("MAX_KEEP_ALIVE"), USocket::iBackLog);
|
||||
u_printf_string_max_length = cfg->readLong(U_CONSTANT_TO_PARAM("LOG_MSG_SIZE"));
|
||||
|
||||
U_INTERNAL_DUMP("UNotifier::max_connection = %u USocket::iBackLog = %u", UNotifier::max_connection, USocket::iBackLog)
|
||||
|
||||
#ifdef U_MAX_CONNECTIONS_ACCEPTED_SIMULTANEOUSLY
|
||||
max_accepted = USocket::iBackLog;
|
||||
#endif
|
||||
|
@ -3447,13 +3460,6 @@ next:
|
|||
socket_flags |= O_NONBLOCK;
|
||||
}
|
||||
|
||||
if (handler_other)
|
||||
{
|
||||
UNotifier::min_connection++;
|
||||
|
||||
handler_other->UEventFd::op_mask &= ~EPOLLRDHUP;
|
||||
}
|
||||
|
||||
if (handler_inotify)
|
||||
{
|
||||
UNotifier::min_connection++;
|
||||
|
@ -3462,13 +3468,16 @@ next:
|
|||
}
|
||||
}
|
||||
|
||||
UNotifier::max_connection = (UNotifier::max_connection ? UNotifier::max_connection : USocket::iBackLog) + (UNotifier::num_connection = UNotifier::min_connection);
|
||||
UNotifier::num_connection = UNotifier::min_connection;
|
||||
|
||||
if (num_client_threshold == 0) num_client_threshold = U_NOT_FOUND;
|
||||
}
|
||||
|
||||
U_INTERNAL_DUMP("UNotifier::max_connection = %u UNotifier::min_connection = %u num_client_threshold = %u",
|
||||
UNotifier::max_connection, UNotifier::min_connection, num_client_threshold)
|
||||
U_INTERNAL_DUMP("UNotifier::max_connection = %u USocket::iBackLog = %u", UNotifier::max_connection, USocket::iBackLog)
|
||||
|
||||
if (UNotifier::max_connection == 0) UNotifier::max_connection = USocket::iBackLog;
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(UNotifier::max_connection, 0)
|
||||
|
||||
pthis->preallocate();
|
||||
|
||||
|
@ -4332,11 +4341,14 @@ bool UServer_Base::handlerTimeoutConnection(void* cimg)
|
|||
U_INTERNAL_ASSERT_POINTER(ptime)
|
||||
U_INTERNAL_ASSERT_DIFFERS(timeoutMS, -1)
|
||||
|
||||
U_INTERNAL_DUMP("pthis = %p handler_other = %p handler_inotify = %p", pthis, handler_other, handler_inotify)
|
||||
U_INTERNAL_DUMP("pthis = %p handler_other = %p handler_inotify = %p handler_db1 = %p handler_db2 = %p",
|
||||
UServer_Base::pthis, UServer_Base::handler_other, UServer_Base::handler_inotify, UServer_Base::handler_db1, UServer_Base::handler_db2)
|
||||
|
||||
if (cimg == pthis ||
|
||||
cimg == handler_other ||
|
||||
cimg == handler_inotify)
|
||||
if (cimg == pthis ||
|
||||
cimg == UServer_Base::handler_db1 ||
|
||||
cimg == UServer_Base::handler_db2 ||
|
||||
cimg == UServer_Base::handler_inotify ||
|
||||
(UServer_Base::handler_other && UServer_Base::handler_other->isContained(cimg)))
|
||||
{
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
@ -4462,15 +4474,49 @@ void UServer_Base::runLoop(const char* user)
|
|||
if (budp == false)
|
||||
#endif
|
||||
{
|
||||
UNotifier::init();
|
||||
if (handler_db1)
|
||||
{
|
||||
UNotifier::min_connection++;
|
||||
|
||||
U_INTERNAL_DUMP("UNotifier::min_connection = %d", UNotifier::min_connection)
|
||||
handler_db1->UEventFd::op_mask &= ~EPOLLRDHUP;
|
||||
}
|
||||
|
||||
if (handler_db2)
|
||||
{
|
||||
UNotifier::min_connection++;
|
||||
|
||||
handler_db2->UEventFd::op_mask &= ~EPOLLRDHUP;
|
||||
}
|
||||
|
||||
if (handler_other)
|
||||
{
|
||||
uint32_t n = handler_other->size();
|
||||
|
||||
U_INTERNAL_DUMP("handler_other->size() = %u", n)
|
||||
|
||||
UNotifier::min_connection += n;
|
||||
|
||||
for (uint32_t i = 0; i < n; ++i) (*handler_other)[i]->UEventFd::op_mask &= ~EPOLLRDHUP;
|
||||
}
|
||||
|
||||
UNotifier::max_connection += (UNotifier::num_connection = UNotifier::min_connection);
|
||||
|
||||
U_INTERNAL_DUMP("UNotifier::max_connection = %u UNotifier::min_connection = %u num_client_threshold = %u",
|
||||
UNotifier::max_connection, UNotifier::min_connection, num_client_threshold)
|
||||
|
||||
UNotifier::init();
|
||||
|
||||
if (UNotifier::min_connection)
|
||||
{
|
||||
if (binsert) UNotifier::insert(pthis, EPOLLEXCLUSIVE | EPOLLROUNDROBIN); // NB: we ask to be notified for request of connection (=> accept)
|
||||
if (handler_other) UNotifier::insert(handler_other, EPOLLEXCLUSIVE | EPOLLROUNDROBIN); // NB: we ask to be notified for request from generic system
|
||||
if (handler_db1) UNotifier::insert(handler_db1, EPOLLEXCLUSIVE | EPOLLROUNDROBIN); // NB: we ask to be notified for response from db
|
||||
if (handler_db2) UNotifier::insert(handler_db2, EPOLLEXCLUSIVE | EPOLLROUNDROBIN); // NB: we ask to be notified for response from db
|
||||
if (handler_inotify) UNotifier::insert(handler_inotify, EPOLLEXCLUSIVE | EPOLLROUNDROBIN); // NB: we ask to be notified for change of file system (=> inotify)
|
||||
|
||||
if (handler_other) // NB: we ask to be notified for request from generic system
|
||||
{
|
||||
for (uint32_t i = 0, n = handler_other->size(); i < n; ++i) UNotifier::insert(handler_other->at(i), EPOLLEXCLUSIVE | EPOLLROUNDROBIN);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(ENABLE_THREAD) && !defined(USE_LIBEVENT) && defined(U_SERVER_THREAD_APPROACH_SUPPORT)
|
||||
|
@ -4541,8 +4587,8 @@ void UServer_Base::runLoop(const char* user)
|
|||
|
||||
UClientImage_Base::callerHandlerRead = UServer_Base::handlerUDP;
|
||||
|
||||
U_INTERNAL_DUMP("handler_other = %p handler_inotify = %p UNotifier::num_connection = %u UNotifier::min_connection = %u",
|
||||
handler_other, handler_inotify, UNotifier::num_connection, UNotifier::min_connection)
|
||||
U_INTERNAL_DUMP("handler_other = %p handler_inotify = %p handler_db1 = %p handler_db2 = %p UNotifier::num_connection = %u UNotifier::min_connection = %u",
|
||||
handler_other, handler_inotify, handler_db1, handler_db2, UNotifier::num_connection, UNotifier::min_connection)
|
||||
|
||||
// NB: we can go directly on recvFrom() and block on it...
|
||||
|
||||
|
@ -4574,8 +4620,8 @@ void UServer_Base::runLoop(const char* user)
|
|||
{
|
||||
while (flag_loop)
|
||||
{
|
||||
U_INTERNAL_DUMP("handler_other = %p handler_inotify = %p UNotifier::num_connection = %u UNotifier::min_connection = %u",
|
||||
handler_other, handler_inotify, UNotifier::num_connection, UNotifier::min_connection)
|
||||
U_INTERNAL_DUMP("handler_other = %p handler_inotify = %p handler_db1 = %p handler_db2 = %p UNotifier::num_connection = %u UNotifier::min_connection = %u",
|
||||
handler_other, handler_inotify, handler_db1, handler_db2, UNotifier::num_connection, UNotifier::min_connection)
|
||||
|
||||
# if defined(ENABLE_THREAD) && !defined(USE_LIBEVENT) && defined(U_SERVER_THREAD_APPROACH_SUPPORT)
|
||||
if (preforked_num_kids != -1)
|
||||
|
|
|
@ -56,6 +56,8 @@ void URDBServer::preallocate()
|
|||
{
|
||||
U_TRACE_NO_PARAM(0+256, "URDBServer::preallocate()")
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(UNotifier::max_connection, 0)
|
||||
|
||||
UServer_Base::vClientImage = new URDBClientImage[UNotifier::max_connection];
|
||||
}
|
||||
|
||||
|
|
|
@ -718,6 +718,8 @@ void UNotifier::createMapFd()
|
|||
lo_map_fd_len = 20+max_connection;
|
||||
lo_map_fd = (UEventFd**) UMemoryPool::_malloc(&lo_map_fd_len, sizeof(UEventFd*), true);
|
||||
|
||||
U_INTERNAL_DUMP("lo_map_fd_len = %u", lo_map_fd_len)
|
||||
|
||||
typedef UGenericHashMap<unsigned int,UEventFd*> umapfd;
|
||||
|
||||
U_NEW(umapfd, hi_map_fd, umapfd);
|
||||
|
@ -733,7 +735,7 @@ bool UNotifier::isHandler(int fd)
|
|||
|
||||
bool result = false;
|
||||
|
||||
U_INTERNAL_DUMP("num_connection = %d min_connection = %d", num_connection, min_connection)
|
||||
U_INTERNAL_DUMP("num_connection = %u min_connection = %u", num_connection, min_connection)
|
||||
|
||||
if (num_connection > min_connection)
|
||||
{
|
||||
|
@ -762,6 +764,8 @@ bool UNotifier::setHandler(int fd)
|
|||
U_INTERNAL_ASSERT_POINTER(lo_map_fd)
|
||||
U_INTERNAL_ASSERT_POINTER(hi_map_fd)
|
||||
|
||||
U_INTERNAL_DUMP("lo_map_fd_len = %u", lo_map_fd_len)
|
||||
|
||||
if (fd < (int32_t)lo_map_fd_len)
|
||||
{
|
||||
if (lo_map_fd[fd])
|
||||
|
@ -796,7 +800,7 @@ bool UNotifier::setHandler(int fd)
|
|||
|
||||
void UNotifier::insert(UEventFd* item, int op)
|
||||
{
|
||||
U_TRACE(0, "UNotifier::insert(%p%d)", item, op)
|
||||
U_TRACE(0, "UNotifier::insert(%p,%d)", item, op)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(item)
|
||||
|
||||
|
@ -806,6 +810,8 @@ void UNotifier::insert(UEventFd* item, int op)
|
|||
|
||||
U_INTERNAL_ASSERT_DIFFERS(fd, -1)
|
||||
|
||||
U_INTERNAL_DUMP("lo_map_fd_len = %u", lo_map_fd_len)
|
||||
|
||||
if (fd < (int32_t)lo_map_fd_len) lo_map_fd[fd] = item;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -127,7 +127,7 @@ UHTTP2::Connection::Connection() : itable(64, setIndexStaticTable)
|
|||
, dtable(64, setIndexStaticTable)
|
||||
#endif
|
||||
{
|
||||
U_TRACE_CTOR(0, Connection, "", 0)
|
||||
U_TRACE_CTOR(0, Connection, "")
|
||||
|
||||
reset();
|
||||
|
||||
|
|
|
@ -501,6 +501,8 @@ uint32_t USocketExt::writev(USocket* sk, struct iovec* iov, int iovcnt, uint32_t
|
|||
{
|
||||
U_TRACE(0, "USocketExt::writev(%p,%p,%d,%u,%d)", sk, iov, iovcnt, count, timeoutMS)
|
||||
|
||||
U_DUMP_IOVEC(iov,iovcnt)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(sk)
|
||||
U_INTERNAL_ASSERT_MAJOR(count, 0)
|
||||
U_INTERNAL_ASSERT(sk->isConnected())
|
||||
|
|
|
@ -7440,7 +7440,9 @@ void UHTTP::setDynamicResponse()
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
|
||||
U_ASSERT(checkForCompression(clength))
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
|
||||
if (compress(*ext, UClientImage_Base::wbuffer->substr(U_http_info.endHeader, clength))) clength = UClientImage_Base::body->size();
|
||||
|
@ -7479,11 +7481,6 @@ next:
|
|||
}
|
||||
else
|
||||
{
|
||||
# ifdef U_SERVER_CAPTIVE_PORTAL
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('/','p','l','a','i','n','\r','\n'));
|
||||
|
||||
ptr += U_CONSTANT_SIZE("/plain\r\n");
|
||||
# else
|
||||
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('/','p','l','a','i','n',';',' '));
|
||||
u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('c','h','a','r','s','e','t','='));
|
||||
u_put_unalignedp32(ptr+16, U_MULTICHAR_CONSTANT32('U','T','F','-'));
|
||||
|
@ -7491,7 +7488,6 @@ next:
|
|||
u_put_unalignedp16(ptr+21, U_MULTICHAR_CONSTANT16('\r','\n'));
|
||||
|
||||
ptr += U_CONSTANT_SIZE("/plain; charset=UTF-8\r\n");
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11841,7 +11837,7 @@ loop: while (u__isalpha(*++ptr1)) {}
|
|||
U_http_info.nResponseCode = HTTP_OK;
|
||||
|
||||
UClientImage_Base::body->clear();
|
||||
UClientImage_Base::wbuffer->size_adjust_constant(0U);
|
||||
UClientImage_Base::wbuffer->rep->setEmpty();
|
||||
|
||||
UClientImage_Base::setHeaderForResponse(6+29+2+12+2); // Date: Wed, 20 Jun 2012 11:43:17 GMT\r\nServer: ULib\r\n
|
||||
|
||||
|
@ -11864,7 +11860,7 @@ next: if (*ptr1 == '?')
|
|||
{
|
||||
U_INTERNAL_DUMP("U_http_usp_flag = %u UClientImage_Base::wbuffer(%u) = %V", U_http_usp_flag, UClientImage_Base::wbuffer->size(), UClientImage_Base::wbuffer->rep)
|
||||
|
||||
(void) UServer_Base::pClientImage->writeResponse();
|
||||
if (UClientImage_Base::isRequestNeedProcessing()) UServer_Base::pClientImage->writeResponseCompact();
|
||||
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD) UServer_Base::endNewChild(); // no return
|
||||
|
||||
|
|
|
@ -10,21 +10,24 @@ rm -f benchmark/FrameworkBenchmarks/benchmark.log* \
|
|||
trace.*userver_*.[0-9]* object.*userver_*.[0-9]* stack.*userver_*.[0-9]* mempool.*userver_*.[0-9]* \
|
||||
$DOC_ROOT/trace.*userver_*.[0-9]* $DOC_ROOT/object.*userver_*.[0-9]* $DOC_ROOT/stack.*userver_*.[0-9]* $DOC_ROOT/mempool.*userver_*.[0-9]*
|
||||
|
||||
#UTRACE="0 100M 0"
|
||||
#UTRACE="0 50M 0"
|
||||
UTRACE_SIGNAL="0 50M -1"
|
||||
UTRACE_FOLDER=/tmp
|
||||
TMPDIR=/tmp
|
||||
#UOBJDUMP="0 10M 100"
|
||||
#USIMERR="error.sim"
|
||||
#VALGRIND="valgrind -v --trace-children=yes"
|
||||
#UMEMUSAGE=yes
|
||||
export UTRACE UOBJDUMP USIMERR VALGRIND UMEMUSAGE
|
||||
#VALGRIND="valgrind -v --trace-children=yes"
|
||||
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL UMEMUSAGE VALGRIND UTRACE_FOLDER TMPDIR
|
||||
|
||||
unset ORM_DRIVER ORM_OPTION
|
||||
export ORM_DRIVER ORM_OPTION UMEMPOOL
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# PLAINTEXT
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
UMEMPOOL="58,0,0,41,16401,-14,-15,11,25"
|
||||
sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 16384|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
#UMEMPOOL="84,0,0,41,16401,-14,-15,11,25"
|
||||
#sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
#sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 16384|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#Running 15s test @ http://localhost:8080/plaintext
|
||||
# 4 threads and 256 connections
|
||||
|
@ -42,9 +45,9 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
|
|||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
# JSON
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#UMEMPOOL="58,0,0,41,16401,-14,-15,11,25"
|
||||
#sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
#sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
UMEMPOOL="237,0,0,49,273,-15,-14,-20,36"
|
||||
sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
#Running 15s test @ http://localhost:8080/json
|
||||
# 4 threads and 256 connections
|
||||
|
|
|
@ -1 +1 @@
|
|||
0213
|
||||
0230
|
||||
|
|
|
@ -3,7 +3,7 @@ userver {
|
|||
PORT 8080
|
||||
PREFORK_CHILD 4
|
||||
TCP_LINGER_SET 0
|
||||
LISTEN_BACKLOG 16384
|
||||
LISTEN_BACKLOG 256
|
||||
DOCUMENT_ROOT benchmark/FrameworkBenchmarks/ULib/www
|
||||
PID_FILE ../userver_tcp.pid
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,7 @@ start_msg server_rpc
|
|||
rm -rf err/server_rpc.err \
|
||||
trace.*server*.[0-9]* object.*server*.[0-9]* stack.*server*.[0-9]*
|
||||
|
||||
#UTRACE="0 50M 0"
|
||||
#UTRACE="0 50M -1"
|
||||
#UTRACE_SIGNAL="0 10M 0"
|
||||
#UOBJDUMP="0 10M 100"
|
||||
#USIMERR="error.sim"
|
||||
|
|
Loading…
Reference in New Issue
Block a user