mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
some fix + UMongoDBClient find extension
This commit is contained in:
parent
be68eeb09c
commit
4c2a92c11b
|
@ -152,11 +152,11 @@ public:
|
|||
{
|
||||
U_TRACE(0, "UCommand::getArgument(%d)", n)
|
||||
|
||||
char* result = (argv_exec ? argv_exec[n] : 0);
|
||||
char* arg = (argv_exec ? argv_exec[n] : 0);
|
||||
|
||||
U_INTERNAL_ASSERT(result == 0 || u_isText((const unsigned char*)result, u__strlen(result, __PRETTY_FUNCTION__)))
|
||||
U_INTERNAL_ASSERT(arg == 0 || u_isText((const unsigned char*)arg, u__strlen(arg, __PRETTY_FUNCTION__)))
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(arg);
|
||||
}
|
||||
|
||||
void setNumArgument(int32_t n = 1, bool bfree = false);
|
||||
|
@ -217,9 +217,9 @@ public:
|
|||
|
||||
U_INTERNAL_ASSERT(command)
|
||||
|
||||
bool result = (strncmp(command.data(), U_CONSTANT_TO_PARAM(U_PATH_SHELL)) == 0);
|
||||
if (strncmp(command.data(), U_CONSTANT_TO_PARAM(U_PATH_SHELL)) == 0) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
char* getCommand() const __pure { return getArgument(isShellScript() ? 2 : 0); }
|
||||
|
@ -252,9 +252,9 @@ public:
|
|||
|
||||
U_INTERNAL_ASSERT_POINTER(argv_exec)
|
||||
|
||||
bool result = (U_SYSCALL(access, "%S,%d", argv_exec[0], mode) == 0);
|
||||
if (U_SYSCALL(access, "%S,%d", argv_exec[0], mode) == 0) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// MANAGE MESSAGE ERROR
|
||||
|
@ -263,18 +263,18 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UCommand::isStarted()")
|
||||
|
||||
bool result = (pid > 0);
|
||||
if (pid > 0) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
static bool isTimeout()
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UCommand::isTimeout()")
|
||||
|
||||
bool result = (exit_value == -EAGAIN);
|
||||
if (exit_value == -EAGAIN) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
static void printMsgError()
|
||||
|
|
|
@ -851,6 +851,11 @@ public:
|
|||
UHashMap<UStringRep*>::insertAfterFind(_key, str.rep);
|
||||
}
|
||||
|
||||
// OPERATOR
|
||||
|
||||
bool operator==(const UHashMap<UString>& v) __pure;
|
||||
bool operator!=(const UHashMap<UString>& v) { return ! operator==(v); }
|
||||
|
||||
// OPERATOR []
|
||||
|
||||
UString operator[](const char* _key);
|
||||
|
|
|
@ -53,9 +53,9 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UPlugIn<void*>::empty()")
|
||||
|
||||
bool result = (first == 0);
|
||||
if (first == 0) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
static UPlugIn<void*>* getObjWrapper(void* obj) __pure;
|
||||
|
|
|
@ -530,8 +530,10 @@ public:
|
|||
static int jread_error;
|
||||
static uint32_t jread_elements, jread_pos;
|
||||
|
||||
static bool jfind(const UString& json, const UString& query, UString& result);
|
||||
static int jread(const UString& json, const UString& query, UString& result, uint32_t* queryParams = 0);
|
||||
static int jread(const UString& json, const UString& query, UString& result, uint32_t* queryParams = 0);
|
||||
static bool jfind(const UString& json, const char* query, uint32_t quey_len, UString& result);
|
||||
|
||||
static bool jfind(const UString& json, const UString& query, UString& result) { return jfind(json, U_STRING_TO_PARAM(query), result); }
|
||||
|
||||
// reads one value from an array
|
||||
|
||||
|
|
|
@ -82,9 +82,9 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UMimeEntity::isEmpty()")
|
||||
|
||||
bool result = content.empty();
|
||||
if (content.empty()) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
void clear()
|
||||
|
@ -189,21 +189,27 @@ public:
|
|||
|
||||
UString value = getContentDisposition();
|
||||
|
||||
bool result = (value.empty() == false &&
|
||||
U_STRING_FIND(value, 0, "attachment") != U_NOT_FOUND);
|
||||
if (value.empty() == false &&
|
||||
U_STRING_FIND(value, 0, "attachment") != U_NOT_FOUND)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool isBodyMessage() const
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "UMimeEntity::isBodyMessage()")
|
||||
|
||||
bool result = (isText() &&
|
||||
UMimeHeader::getValueAttributeFromKeyValue(content_type, U_CONSTANT_TO_PARAM("name"), false).empty() &&
|
||||
isAttachment() == false);
|
||||
if (isText() &&
|
||||
UMimeHeader::getValueAttributeFromKeyValue(content_type, U_CONSTANT_TO_PARAM("name"), false).empty() &&
|
||||
isAttachment() == false)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
UString getFileName() const { return UMimeHeader::getFileName(getContentDisposition()); }
|
||||
|
@ -312,9 +318,9 @@ public:
|
|||
|
||||
// DEBUG
|
||||
|
||||
# ifdef DEBUG
|
||||
# ifdef DEBUG
|
||||
const char* dump(bool reset) const;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -391,9 +397,9 @@ public:
|
|||
|
||||
// DEBUG
|
||||
|
||||
# ifdef DEBUG
|
||||
# ifdef DEBUG
|
||||
const char* dump(bool reset) const;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -414,9 +420,13 @@ protected:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UMimeMultipart::isEmpty()")
|
||||
|
||||
bool result = (UMimeEntity::isEmpty() && getNumBodyPart() == 0);
|
||||
if (UMimeEntity::isEmpty() &&
|
||||
getNumBodyPart() == 0)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
void setEmpty()
|
||||
|
|
|
@ -189,9 +189,10 @@ public:
|
|||
|
||||
U_ASSERT(empty() == false)
|
||||
|
||||
bool result = getHeader(U_CONSTANT_TO_PARAM("Connection")).equal(U_CONSTANT_TO_PARAM("close"));
|
||||
if (getHeader(U_CONSTANT_TO_PARAM("Connection")).equal(U_CONSTANT_TO_PARAM("close")))
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(true);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// Transfer-Encoding: chunked
|
||||
|
@ -202,9 +203,9 @@ public:
|
|||
|
||||
U_ASSERT(empty() == false)
|
||||
|
||||
bool result = (getHeader(U_CONSTANT_TO_PARAM("Transfer-Encoding")) == *UString::str_chunked);
|
||||
if (getHeader(U_CONSTANT_TO_PARAM("Transfer-Encoding")) == *UString::str_chunked) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// Cookie
|
||||
|
@ -228,9 +229,9 @@ public:
|
|||
|
||||
U_ASSERT(empty() == false)
|
||||
|
||||
bool result = containsHeader(U_CONSTANT_TO_PARAM("Set-Cookie"));
|
||||
if (containsHeader(U_CONSTANT_TO_PARAM("Set-Cookie"))) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// Location
|
||||
|
@ -276,10 +277,13 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UMimeHeader::isMime()")
|
||||
|
||||
bool result = ((table.empty() == false) &&
|
||||
(getMimeVersion().empty() == false));
|
||||
if (table.empty() == false &&
|
||||
getMimeVersion().empty() == false)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -311,10 +315,11 @@ public:
|
|||
|
||||
if (content_type)
|
||||
{
|
||||
bool result = (ignore_case ? u__strncasecmp(content_type.data(), type, len)
|
||||
: strncmp(content_type.data(), type, len)) == 0;
|
||||
|
||||
U_RETURN(result);
|
||||
if ((ignore_case ? u__strncasecmp(content_type.data(), type, len)
|
||||
: strncmp(content_type.data(), type, len)) == 0)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
}
|
||||
|
||||
U_RETURN(false);
|
||||
|
|
|
@ -129,9 +129,7 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UClient_Base::reset()")
|
||||
|
||||
# ifdef DEBUG
|
||||
uri.clear(); // NB: to avoid DEAD OF SOURCE STRING WITH CHILD ALIVE... (uri can be a substr of url)
|
||||
# endif
|
||||
url.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -101,9 +101,9 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UHttpClient_Base::isPasswordAuthentication()")
|
||||
|
||||
bool result = (user && password);
|
||||
if (user && password) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
void setRequestPasswordAuthentication(const UString& _user, const UString& _password)
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
|
||||
BSON_APPEND_INT32(query, "_id", value);
|
||||
|
||||
bool result = find(query);
|
||||
bool result = find(query, 0);
|
||||
|
||||
U_SYSCALL_VOID(bson_destroy, "%p", query);
|
||||
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
|
||||
bson_t* query = (bson_t*) U_SYSCALL_NO_PARAM(bson_new);
|
||||
|
||||
bool result = find(query);
|
||||
bool result = find(query, 0);
|
||||
|
||||
U_SYSCALL_VOID(bson_destroy, "%p", query);
|
||||
|
||||
|
@ -122,6 +122,8 @@ public:
|
|||
|
||||
bool findOne(const char* json, uint32_t len);
|
||||
|
||||
bool find(bson_t* query, bson_t* projection);
|
||||
|
||||
bool update(bson_t* query, bson_t* update);
|
||||
bool findAndModify(bson_t* query, bson_t* update);
|
||||
|
||||
|
@ -143,8 +145,6 @@ protected:
|
|||
mongoc_client_t* client;
|
||||
mongoc_cursor_t* cursor;
|
||||
mongoc_collection_t* collection;
|
||||
|
||||
bool find(bson_t* query);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -125,9 +125,13 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UIPAllow::isEmpty()")
|
||||
|
||||
bool result = (device.empty() || host.empty());
|
||||
if (device.empty() ||
|
||||
host.empty())
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
static bool getNetworkInterface(UVector<UIPAllow*>& vipallow);
|
||||
|
@ -292,11 +296,14 @@ public:
|
|||
{
|
||||
U_TRACE(0, "UIPAddress::operator==(%p)", &cOtherAddr)
|
||||
|
||||
bool result = (iAddressType == cOtherAddr.iAddressType) &&
|
||||
(iAddressLength == cOtherAddr.iAddressLength) &&
|
||||
(memcmp(pcAddress.p, cOtherAddr.pcAddress.p, iAddressLength) == 0);
|
||||
if (iAddressType == cOtherAddr.iAddressType &&
|
||||
iAddressLength == cOtherAddr.iAddressLength &&
|
||||
(memcmp(pcAddress.p, cOtherAddr.pcAddress.p, iAddressLength) == 0))
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool operator!=(const UIPAddress& cOtherAddr) const { return !operator==(cOtherAddr); }
|
||||
|
|
|
@ -107,19 +107,26 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UTimeVal::isZero()")
|
||||
|
||||
bool result = (tv_sec == 0L &&
|
||||
tv_usec <= 1L);
|
||||
if (tv_sec == 0L &&
|
||||
tv_usec <= 1L)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool isNegativ() const
|
||||
{
|
||||
U_TRACE_NO_PARAM(0,"UTimeVal::isNegativ()")
|
||||
|
||||
bool result = (tv_sec < 0L || tv_usec < 0L);
|
||||
if (tv_sec < 0L ||
|
||||
tv_usec < 0L)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool notZero() const { return (isZero() == false); }
|
||||
|
@ -155,9 +162,9 @@ public:
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
long result = tv_sec + (tv_usec >= 500000L ? 1L : 0L);
|
||||
long sec = tv_sec + (tv_usec >= 500000L ? 1L : 0L);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(sec);
|
||||
}
|
||||
|
||||
long getMilliSecond() const
|
||||
|
@ -204,9 +211,13 @@ public:
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
bool result = (tv_sec == t.tv_sec && tv_usec == t.tv_usec);
|
||||
if (tv_sec == t.tv_sec &&
|
||||
tv_usec == t.tv_usec)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool operator==(const UTimeVal& t) const
|
||||
|
@ -215,9 +226,13 @@ public:
|
|||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
bool result = (tv_sec == t.tv_sec && tv_usec == t.tv_usec);
|
||||
if (tv_sec == t.tv_sec &&
|
||||
tv_usec == t.tv_usec)
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool operator< (const UTimeVal& t) const __pure;
|
||||
|
@ -343,10 +358,14 @@ public:
|
|||
|
||||
U_INTERNAL_ASSERT_RANGE(0L, tv_usec, U_SECOND)
|
||||
|
||||
bool result = (tv_sec > t->tv_sec ||
|
||||
(tv_sec == t->tv_sec && ((tv_usec * 1000L) > t->tv_nsec)));
|
||||
if ( tv_sec > t->tv_sec ||
|
||||
(tv_sec == t->tv_sec &&
|
||||
((tv_usec * 1000L) > t->tv_nsec)))
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// SERVICES
|
||||
|
|
|
@ -60,9 +60,9 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UTokenizer::atEnd()")
|
||||
|
||||
bool result = (s >= end);
|
||||
if (s >= end) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
void setDelimiter(const char* sep)
|
||||
|
|
|
@ -148,13 +148,13 @@ public:
|
|||
void set(const Url& u)
|
||||
{
|
||||
service_end = u.service_end;
|
||||
user_begin = u.user_begin;
|
||||
user_end = u.user_end;
|
||||
host_begin = u.host_begin;
|
||||
host_end = u.host_end;
|
||||
path_begin = u.path_begin;
|
||||
path_end = u.path_end;
|
||||
query = u.query;
|
||||
user_begin = u.user_begin;
|
||||
user_end = u.user_end;
|
||||
host_begin = u.host_begin;
|
||||
host_end = u.host_end;
|
||||
path_begin = u.path_begin;
|
||||
path_end = u.path_end;
|
||||
query = u.query;
|
||||
}
|
||||
|
||||
Url(const Url& u) : url(u.url)
|
||||
|
@ -198,7 +198,14 @@ public:
|
|||
|
||||
url.clear();
|
||||
|
||||
service_end = user_begin = user_end = host_begin = host_end = path_begin = path_end = query = -1;
|
||||
service_end =
|
||||
user_begin =
|
||||
user_end =
|
||||
host_begin =
|
||||
host_end =
|
||||
path_begin =
|
||||
path_end =
|
||||
query = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,36 +223,45 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "Url::isHTTP()")
|
||||
|
||||
bool result = (getService() == *UString::str_http);
|
||||
if (service_end == 4 &&
|
||||
UString::str_http->equal(url.data(), (uint32_t)service_end))
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool isHTTPS() const
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "Url::isHTTPS()")
|
||||
|
||||
bool result = getService().equal(U_CONSTANT_TO_PARAM("https"));
|
||||
if (service_end == 5 &&
|
||||
url.c_char(4) == 's' &&
|
||||
UString::str_http->equal(url.data(), 4))
|
||||
{
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool isLDAP() const
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "Url::isLDAP()")
|
||||
|
||||
bool result = getService().equal(U_CONSTANT_TO_PARAM("ldap"));
|
||||
if (getService().equal(U_CONSTANT_TO_PARAM("ldap"))) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool isLDAPS() const
|
||||
{
|
||||
U_TRACE_NO_PARAM(0, "Url::isLDAPS()")
|
||||
|
||||
bool result = getService().equal(U_CONSTANT_TO_PARAM("ldaps"));
|
||||
if (getService().equal(U_CONSTANT_TO_PARAM("ldaps"))) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,9 +320,11 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "Url::isLocalFile()")
|
||||
|
||||
bool result = (host_begin < host_end ? true : false); // Is there a host ?
|
||||
// Is there a host ?
|
||||
|
||||
U_RETURN(result);
|
||||
if (host_begin < host_end) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,9 +382,9 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "Url::isPath()")
|
||||
|
||||
bool result = (path_begin < path_end);
|
||||
if (path_begin < path_end) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -412,9 +430,9 @@ public:
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "Url::isQuery()")
|
||||
|
||||
bool result = (path_end < (int)(url.size() - 1));
|
||||
if (path_end < (int)(url.size() - 1)) U_RETURN(true);
|
||||
|
||||
U_RETURN(result);
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -542,6 +542,48 @@ UString UHashMap<UString>::erase(const UString& _key)
|
|||
return UString::getStringNull();
|
||||
}
|
||||
|
||||
__pure bool UHashMap<UString>::operator==(const UHashMap<UString>& t)
|
||||
{
|
||||
U_TRACE(0, "UHashMap<UString>::operator==(%p)", &t)
|
||||
|
||||
U_CHECK_MEMORY
|
||||
|
||||
if (_length == t._length)
|
||||
{
|
||||
U_INTERNAL_DUMP("_length = %u", _length)
|
||||
|
||||
UHashMapNode* _node;
|
||||
UHashMapNode* _next;
|
||||
UHashMapNode** ptr;
|
||||
UHashMapNode** end;
|
||||
|
||||
for (end = (ptr = t.table) + t._capacity; ptr < end; ++ptr)
|
||||
{
|
||||
if (*ptr)
|
||||
{
|
||||
_node = *ptr;
|
||||
|
||||
do {
|
||||
_next = _node->next;
|
||||
|
||||
UHashMap<void*>::lookup((UStringRep*)_node->key);
|
||||
|
||||
if (node == 0 ||
|
||||
((UStringRep*)_node->elem)->equal(elem()) == false)
|
||||
{
|
||||
U_RETURN(false);
|
||||
}
|
||||
}
|
||||
while ((_node = _next));
|
||||
}
|
||||
}
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
||||
// OPERATOR []
|
||||
|
||||
UString UHashMap<UString>::at(const UStringRep* _key)
|
||||
|
|
|
@ -2011,19 +2011,19 @@ end:
|
|||
U_RETURN(jTok);
|
||||
}
|
||||
|
||||
bool UValue::jfind(const UString& json, const UString& query, UString& result)
|
||||
bool UValue::jfind(const UString& json, const char* query, uint32_t query_len, UString& result)
|
||||
{
|
||||
U_TRACE(0, "UValue::jfind(%V,%V,%p)", json.rep, query.rep, &result)
|
||||
U_TRACE(0, "UValue::jfind(%V,%.*S,%u,%p)", json.rep, query_len, query, query_len, &result)
|
||||
|
||||
U_ASSERT(result.empty())
|
||||
|
||||
uint32_t pos = json.find(query);
|
||||
uint32_t pos = json.find(query, query_len);
|
||||
|
||||
U_INTERNAL_DUMP("pos = %d", pos)
|
||||
|
||||
if (pos != U_NOT_FOUND)
|
||||
{
|
||||
pos += query.size();
|
||||
pos += query_len;
|
||||
|
||||
if (u__isquote(json.c_char(pos))) ++pos;
|
||||
|
||||
|
@ -2046,7 +2046,17 @@ bool UValue::jfind(const UString& json, const UString& query, UString& result)
|
|||
|
||||
if (jread_skip(tok) != -1)
|
||||
{
|
||||
(void) result.assign(start, tok.getPointer()-start);
|
||||
const char* end = tok.getPointer();
|
||||
|
||||
if (u__isquote(*start))
|
||||
{
|
||||
++start;
|
||||
--end;
|
||||
|
||||
U_INTERNAL_ASSERT(u__isquote(*end))
|
||||
}
|
||||
|
||||
(void) result.assign(start, end-start);
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
|
|
@ -357,43 +357,47 @@ bool UClient_Base::setUrl(const char* str, uint32_t len)
|
|||
U_INTERNAL_ASSERT_POINTER(str)
|
||||
U_INTERNAL_ASSERT_MAJOR(len, 0)
|
||||
|
||||
// check we've been passed a absolute URL
|
||||
// we check we've been passed a absolute URL
|
||||
|
||||
if (u_isUrlScheme(str, len) == 0)
|
||||
{
|
||||
char* p;
|
||||
char* ptr;
|
||||
char* dest;
|
||||
uint32_t sz;
|
||||
char buf[U_PATH_MAX];
|
||||
|
||||
const char* src = uri.data();
|
||||
const char* _end = src + uri.size();
|
||||
|
||||
U_INTERNAL_DUMP("uri = %V", uri.rep)
|
||||
|
||||
ptr = dest = buf;
|
||||
|
||||
while (src < _end)
|
||||
if (uri.empty()) (void) uri.replace(str, len);
|
||||
else
|
||||
{
|
||||
p = (char*) memchr(src, '/', _end - src);
|
||||
char* p;
|
||||
char* ptr;
|
||||
char* dest;
|
||||
uint32_t sz;
|
||||
char buf[U_PATH_MAX];
|
||||
|
||||
if (p == 0) break;
|
||||
const char* src = uri.data();
|
||||
const char* _end = src + uri.size();
|
||||
|
||||
sz = p - src + 1;
|
||||
ptr = dest = buf;
|
||||
|
||||
U_INTERNAL_DUMP("segment = %.*S", sz, src)
|
||||
while (src < _end)
|
||||
{
|
||||
p = (char*) memchr(src, '/', _end - src);
|
||||
|
||||
U_MEMCPY(dest, src, sz);
|
||||
if (p == 0) break;
|
||||
|
||||
src = p + 1;
|
||||
dest += sz;
|
||||
sz = p - src + 1;
|
||||
|
||||
U_INTERNAL_DUMP("segment = %.*S", sz, src)
|
||||
|
||||
U_MEMCPY(dest, src, sz);
|
||||
|
||||
src = p + 1;
|
||||
dest += sz;
|
||||
}
|
||||
|
||||
U_MEMCPY(dest, str, len);
|
||||
|
||||
(void) uri.replace(buf, dest - ptr + len);
|
||||
}
|
||||
|
||||
U_MEMCPY(dest, str, len);
|
||||
|
||||
(void) uri.replace(buf, dest - ptr + len);
|
||||
|
||||
U_INTERNAL_DUMP("uri = %V", uri.rep)
|
||||
|
||||
U_RETURN(false);
|
||||
|
|
|
@ -953,9 +953,16 @@ bool UHttpClient_Base::sendRequest(int method, const char* content_type, uint32_
|
|||
|
||||
// send post request to server and get response
|
||||
|
||||
if (sendRequest()) U_RETURN(true);
|
||||
bool ok = sendRequest();
|
||||
|
||||
U_RETURN(false);
|
||||
// reset reference to request...
|
||||
|
||||
UClient_Base::reset();
|
||||
|
||||
requestHeader->clear();
|
||||
responseHeader->clear();
|
||||
|
||||
U_RETURN(ok);
|
||||
}
|
||||
|
||||
bool UHttpClient_Base::sendPost(const UString& _url, const UString& _body, const char* content_type, uint32_t content_type_len)
|
||||
|
|
|
@ -78,14 +78,27 @@ bool UMongoDBClient::insert(bson_t* doc)
|
|||
U_RETURN(false);
|
||||
}
|
||||
|
||||
bool UMongoDBClient::find(bson_t* query)
|
||||
bool UMongoDBClient::find(bson_t* query, bson_t* projection)
|
||||
{
|
||||
U_TRACE(0, "UMongoDBClient::find(%p)", query)
|
||||
U_TRACE(0, "UMongoDBClient::find(%p,%p)", query, projection)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(client)
|
||||
U_INTERNAL_ASSERT_POINTER(collection)
|
||||
|
||||
cursor = (mongoc_cursor_t*) U_SYSCALL(mongoc_collection_find, "%p,%d,%u,%u,%u,%p,%p,%p", collection, MONGOC_QUERY_NONE, 0, 0, 0, query, 0, 0);
|
||||
/**
|
||||
* Parameters
|
||||
*
|
||||
* collection A mongoc_collection_t
|
||||
* flags A mongoc_query_flags_t
|
||||
* skip A uint32_t of number of documents to skip or 0
|
||||
* limit A uint32_t of max number of documents to return or 0
|
||||
* batch_size A uint32_t containing batch size of document result sets or 0 for default. Default is 100
|
||||
* query A bson_t containing the query and options to execute
|
||||
* fields A bson_t containing fields to return or NULL
|
||||
* read_prefs A mongoc_read_prefs_t or NULL for default read preferences
|
||||
*/
|
||||
|
||||
cursor = (mongoc_cursor_t*) U_SYSCALL(mongoc_collection_find, "%p,%d,%u,%u,%u,%p,%p,%p", collection, MONGOC_QUERY_NONE, 0, 0, 0, query, projection, 0);
|
||||
|
||||
if (cursor)
|
||||
{
|
||||
|
@ -143,7 +156,7 @@ bool UMongoDBClient::findOne(const char* json, uint32_t len)
|
|||
}
|
||||
else
|
||||
{
|
||||
bool result = find(bson);
|
||||
bool result = find(bson, 0);
|
||||
|
||||
U_SYSCALL_VOID(bson_destroy, "%p", bson);
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static World* pworld;
|
||||
static UString* jquery;
|
||||
static char buffer[128];
|
||||
static UElasticSearchClient* es;
|
||||
|
||||
|
@ -29,14 +27,11 @@ static void usp_fork_edb()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld, World);
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("randomNumber"));
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -46,15 +41,9 @@ static void usp_end_edb()
|
|||
|
||||
delete es;
|
||||
|
||||
if (pworld)
|
||||
{
|
||||
delete jquery;
|
||||
delete pworld;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue) delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -62,18 +51,18 @@ static void usp_end_edb()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString result;
|
||||
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", pworld->id = u_get_num_random(10000-1)));
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, u__snprintf(buffer+QLEN, 128, "%u\"}}}", id = u_get_num_random(10000-1))+QLEN);
|
||||
|
||||
(void) UValue::jfind(es->getContent(), *jquery, result);
|
||||
|
||||
pworld->randomNumber = u_strtoul(result.data(), result.end());
|
||||
(void) UValue::jfind(es->getContent(), U_CONSTANT_TO_PARAM("randomNumber"), result);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", pworld->id, result.rep);
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, result.rep);
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, World, *pworld);
|
||||
World world(id, u_strtoul(result.data(), result.end()));
|
||||
USP_JSON_stringify(*pvalue, World, world);
|
||||
pvalue->clear();
|
||||
#endif
|
||||
-->
|
||||
|
|
|
@ -5,9 +5,7 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static UString* jquery;
|
||||
static char buffer[128];
|
||||
static World* pworld_query;
|
||||
static UElasticSearchClient* es;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
|
@ -30,15 +28,12 @@ static void usp_fork_equery()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld_query, World);
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("randomNumber"));
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -48,16 +43,13 @@ static void usp_end_equery()
|
|||
|
||||
delete es;
|
||||
|
||||
if (jquery)
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete jquery;
|
||||
delete pworld_query;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_query;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -65,6 +57,7 @@ static void usp_end_equery()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString rnumber;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
@ -74,18 +67,18 @@ USP_PUTS_CHAR('[');
|
|||
|
||||
while (true)
|
||||
{
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", pworld_query->id = u_get_num_random(10000-1)));
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", id = u_get_num_random(10000-1)));
|
||||
|
||||
(void) UValue::jfind(es->getContent(), *jquery, rnumber);
|
||||
rnumber.clear();
|
||||
|
||||
(void) UValue::jfind(es->getContent(), U_CONSTANT_TO_PARAM("randomNumber"), rnumber);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", pworld_query->id, rnumber.rep);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", id, rnumber.rep);
|
||||
#else
|
||||
pworld_query->randomNumber = u_strtoul(rnumber.data(), rnumber.end());
|
||||
|
||||
World* pworld;
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_query));
|
||||
U_NEW(World, pworld, World(id, u_strtoul(rnumber.data(), rnumber.end())));
|
||||
|
||||
pvworld_query->push_back(pworld);
|
||||
#endif
|
||||
|
|
|
@ -5,9 +5,10 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static char* pbuffer1;
|
||||
static char* pbuffer2;
|
||||
static char buffer1[128];
|
||||
static char buffer2[128];
|
||||
static World* pworld_update;
|
||||
static UElasticSearchClient* es;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
|
@ -31,15 +32,18 @@ static void usp_fork_eupdate()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld_update, World);
|
||||
u__memcpy(buffer1, "/tfb/world/", ULEN, __PRETTY_FUNCTION__);
|
||||
|
||||
pbuffer1 = buffer1 + ULEN;
|
||||
|
||||
u__memcpy(buffer2, "{\"doc\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
|
||||
pbuffer2 = buffer2 + QLEN;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer1, "/tfb/world/", ULEN, __PRETTY_FUNCTION__);
|
||||
u__memcpy(buffer2, "{\"doc\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -49,15 +53,13 @@ static void usp_end_eupdate()
|
|||
|
||||
delete es;
|
||||
|
||||
if (pworld_update)
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete pworld_update;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_update;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -65,7 +67,7 @@ static void usp_end_eupdate()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
World* pworld;
|
||||
uint32_t len1, len2, id, rnum;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
|
@ -74,14 +76,17 @@ USP_PUTS_CHAR('[');
|
|||
|
||||
while (true)
|
||||
{
|
||||
(void) es->sendPOST(buffer1, ULEN+u__snprintf(buffer1+ULEN, 128, "%u/_update", pworld_update->id = u_get_num_random(10000-1)),
|
||||
buffer2, QLEN+u__snprintf(buffer2+QLEN, 128, "%u\"}}", pworld_update->randomNumber = u_get_num_random(10000-1)));
|
||||
len1 = u__snprintf(pbuffer1, 100, "%u/_update", id = u_get_num_random(10000-1));
|
||||
len2 = u__snprintf(pbuffer2, 100, "%u\"}}", rnum = u_get_num_random(10000-1));
|
||||
|
||||
(void) es->sendPOST(buffer1, len1+ULEN, buffer2, len2+QLEN);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_update->id, pworld_update->randomNumber);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", id, rnum);
|
||||
#else
|
||||
World* pworld;
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_update));
|
||||
U_NEW(World, pworld, World(id, rnum));
|
||||
|
||||
pvworld_update->push_back(pworld);
|
||||
#endif
|
||||
|
|
|
@ -5,8 +5,6 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static World* pworld;
|
||||
static UString* jquery;
|
||||
static UMongoDBClient* mc;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
|
@ -33,9 +31,6 @@ static void usp_fork_mdb()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld, World);
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("{'randomNumber'"));
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
#endif
|
||||
|
@ -48,15 +43,9 @@ static void usp_end_mdb()
|
|||
|
||||
delete mc;
|
||||
|
||||
if (pworld)
|
||||
{
|
||||
delete pworld;
|
||||
delete jquery;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue) delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -64,18 +53,18 @@ static void usp_end_mdb()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString result;
|
||||
|
||||
(void) mc->findOne(pworld->id = u_get_num_random(10000-1));
|
||||
(void) mc->findOne(id = u_get_num_random(10000-1));
|
||||
|
||||
(void) UValue::jread(mc->vitem[0], *jquery, result); // { "_id" : 8980.000000, "id" : 8980.000000, "randomNumber" : 2131.000000 }
|
||||
|
||||
pworld->randomNumber = u_strtoul(result.data(), result.end());
|
||||
(void) UValue::jfind(mc->vitem[0], U_CONSTANT_TO_PARAM("randomNumber"), result);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", pworld->id, result.rep);
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, result.rep);
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, World, *pworld);
|
||||
World world(id, u_strtoul(result.data(), result.end()));
|
||||
USP_JSON_stringify(*pvalue, World, world);
|
||||
pvalue->clear();
|
||||
#endif
|
||||
-->
|
||||
|
|
|
@ -5,7 +5,6 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "fortune.h"
|
||||
|
||||
static UString* jquery;
|
||||
static UString* pencoded;
|
||||
static UMongoDBClient* mc;
|
||||
static Fortune* pfortune2add;
|
||||
|
@ -31,7 +30,6 @@ static void usp_fork_mfortune()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("{'message'"));
|
||||
U_NEW(UString, pencoded, UString(100U));
|
||||
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
|
||||
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
|
||||
|
@ -44,9 +42,8 @@ static void usp_end_mfortune()
|
|||
|
||||
delete mc;
|
||||
|
||||
if (jquery)
|
||||
if (pencoded)
|
||||
{
|
||||
delete jquery;
|
||||
delete pencoded;
|
||||
delete pvfortune;
|
||||
delete pfortune2add;
|
||||
|
@ -60,15 +57,19 @@ uint32_t i, n;
|
|||
UString result;
|
||||
|
||||
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
||||
|
||||
pvfortune->push_back(item);
|
||||
|
||||
(void) mc->findAll();
|
||||
|
||||
for (i = 0, n = mc->vitem.size(); i < n; ++i)
|
||||
{
|
||||
(void) UValue::jread(mc->vitem[i], *jquery, result); // { "_id" : 5.000000, "id" : 5.000000, "message" : "A computer program does what you tell it to do, not what you want it to do." }
|
||||
result.clear();
|
||||
|
||||
(void) UValue::jfind(mc->vitem[i], U_CONSTANT_TO_PARAM("message"), result);
|
||||
|
||||
U_NEW(Fortune, item, Fortune(i+1, result));
|
||||
|
||||
pvfortune->push_back(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,9 +5,7 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static UString* jquery;
|
||||
static UMongoDBClient* mc;
|
||||
static World* pworld_query;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
|
@ -34,9 +32,6 @@ static void usp_fork_mquery()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("{'randomNumber'"));
|
||||
U_NEW(World, pworld_query, World);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
|
||||
|
@ -50,16 +45,13 @@ static void usp_end_mquery()
|
|||
|
||||
delete mc;
|
||||
|
||||
if (jquery)
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete jquery;
|
||||
delete pworld_query;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_query;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -67,6 +59,7 @@ static void usp_end_mquery()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString rnumber;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
@ -76,18 +69,18 @@ USP_PUTS_CHAR('[');
|
|||
|
||||
while (true)
|
||||
{
|
||||
(void) mc->findOne(pworld_query->id = u_get_num_random(10000-1));
|
||||
(void) mc->findOne(id = u_get_num_random(10000-1));
|
||||
|
||||
(void) UValue::jread(mc->vitem[0], *jquery, rnumber); // { "_id" : 8980.000000, "id" : 8980.000000, "randomNumber" : 2131.000000 }
|
||||
rnumber.clear();
|
||||
|
||||
(void) UValue::jfind(mc->vitem[0], U_CONSTANT_TO_PARAM("randomNumber"), rnumber);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", pworld_query->id, rnumber.rep);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", id, rnumber.rep);
|
||||
#else
|
||||
pworld_query->randomNumber = u_strtoul(rnumber.data(), rnumber.end());
|
||||
|
||||
World* pworld;
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_query));
|
||||
U_NEW(World, pworld, World(id, u_strtoul(rnumber.data(), rnumber.end())));
|
||||
|
||||
pvworld_query->push_back(pworld);
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,6 @@ TechEmpower Web Framework Benchmarks
|
|||
#include "world.h"
|
||||
|
||||
static UMongoDBClient* mc;
|
||||
static World* pworld_update;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
|
@ -33,8 +32,6 @@ static void usp_fork_mupdate()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld_update, World);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
|
||||
|
@ -48,15 +45,13 @@ static void usp_end_mupdate()
|
|||
|
||||
delete mc;
|
||||
|
||||
if (pworld_update)
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete pworld_update;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_update;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -64,6 +59,7 @@ static void usp_end_mupdate()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id, rnum;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
|
@ -72,17 +68,15 @@ USP_PUTS_CHAR('[');
|
|||
|
||||
while (true)
|
||||
{
|
||||
(void) mc->findOne(pworld_update->id = u_get_num_random(10000-1));
|
||||
|
||||
(void) mc->update(pworld_update->id, "randomNumber", pworld_update->randomNumber = u_get_num_random(10000-1));
|
||||
(void) mc->findOne( id = u_get_num_random(10000-1));
|
||||
(void) mc->update(id, "randomNumber", rnum = u_get_num_random(10000-1));
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_update->id, pworld_update->randomNumber);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", id, rnum);
|
||||
#else
|
||||
|
||||
World* pworld;
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_update));
|
||||
U_NEW(World, pworld, World(id, rnum));
|
||||
|
||||
pvworld_update->push_back(pworld);
|
||||
#endif
|
||||
|
|
|
@ -5,7 +5,6 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static World* pworld;
|
||||
static char buffer[128];
|
||||
static UREDISClient_Base* rc;
|
||||
|
||||
|
@ -26,13 +25,11 @@ static void usp_fork_rdb()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld, World);
|
||||
u__memcpy(buffer, "world:", U_CONSTANT_SIZE("world:"), __PRETTY_FUNCTION__);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer, "world:", U_CONSTANT_SIZE("world:"), __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -42,14 +39,9 @@ static void usp_end_rdb()
|
|||
|
||||
delete rc;
|
||||
|
||||
if (pworld)
|
||||
{
|
||||
delete pworld;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue) delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -57,18 +49,16 @@ static void usp_end_rdb()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
UStringRep* rep;
|
||||
uint32_t id;
|
||||
|
||||
(void) rc->get(buffer, 6+u_num2str32(buffer+6, pworld->id = u_get_num_random(10000-1)));
|
||||
|
||||
rep = rc->vitem[0].rep;
|
||||
|
||||
pworld->randomNumber = u_strtoul(rep->data(), rep->end());
|
||||
(void) rc->get(buffer, 6+u_num2str32(buffer+6, id = u_get_num_random(10000-1)));
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", pworld->id, rep);
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, rc->vitem[0].rep);
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, World, *pworld);
|
||||
UStringRep* rep = rc->vitem[0].rep;
|
||||
World world(id, u_strtoul(rep->data(), rep->end()));
|
||||
USP_JSON_stringify(*pvalue, World, world);
|
||||
pvalue->clear();
|
||||
#endif
|
||||
-->
|
||||
|
|
|
@ -527,7 +527,7 @@ public:
|
|||
|
||||
UString tmp(encoded.size() + 200U);
|
||||
|
||||
tmp.snprintf("\n\t\tU_INTERNAL_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false);"
|
||||
tmp.snprintf("\n\t\tU_INTERNAL_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false)"
|
||||
"\n\t\tU_http_info.endHeader = %u;"
|
||||
"\n\t\t(void) UClientImage_Base::wbuffer->insert(0, \n\tU_CONSTANT_TO_PARAM(%v));\n", n, encoded.rep);
|
||||
|
||||
|
@ -563,7 +563,8 @@ public:
|
|||
bsighup == false ||
|
||||
bfork == false)
|
||||
{
|
||||
ptr6 = "\n\t\tif (param >= U_DPAGE_FORK) return;\n";
|
||||
ptr6 = (bfork ? "\n\t\tif (param > U_DPAGE_FORK) return;\n"
|
||||
: "\n\t\tif (param >= U_DPAGE_FORK) return;\n");
|
||||
}
|
||||
|
||||
if (bparallelization) ptr7 = "\t\n\t\tif (UServer_Base::startParallelization(UServer_Base::num_client_for_parallelization)) return;\n\t\n";
|
||||
|
|
|
@ -27,11 +27,9 @@ public:
|
|||
# endif
|
||||
}
|
||||
|
||||
World(const World& w) : id(w.id), randomNumber(w.randomNumber)
|
||||
World(uint32_t _id, uint32_t _randomNumber) : id(_id), randomNumber(_randomNumber)
|
||||
{
|
||||
U_TRACE_REGISTER_OBJECT(5, World, "%p", &w)
|
||||
|
||||
U_MEMORY_TEST_COPY(w)
|
||||
U_TRACE_REGISTER_OBJECT(5, World, "%u,%u", _id, _randomNumber)
|
||||
}
|
||||
|
||||
~World()
|
||||
|
|
|
@ -36,8 +36,9 @@ void Url::setService(const char* service, uint32_t n)
|
|||
if (service_end > 0) (void) url.replace(0, service_end, service, n);
|
||||
else
|
||||
{
|
||||
(void) url.insert(0, U_CONSTANT_TO_PARAM("://"));
|
||||
(void) url.insert(0, service, n);
|
||||
char buffer[32];
|
||||
|
||||
(void) url.insert(0, buffer, u__snprintf(buffer, sizeof(buffer), "%.*s://", n, service));
|
||||
}
|
||||
|
||||
findpos();
|
||||
|
@ -49,10 +50,7 @@ UString Url::getUser()
|
|||
|
||||
UString usr;
|
||||
|
||||
if (user_begin < user_end)
|
||||
{
|
||||
usr = url.substr(user_begin, user_end - user_begin);
|
||||
}
|
||||
if (user_begin < user_end) usr = url.substr(user_begin, user_end - user_begin);
|
||||
|
||||
U_RETURN_STRING(usr);
|
||||
}
|
||||
|
@ -67,14 +65,12 @@ bool Url::setUser(const char* user, uint32_t n)
|
|||
|
||||
if (host_begin < host_end)
|
||||
{
|
||||
if (user_begin < user_end)
|
||||
{
|
||||
(void) url.replace(user_begin, user_end - user_begin, user, n);
|
||||
}
|
||||
if (user_begin < user_end) (void) url.replace(user_begin, user_end - user_begin, user, n);
|
||||
else
|
||||
{
|
||||
(void) url.insert(user_begin, 1, '@');
|
||||
(void) url.insert(user_begin, user, n);
|
||||
char buffer[128];
|
||||
|
||||
(void) url.insert(user_begin, buffer, u__snprintf(buffer, sizeof(buffer), "%.*s@", n, user));
|
||||
}
|
||||
|
||||
findpos();
|
||||
|
@ -199,10 +195,7 @@ void Url::setPath(const char* path, uint32_t n)
|
|||
|
||||
if (path_begin < path_end)
|
||||
{
|
||||
if (*path != '/')
|
||||
{
|
||||
++path_begin;
|
||||
}
|
||||
if (*path != '/') ++path_begin;
|
||||
|
||||
(void) url.replace(path_begin, path_end - path_begin, path, n);
|
||||
}
|
||||
|
@ -335,7 +328,14 @@ void Url::findpos()
|
|||
|
||||
if (service_end < 0)
|
||||
{
|
||||
service_end = user_begin = user_end = host_begin = host_end = path_begin = path_end = query = 0;
|
||||
service_end =
|
||||
user_begin =
|
||||
user_end =
|
||||
host_begin =
|
||||
host_end =
|
||||
path_begin =
|
||||
path_end =
|
||||
query = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ USP_FLAGS="-DAS_cpoll_cppsp_DO" \
|
|||
--without-ssl --without-pcre --without-expat \
|
||||
--without-libz --without-libuuid --without-magic --without-libares \
|
||||
--enable-static-orm-driver='mysql pgsql sqlite' --enable-static-server-plugin=http \
|
||||
--with-mongodb --with-mongodb-includes="-I$IROOT/include/libbson-1.0 -I$IROOT/include/libmongoc-1.0" --with-mongodb-ldflags="-L$IROOT"
|
||||
# --enable-debug --enable-HCRS --enable-HPRS --disable-CRPWS --disable-check-time --disable-HIS --disable-log --disable-GSDS --disable-alias --disable-HSTS \
|
||||
--with-mongodb --with-mongodb-includes="-I$IROOT/include/libbson-1.0 -I$IROOT/include/libmongoc-1.0" --with-mongodb-ldflags="-L$IROOT"
|
||||
#USP_LIBS="-ljson" \
|
||||
|
||||
cp config.cache ..
|
||||
|
@ -53,10 +52,11 @@ make clean
|
|||
make install
|
||||
|
||||
cd ../../src/ulib/net/server/plugin/usp
|
||||
make json.la plaintext.la db.la query.la update.la fortune.la rdb.la rquery.la rupdate.la rfortune.la mdb.la mquery.la mupdate.la mfortune.la
|
||||
make json.la plaintext.la db.la query.la update.la fortune.la rdb.la rquery.la rupdate.la rfortune.la mdb.la mquery.la mupdate.la mfortune.la edb.la equery.la eupdate.la
|
||||
|
||||
mkdir -p $ULIB_DOCUMENT_ROOT
|
||||
cp .libs/json.so .libs/plaintext.so \
|
||||
.libs/edb.so .libs/equery.so .libs/eupdate.so \
|
||||
.libs/db.so .libs/query.so .libs/update.so .libs/fortune.so \
|
||||
.libs/rdb.so .libs/rquery.so .libs/rupdate.so .libs/rfortune.so \
|
||||
.libs/mdb.so .libs/mquery.so .libs/mupdate.so .libs/mfortune.so $ULIB_DOCUMENT_ROOT
|
||||
|
|
|
@ -5,56 +5,45 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static World* pworld;
|
||||
static UString* jquery;
|
||||
static char buffer[128];
|
||||
static UElasticSearchClient* es;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
static UValue* pvalue;
|
||||
#endif
|
||||
|
||||
#define QLEN U_CONSTANT_SIZE("{\"query\":{\"match\":{\"_id\":\"")
|
||||
|
||||
static void usp_fork_edb()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_edb()")
|
||||
U_TRACE(5, "::usp_fork_edb()")
|
||||
|
||||
U_NEW(UElasticSearchClient, es, UElasticSearchClient);
|
||||
U_NEW(UElasticSearchClient, es, UElasticSearchClient);
|
||||
|
||||
if (es->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_edb(): connection disabled or failed");
|
||||
if (es->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_edb(): connection disabled or failed");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld, World);
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("randomNumber"));
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_edb()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_edb()")
|
||||
U_TRACE(5, "::usp_end_edb()")
|
||||
|
||||
delete es;
|
||||
delete es;
|
||||
|
||||
if (pworld)
|
||||
{
|
||||
delete jquery;
|
||||
delete pworld;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue) delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -62,18 +51,18 @@ static void usp_end_edb()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString result;
|
||||
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", pworld->id = u_get_num_random(10000-1)));
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, u__snprintf(buffer+QLEN, 128, "%u\"}}}", id = u_get_num_random(10000-1))+QLEN);
|
||||
|
||||
(void) UValue::jfind(es->getContent(), *jquery, result);
|
||||
|
||||
pworld->randomNumber = u_strtoul(result.data(), result.end());
|
||||
(void) UValue::jfind(es->getContent(), U_CONSTANT_TO_PARAM("randomNumber"), result);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", pworld->id, result.rep);
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, result.rep);
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, World, *pworld);
|
||||
World world(id, u_strtoul(result.data(), result.end()));
|
||||
USP_JSON_stringify(*pvalue, World, world);
|
||||
pvalue->clear();
|
||||
#endif
|
||||
-->
|
||||
|
|
|
@ -5,9 +5,7 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static UString* jquery;
|
||||
static char buffer[128];
|
||||
static World* pworld_query;
|
||||
static UElasticSearchClient* es;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
|
@ -30,15 +28,12 @@ static void usp_fork_equery()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld_query, World);
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("randomNumber"));
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer, "{\"query\":{\"match\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -48,16 +43,13 @@ static void usp_end_equery()
|
|||
|
||||
delete es;
|
||||
|
||||
if (jquery)
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete jquery;
|
||||
delete pworld_query;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_query;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -65,6 +57,7 @@ static void usp_end_equery()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString rnumber;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
@ -74,18 +67,18 @@ USP_PUTS_CHAR('[');
|
|||
|
||||
while (true)
|
||||
{
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", pworld_query->id = u_get_num_random(10000-1)));
|
||||
(void) es->sendPOST(U_CONSTANT_TO_PARAM("/tfb/world/_search"), buffer, QLEN+u__snprintf(buffer+QLEN, 128, "%u\"}}}", id = u_get_num_random(10000-1)));
|
||||
|
||||
(void) UValue::jfind(es->getContent(), *jquery, rnumber);
|
||||
rnumber.clear();
|
||||
|
||||
(void) UValue::jfind(es->getContent(), U_CONSTANT_TO_PARAM("randomNumber"), rnumber);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", pworld_query->id, rnumber.rep);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", id, rnumber.rep);
|
||||
#else
|
||||
pworld_query->randomNumber = u_strtoul(rnumber.data(), rnumber.end());
|
||||
|
||||
World* pworld;
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_query));
|
||||
U_NEW(World, pworld, World(id, u_strtoul(rnumber.data(), rnumber.end())));
|
||||
|
||||
pvworld_query->push_back(pworld);
|
||||
#endif
|
||||
|
|
|
@ -5,13 +5,14 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static char* pbuffer1;
|
||||
static char* pbuffer2;
|
||||
static char buffer1[128];
|
||||
static char buffer2[128];
|
||||
static World* pworld_update;
|
||||
static UElasticSearchClient* es;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
static UValue* pvalue;
|
||||
static UVector<World*>* pvworld_update;
|
||||
#endif
|
||||
|
||||
|
@ -20,44 +21,45 @@ static UVector<World*>* pvworld_update;
|
|||
|
||||
static void usp_fork_eupdate()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_eupdate()")
|
||||
U_TRACE(5, "::usp_fork_eupdate()")
|
||||
|
||||
U_NEW(UElasticSearchClient, es, UElasticSearchClient);
|
||||
|
||||
if (es->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_eupdate(): connection disabled or failed");
|
||||
if (es->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_eupdate(): connection disabled or failed");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld_update, World);
|
||||
u__memcpy(buffer1, "/tfb/world/", ULEN, __PRETTY_FUNCTION__);
|
||||
|
||||
pbuffer1 = buffer1 + ULEN;
|
||||
|
||||
u__memcpy(buffer2, "{\"doc\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
|
||||
pbuffer2 = buffer2 + QLEN;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer1, "/tfb/world/", ULEN, __PRETTY_FUNCTION__);
|
||||
u__memcpy(buffer2, "{\"doc\":{\"_id\":\"", QLEN, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_eupdate()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_eupdate()")
|
||||
U_TRACE(5, "::usp_end_eupdate()")
|
||||
|
||||
delete es;
|
||||
delete es;
|
||||
|
||||
if (pworld_update)
|
||||
{
|
||||
delete pworld_update;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_update;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete pvalue;
|
||||
delete pvworld_update;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -65,7 +67,7 @@ static void usp_end_eupdate()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
World* pworld;
|
||||
uint32_t len1, len2, id, rnum;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
|
@ -73,25 +75,28 @@ USP_PUTS_CHAR('[');
|
|||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
(void) es->sendPOST(buffer1, ULEN+u__snprintf(buffer1+ULEN, 128, "%u/_update", pworld_update->id = u_get_num_random(10000-1)),
|
||||
buffer2, QLEN+u__snprintf(buffer2+QLEN, 128, "%u\"}}", pworld_update->randomNumber = u_get_num_random(10000-1)));
|
||||
{
|
||||
len1 = u__snprintf(pbuffer1, 100, "%u/_update", id = u_get_num_random(10000-1));
|
||||
len2 = u__snprintf(pbuffer2, 100, "%u\"}}", rnum = u_get_num_random(10000-1));
|
||||
|
||||
(void) es->sendPOST(buffer1, len1+ULEN, buffer2, len2+QLEN);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_update->id, pworld_update->randomNumber);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", id, rnum);
|
||||
#else
|
||||
World* pworld;
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_update));
|
||||
U_NEW(World, pworld, World(id, rnum));
|
||||
|
||||
pvworld_update->push_back(pworld);
|
||||
pvworld_update->push_back(pworld);
|
||||
#endif
|
||||
|
||||
if (++i == num_queries) break;
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(',');
|
||||
USP_PUTS_CHAR(',');
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(']');
|
||||
|
|
|
@ -5,58 +5,47 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static World* pworld;
|
||||
static UString* jquery;
|
||||
static UMongoDBClient* mc;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
static UValue* pvalue;
|
||||
#endif
|
||||
|
||||
static void usp_fork_mdb()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_mdb()")
|
||||
U_TRACE(5, "::usp_fork_mdb()")
|
||||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mdb(): connection failed");
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mdb(): connection failed");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mc->selectCollection("hello_world", "World") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mdb(): selectCollection() failed");
|
||||
if (mc->selectCollection("hello_world", "World") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mdb(): selectCollection() failed");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld, World);
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("{'randomNumber'"));
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_mdb()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_mdb()")
|
||||
U_TRACE(5, "::usp_end_mdb()")
|
||||
|
||||
delete mc;
|
||||
delete mc;
|
||||
|
||||
if (pworld)
|
||||
{
|
||||
delete pworld;
|
||||
delete jquery;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue) delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -64,18 +53,18 @@ static void usp_end_mdb()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString result;
|
||||
|
||||
(void) mc->findOne(pworld->id = u_get_num_random(10000-1));
|
||||
(void) mc->findOne(id = u_get_num_random(10000-1));
|
||||
|
||||
(void) UValue::jread(mc->vitem[0], *jquery, result); // { "_id" : 8980.000000, "id" : 8980.000000, "randomNumber" : 2131.000000 }
|
||||
|
||||
pworld->randomNumber = u_strtoul(result.data(), result.end());
|
||||
(void) UValue::jfind(mc->vitem[0], U_CONSTANT_TO_PARAM("randomNumber"), result);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", pworld->id, result.rep);
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, result.rep);
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, World, *pworld);
|
||||
World world(id, u_strtoul(result.data(), result.end()));
|
||||
USP_JSON_stringify(*pvalue, World, world);
|
||||
pvalue->clear();
|
||||
#endif
|
||||
-->
|
||||
|
|
|
@ -5,7 +5,6 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "fortune.h"
|
||||
|
||||
static UString* jquery;
|
||||
static UString* pencoded;
|
||||
static UMongoDBClient* mc;
|
||||
static Fortune* pfortune2add;
|
||||
|
@ -13,44 +12,42 @@ static UVector<Fortune*>* pvfortune;
|
|||
|
||||
static void usp_fork_mfortune()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_mfortune()")
|
||||
U_TRACE(5, "::usp_fork_mfortune()")
|
||||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mfortune(): connection failed");
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mfortune(): connection failed");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mc->selectCollection("hello_world", "Fortune") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mfortune(): selectCollection() failed");
|
||||
if (mc->selectCollection("hello_world", "Fortune") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mfortune(): selectCollection() failed");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("{'message'"));
|
||||
U_NEW(UString, pencoded, UString(100U));
|
||||
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
|
||||
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
|
||||
U_NEW(UString, pencoded, UString(100U));
|
||||
U_NEW(UVector<Fortune*>, pvfortune, UVector<Fortune*>);
|
||||
U_NEW(Fortune, pfortune2add, Fortune(0, U_STRING_FROM_CONSTANT("Additional fortune added at request time.")));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_mfortune()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_mfortune()")
|
||||
U_TRACE(5, "::usp_end_mfortune()")
|
||||
|
||||
delete mc;
|
||||
delete mc;
|
||||
|
||||
if (jquery)
|
||||
{
|
||||
delete jquery;
|
||||
delete pencoded;
|
||||
delete pvfortune;
|
||||
delete pfortune2add;
|
||||
}
|
||||
if (pencoded)
|
||||
{
|
||||
delete pencoded;
|
||||
delete pvfortune;
|
||||
delete pfortune2add;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -60,33 +57,37 @@ uint32_t i, n;
|
|||
UString result;
|
||||
|
||||
U_NEW(Fortune, item, Fortune(*pfortune2add));
|
||||
|
||||
pvfortune->push_back(item);
|
||||
|
||||
(void) mc->findAll();
|
||||
|
||||
for (i = 0, n = mc->vitem.size(); i < n; ++i)
|
||||
{
|
||||
(void) UValue::jread(mc->vitem[i], *jquery, result); // { "_id" : 5.000000, "id" : 5.000000, "message" : "A computer program does what you tell it to do, not what you want it to do." }
|
||||
{
|
||||
result.clear();
|
||||
|
||||
(void) UValue::jfind(mc->vitem[i], U_CONSTANT_TO_PARAM("message"), result);
|
||||
|
||||
U_NEW(Fortune, item, Fortune(i+1, result));
|
||||
|
||||
pvfortune->push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
pvfortune->sort(Fortune::cmp_obj);
|
||||
|
||||
for (i = 0, ++n; i < n; ++i)
|
||||
{
|
||||
Fortune* elem = (*pvfortune)[i];
|
||||
{
|
||||
Fortune* elem = (*pvfortune)[i];
|
||||
|
||||
UXMLEscape::encode(elem->message, *pencoded);
|
||||
UXMLEscape::encode(elem->message, *pencoded);
|
||||
|
||||
USP_PRINTF_ADD(
|
||||
"<tr>"
|
||||
"<td>%u</td>"
|
||||
"<td>%v</td>"
|
||||
"</tr>",
|
||||
elem->id, pencoded->rep);
|
||||
}
|
||||
USP_PRINTF_ADD(
|
||||
"<tr>"
|
||||
"<td>%u</td>"
|
||||
"<td>%v</td>"
|
||||
"</tr>",
|
||||
elem->id, pencoded->rep);
|
||||
}
|
||||
|
||||
pvfortune->clear();
|
||||
--></table></body></html>
|
||||
|
|
|
@ -5,61 +5,53 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static UString* jquery;
|
||||
static UMongoDBClient* mc;
|
||||
static World* pworld_query;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
static UValue* pvalue;
|
||||
static UVector<World*>* pvworld_query;
|
||||
#endif
|
||||
|
||||
static void usp_fork_mquery()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_mquery()")
|
||||
U_TRACE(5, "::usp_fork_mquery()")
|
||||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mquery(): connection disabled or failed");
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mquery(): connection disabled or failed");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mc->selectCollection("hello_world", "World") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mquery(): selectCollection() failed");
|
||||
if (mc->selectCollection("hello_world", "World") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mquery(): selectCollection() failed");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
U_NEW(UString, jquery, U_STRING_FROM_CONSTANT("{'randomNumber'"));
|
||||
U_NEW(World, pworld_query, World);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_query, UVector<World*>(500));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_mquery()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_mquery()")
|
||||
U_TRACE(5, "::usp_end_mquery()")
|
||||
|
||||
delete mc;
|
||||
delete mc;
|
||||
|
||||
if (jquery)
|
||||
{
|
||||
delete jquery;
|
||||
delete pworld_query;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_query;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete pvalue;
|
||||
delete pvworld_query;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -67,6 +59,7 @@ static void usp_end_mquery()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id;
|
||||
UString rnumber;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
@ -75,29 +68,29 @@ USP_PUTS_CHAR('[');
|
|||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
(void) mc->findOne(pworld_query->id = u_get_num_random(10000-1));
|
||||
{
|
||||
(void) mc->findOne(id = u_get_num_random(10000-1));
|
||||
|
||||
(void) UValue::jread(mc->vitem[0], *jquery, rnumber); // { "_id" : 8980.000000, "id" : 8980.000000, "randomNumber" : 2131.000000 }
|
||||
rnumber.clear();
|
||||
|
||||
(void) UValue::jfind(mc->vitem[0], U_CONSTANT_TO_PARAM("randomNumber"), rnumber);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", pworld_query->id, rnumber.rep);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%v}", id, rnumber.rep);
|
||||
#else
|
||||
pworld_query->randomNumber = u_strtoul(rnumber.data(), rnumber.end());
|
||||
World* pworld;
|
||||
|
||||
World* pworld;
|
||||
U_NEW(World, pworld, World(id, u_strtoul(rnumber.data(), rnumber.end())));
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_query));
|
||||
|
||||
pvworld_query->push_back(pworld);
|
||||
pvworld_query->push_back(pworld);
|
||||
#endif
|
||||
|
||||
if (++i == num_queries) break;
|
||||
if (++i == num_queries) break;
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(',');
|
||||
USP_PUTS_CHAR(',');
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(']');
|
||||
|
|
|
@ -6,57 +6,52 @@ TechEmpower Web Framework Benchmarks
|
|||
#include "world.h"
|
||||
|
||||
static UMongoDBClient* mc;
|
||||
static World* pworld_update;
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
static UValue* pvalue;
|
||||
static UVector<World*>* pvworld_update;
|
||||
#endif
|
||||
|
||||
static void usp_fork_mupdate()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_mupdate()")
|
||||
U_TRACE(5, "::usp_fork_mupdate()")
|
||||
|
||||
U_NEW(UMongoDBClient, mc, UMongoDBClient);
|
||||
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mupdate(): connection disabled or failed");
|
||||
if (mc->connect() == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mupdate(): connection disabled or failed");
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mc->selectCollection("hello_world", "World") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mupdate(): selectCollection() failed");
|
||||
if (mc->selectCollection("hello_world", "World") == false)
|
||||
{
|
||||
U_WARNING("usp_fork_mupdate(): selectCollection() failed");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld_update, World);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
|
||||
U_NEW(UValue, pvalue, UValue(ARRAY_VALUE));
|
||||
U_NEW(UVector<World*>, pvworld_update, UVector<World*>(500));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_mupdate()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_mupdate()")
|
||||
U_TRACE(5, "::usp_end_mupdate()")
|
||||
|
||||
delete mc;
|
||||
delete mc;
|
||||
|
||||
if (pworld_update)
|
||||
{
|
||||
delete pworld_update;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
delete pvworld_update;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue)
|
||||
{
|
||||
delete pvalue;
|
||||
delete pvworld_update;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -64,6 +59,7 @@ static void usp_end_mupdate()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t id, rnum;
|
||||
int i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
|
@ -71,28 +67,26 @@ USP_PUTS_CHAR('[');
|
|||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
(void) mc->findOne(pworld_update->id = u_get_num_random(10000-1));
|
||||
|
||||
(void) mc->update(pworld_update->id, "randomNumber", pworld_update->randomNumber = u_get_num_random(10000-1));
|
||||
{
|
||||
(void) mc->findOne( id = u_get_num_random(10000-1));
|
||||
(void) mc->update(id, "randomNumber", rnum = u_get_num_random(10000-1));
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_update->id, pworld_update->randomNumber);
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", id, rnum);
|
||||
#else
|
||||
World* pworld;
|
||||
|
||||
World* pworld;
|
||||
U_NEW(World, pworld, World(id, rnum));
|
||||
|
||||
U_NEW(World, pworld, World(*pworld_update));
|
||||
|
||||
pvworld_update->push_back(pworld);
|
||||
pvworld_update->push_back(pworld);
|
||||
#endif
|
||||
|
||||
if (++i == num_queries) break;
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(',');
|
||||
USP_PUTS_CHAR(',');
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(']');
|
||||
|
|
|
@ -5,7 +5,6 @@ TechEmpower Web Framework Benchmarks
|
|||
<!--#declaration
|
||||
#include "world.h"
|
||||
|
||||
static World* pworld;
|
||||
static char buffer[128];
|
||||
static UREDISClient_Base* rc;
|
||||
|
||||
|
@ -26,13 +25,11 @@ static void usp_fork_rdb()
|
|||
return;
|
||||
}
|
||||
|
||||
U_NEW(World, pworld, World);
|
||||
u__memcpy(buffer, "world:", U_CONSTANT_SIZE("world:"), __PRETTY_FUNCTION__);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
U_NEW(UValue, pvalue, UValue(OBJECT_VALUE));
|
||||
#endif
|
||||
|
||||
u__memcpy(buffer, "world:", U_CONSTANT_SIZE("world:"), __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -42,14 +39,9 @@ static void usp_end_rdb()
|
|||
|
||||
delete rc;
|
||||
|
||||
if (pworld)
|
||||
{
|
||||
delete pworld;
|
||||
|
||||
# ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
# endif
|
||||
}
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
if (pvalue) delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
|
@ -57,18 +49,16 @@ static void usp_end_rdb()
|
|||
Content-Type: application/json
|
||||
-->
|
||||
<!--#code
|
||||
UStringRep* rep;
|
||||
uint32_t id;
|
||||
|
||||
(void) rc->get(buffer, 6+u_num2str32(buffer+6, pworld->id = u_get_num_random(10000-1)));
|
||||
|
||||
rep = rc->vitem[0].rep;
|
||||
|
||||
pworld->randomNumber = u_strtoul(rep->data(), rep->end());
|
||||
(void) rc->get(buffer, 6+u_num2str32(buffer+6, id = u_get_num_random(10000-1)));
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", pworld->id, rep);
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%v}", id, rc->vitem[0].rep);
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, World, *pworld);
|
||||
UStringRep* rep = rc->vitem[0].rep;
|
||||
World world(id, u_strtoul(rep->data(), rep->end()));
|
||||
USP_JSON_stringify(*pvalue, World, world);
|
||||
pvalue->clear();
|
||||
#endif
|
||||
-->
|
||||
|
|
|
@ -27,11 +27,9 @@ public:
|
|||
# endif
|
||||
}
|
||||
|
||||
World(const World& w) : id(w.id), randomNumber(w.randomNumber)
|
||||
World(uint32_t _id, uint32_t _randomNumber) : id(_id), randomNumber(_randomNumber)
|
||||
{
|
||||
U_TRACE_REGISTER_OBJECT(5, World, "%p", &w)
|
||||
|
||||
U_MEMORY_TEST_COPY(w)
|
||||
U_TRACE_REGISTER_OBJECT(5, World, "%u,%u", _id, _randomNumber)
|
||||
}
|
||||
|
||||
~World()
|
||||
|
|
Loading…
Reference in New Issue
Block a user