1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00
This commit is contained in:
stefanocasazza 2017-06-23 14:43:08 +02:00
parent 6555d29cd2
commit dd7188d3b3
3 changed files with 86 additions and 60 deletions

View File

@ -61,9 +61,13 @@ static void usp_end_fortune()
#endif
-->
<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
uint32_t sz;
Fortune* item;
char* s = UClientImage_Base::wbuffer->data();
char* ptr = UClientImage_Base::wbuffer->pend();
U_NEW(Fortune, item, Fortune(*pfortune2add));
pvfortune->push_back(item);
pstmt_fortune->execute();
@ -83,13 +87,26 @@ for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
UXMLEscape::encode(elem->message, *pencoded);
USP_PRINTF_ADD(
"<tr>"
"<td>%u</td>"
"<td>%v</td>"
"</tr>",
elem->id, pencoded->rep);
sz = pencoded->size();
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>'));
ptr = u_num2str32(elem->id, ptr+8);
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d'));
ptr += 8;
*ptr++ = '>';
(void) memcpy(ptr, pencoded->data(), sz);
ptr += sz;
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
u_put_unalignedp16(ptr+8, U_MULTICHAR_CONSTANT16('r','>'));
ptr += 10;
}
UClientImage_Base::wbuffer->size_adjust(ptr - s);
pvfortune->clear();
--></table></body></html>

View File

@ -1246,8 +1246,8 @@ void UServer_Base::initEvasive()
delete db_evasive;
delete evasive_rec;
db_evasive = U_NULLPTR;
evasive_rec = U_NULLPTR;
db_evasive = U_NULLPTR;
evasive_rec = U_NULLPTR;
}
}
@ -1445,16 +1445,8 @@ bool UServer_Base::checkHitUriStats()
if (bwhitelist == false)
{
uint32_t sz = U_http_info.uri_len;
const char* ptr = U_http_info.uri;
# ifdef U_ALIAS
if (*UClientImage_Base::request_uri) // The interpreted pathname of the original requested document (relative to the document root)
{
sz = UClientImage_Base::request_uri->size();
ptr = UClientImage_Base::request_uri->data();
}
# endif
uint32_t sz;
const char* ptr = UClientImage_Base::getRequestUri(sz);
UString key(UServer_Base::client_address_len + sz);

View File

@ -5,91 +5,108 @@ TechEmpower Web Framework Benchmarks
<!--#declaration
#include "fortune.h"
static Fortune* pfortune;
static Fortune* pfortune;
static Fortune* pfortune2add;
static UString* pencoded;
static UOrmSession* psql_fortune;
static UOrmStatement* pstmt_fortune;
static UOrmSession* psql_fortune;
static UOrmStatement* pstmt_fortune;
static UVector<Fortune*>* pvfortune;
static void usp_fork_fortune()
{
U_TRACE(5, "::usp_fork_fortune()")
U_TRACE(5, "::usp_fork_fortune()")
U_NEW(UOrmSession, psql_fortune, UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
U_NEW(UOrmSession, psql_fortune, UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
if (psql_fortune->isReady() == false)
{
U_WARNING("usp_fork_fortune(): we cound't connect to db");
if (psql_fortune->isReady() == false)
{
U_WARNING("usp_fork_fortune(): we cound't connect to db");
return;
}
return;
}
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
U_NEW(UOrmStatement, pstmt_fortune, UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
// if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
// if (UOrmDriver::isPGSQL()) *psql_fortune << "BEGIN ISOLATION LEVEL SERIALIZABLE; COMMIT";
U_NEW(Fortune, pfortune, Fortune);
U_NEW(Fortune, pfortune, Fortune);
pstmt_fortune->into(*pfortune);
pstmt_fortune->into(*pfortune);
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_fortune()
{
U_TRACE(5, "::usp_end_fortune()")
U_TRACE(5, "::usp_end_fortune()")
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
U_INTERNAL_DUMP("psql_fortune = %p", psql_fortune)
delete psql_fortune;
delete psql_fortune;
if (pstmt_fortune)
{
delete pstmt_fortune;
delete pfortune;
delete pencoded;
delete pvfortune;
delete pfortune2add;
}
if (pstmt_fortune)
{
delete pstmt_fortune;
delete pfortune;
delete pencoded;
delete pvfortune;
delete pfortune2add;
}
}
#endif
-->
<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
uint32_t sz;
Fortune* item;
char* s = UClientImage_Base::wbuffer->data();
char* ptr = UClientImage_Base::wbuffer->pend();
U_NEW(Fortune, item, Fortune(*pfortune2add));
pvfortune->push_back(item);
pstmt_fortune->execute();
do {
U_NEW(Fortune, item, Fortune(*pfortune));
do {
U_NEW(Fortune, item, Fortune(*pfortune));
pvfortune->push_back(item);
}
}
while (pstmt_fortune->nextRow());
pvfortune->sort(Fortune::cmp_obj);
for (uint32_t i = 0, n = pvfortune->size(); 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);
}
sz = pencoded->size();
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','t','r','>','<','t','d','>'));
ptr = u_num2str32(elem->id, ptr+8);
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','t','d'));
ptr += 8;
*ptr++ = '>';
(void) memcpy(ptr, pencoded->data(), sz);
ptr += sz;
u_put_unalignedp64(ptr, U_MULTICHAR_CONSTANT64('<','/','t','d','>','<','/','t'));
u_put_unalignedp16(ptr+8, U_MULTICHAR_CONSTANT16('r','>'));
ptr += 10;
}
UClientImage_Base::wbuffer->size_adjust(ptr - s);
pvfortune->clear();
--></table></body></html>