1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00

bug fixing

This commit is contained in:
stefanocasazza 2015-07-27 19:19:19 +02:00
parent 488927dd47
commit 04ab977e90
28 changed files with 434 additions and 552 deletions

View File

@ -938,7 +938,14 @@ public:
UString front() { return UString(UVector<UStringRep*>::front()); }
UString back() { return UString(UVector<UStringRep*>::back()); }
UString at(uint32_t pos) const __pure;
UString at(uint32_t pos) const __pure
{
U_TRACE(0, "UVector<UString>::at(%u)", pos)
UString result(UVector<UStringRep*>::at(pos));
U_RETURN_STRING(result);
}
UString operator[](uint32_t pos) const;

View File

@ -513,7 +513,7 @@ protected:
static UString* cenvironment;
static UString* senvironment;
static UString* str_preforked_num_kids;
static uint32_t max_depth, wakeup_for_nothing, read_again;
static uint32_t max_depth, wakeup_for_nothing, nread, nread_again;
static bool flag_loop, flag_sigterm, monitoring_process, set_realtime_priority, public_address, binsert, set_tcp_keep_alive;
static uint32_t vplugin_size;

View File

@ -17,11 +17,13 @@
#include <ulib/container/vector.h>
#include <ulib/container/gen_hash_map.h>
/* NB: to force the use of select() uncomment this define
#if defined(U_SERVER_CAPTIVE_PORTAL) && defined(HAVE_EPOLL_WAIT)
# undef HAVE_EPOLL_WAIT
#endif
*/
/**
* NB: to force the use of select() uncomment this define
*
* #if defined(U_SERVER_CAPTIVE_PORTAL) && defined(HAVE_EPOLL_WAIT)
* # undef HAVE_EPOLL_WAIT
* #endif
*/
#ifndef _MSWINDOWS_
# include <sys/select.h>
@ -31,6 +33,10 @@
# endif
#endif
#if defined(HAVE_EPOLL_WAIT) && !defined(USE_LIBEVENT)
# define U_EPOLLET_POSTPONE_STRATEGY
#endif
#include <ulib/event/event_fd.h>
#include <ulib/event/event_time.h>
@ -116,6 +122,10 @@ protected:
static int max_nfd_ready, nfd_ready; // the number of file descriptors ready for the requested I/O
static UGenericHashMap<int,UEventFd*>* hi_map_fd; // maps a fd to a node pointer
#ifdef U_EPOLLET_POSTPONE_STRATEGY
static bool bepollet;
#endif
#ifdef USE_LIBEVENT
// nothing
#elif defined(HAVE_EPOLL_WAIT)

View File

@ -143,7 +143,23 @@ public:
++references;
}
void release(); // NB: we don't use delete (dtor) because add a deallocation to the destroy object process...
void release() // NB: we don't use delete (dtor) because add a deallocation to the destroy object process...
{
U_TRACE(0, "UStringRep::release()")
U_INTERNAL_DUMP("this = %p parent = %p references = %u child = %d", this, parent, references, child)
# ifdef DEBUG
if (memory.invariant() == false)
{
U_ERROR("UStringRep::release() %s - this = %p parent = %p references = %u child = %d _capacity = %u str(%u) = %.*S",
memory.getErrorType(this), this, parent, references, child, _capacity, _length, _length, str);
}
# endif
if (references) --references;
else _release();
}
// Size and Capacity
@ -613,7 +629,9 @@ public:
U_RETURN(false);
}
bool isEndHeader(uint32_t pos) const __pure;
bool isEndHeader(uint32_t pos) const __pure;
bool findEndHeader(uint32_t pos) const __pure;
uint32_t findWhiteSpace(uint32_t pos) const __pure;
bool strtob() const __pure;
@ -805,6 +823,7 @@ private:
U_INTERNAL_ASSERT(invariant())
}
void _release();
void set(uint32_t length, uint32_t capacity, const char* ptr);
// Equal lookup use case
@ -1649,10 +1668,12 @@ public:
bool isBinary(uint32_t pos = 0) const { return rep->isBinary(pos); }
bool isBase64(uint32_t pos = 0) const { return rep->isBase64(pos); }
bool isBase64Url(uint32_t pos = 0) const { return rep->isBase64Url(pos); }
bool isEndHeader(uint32_t pos = 0) const { return rep->isEndHeader(pos); }
bool isWhiteSpace(uint32_t pos = 0) const { return rep->isWhiteSpace(pos); }
bool isPrintable(uint32_t pos = 0, bool bline = false) const { return rep->isPrintable(pos, bline); }
bool isEndHeader(uint32_t pos = 0) const { return rep->isEndHeader(pos); }
bool findEndHeader(uint32_t pos = 0) const { return rep->findEndHeader(pos); }
char last_char() const { return rep->last_char(); }
char first_char() const { return rep->first_char(); }
char c_char(uint32_t pos) const { return rep->at(pos); }

View File

@ -185,31 +185,25 @@ UVector<UString>::UVector(const UString& x, const char* delim) : UVector<UString
U_TRACE_REGISTER_OBJECT(0, UVector<UString>, "%V,%S", x.rep, delim)
const char* s = x.data();
char c = *s;
if (*s == '[' ||
*s == '(')
if (c == '[' ||
c == '(')
{
istream_loading = true; // NB: we need this flag for distinguish this operation in UString::setFromData()...
(void) loadFromData(s, x.size());
istream_loading = false;
}
else
{
(void) split(x, delim);
(void) split(x, delim); // NB: use substr(), so dependency from x...
}
if (_length) reserve(_length);
}
__pure UString UVector<UString>::at(uint32_t pos) const
{
U_TRACE(0, "UVector<UString>::at(%u)", pos)
UStringRep* rep = UVector<UStringRep*>::at(pos);
UString result(rep);
U_RETURN_STRING(result);
}
__pure uint32_t UVector<UString>::find(const char* s, uint32_t n)
{
U_TRACE(0, "UVector<UString>::find(%.*S,%u)", n, s, n)
@ -298,26 +292,6 @@ __pure bool UVector<UString>::isEqual(uint32_t pos, const UString& str, bool ign
U_RETURN(false);
}
/*
__pure uint32_t UVector<UString>::findWithDataOffset(const char* s, uint32_t n, uint32_t offset)
{
U_TRACE(0, "UVector<UString>::findWithDataOffset(%#.*S,%u)", n, s, n)
U_CHECK_MEMORY
UStringRep* r;
for (uint32_t i = 0; i < _length; ++i)
{
r = UVector<UStringRep*>::at(i);
if (u_find(r->data() + offset, r->size() - offset, s, n)) U_RETURN(i);
}
U_RETURN(U_NOT_FOUND);
}
*/
__pure uint32_t UVector<UString>::findSorted(const UString& str, bool ignore_case, bool bcouple)
{
U_TRACE(0, "UVector<UString>::findSorted(%V,%b,%b)", str.rep, ignore_case, bcouple)
@ -781,67 +755,6 @@ static inline int chfunc(UStringRep* a[], int i, int depth)
U_RETURN(result);
}
/* Simple version
static inline void swap2(UStringRep* a[], int i, int j)
{
U_TRACE(0, "swap2(%p,%d,%d)", a, i, j)
UStringRep* t = a[i];
a[i] = a[j];
a[j] = t;
}
static inline void vecswap2(UStringRep* a[], int i, int j, int n)
{
U_TRACE(0, "vecswap2(%p,%d,%d,%d)", a, i, j, n)
while (n-- > 0) swap2(a, i++, j++);
}
#define ch(i) chfunc(a, i, depth)
void UVector<UString>::mksort(UStringRep** a, int n, int depth)
{
U_TRACE(0+256, "UVector<UString>::mksort(%p,%d,%d)", a, n, depth)
int le, lt, gt, ge, r, v;
if (n <= 1) return;
swap2(a, 0, u_random(n) % n);
v = ch(0);
le = lt = 1;
gt = ge = n-1;
for (;;)
{
for (; lt <= gt && ch(lt) <= v; lt++) if (ch(lt) == v) swap2(a, le++, lt);
for (; lt <= gt && ch(gt) >= v; gt--) if (ch(gt) == v) swap2(a, gt, ge--);
if (lt > gt) break;
swap2(a, lt++, gt--);
}
r = U_min(le, lt-le);
vecswap2(a, 0, lt-r, r);
r = U_min(ge-gt, n-ge-1);
vecswap2(a, lt, n-r, r);
mksort(a, lt-le, depth);
if (v != 0) mksort(a + lt-le, le + n-ge-1, depth+1);
mksort(a + n-(ge-gt), ge-gt, depth);
}
*/
/* Faster version */
static inline void vecswap2(UStringRep** a, UStringRep** b, int n)
{
U_TRACE(0, "vecswap2(%p,%p,%d)", a, b, n)

View File

@ -569,7 +569,7 @@ uint32_t UValue::getMemberNames(UVector<UString>& members) const
uint32_t UValue::emitString(const unsigned char* inptr, uint32_t len, char* out)
{
U_TRACE(0, "UValue::emitString(%.*S,%u,%p)", len, inptr, len, out)
U_TRACE(0+256, "UValue::emitString(%.*S,%u,%p)", len, inptr, len, out)
U_INTERNAL_ASSERT_POINTER(out)
U_INTERNAL_ASSERT_POINTER(inptr)

View File

@ -291,8 +291,6 @@ void ULog::updateDate1()
U_INTERNAL_DUMP("tv_sec_old_1 = %lu u_now->tv_sec = %lu", tv_sec_old_1, tv_sec)
U_INTERNAL_ASSERT_MINOR(tv_sec_old_1, tv_sec)
if ((tv_sec - tv_sec_old_1) != 1 ||
(tv_sec % U_ONE_HOUR_IN_SECOND) == 0)
{
@ -326,8 +324,6 @@ void ULog::updateDate1()
U_INTERNAL_DUMP("tv_sec_old_1 = %lu u_now->tv_sec = %lu", tv_sec_old_1, tv_sec)
U_INTERNAL_ASSERT_MINOR(tv_sec_old_1, tv_sec)
if ((tv_sec - tv_sec_old_1) != 1 ||
(tv_sec % U_ONE_HOUR_IN_SECOND) == 0)
{
@ -367,8 +363,6 @@ void ULog::updateDate2()
U_INTERNAL_DUMP("tv_sec_old_2 = %lu u_now->tv_sec = %lu", tv_sec_old_2, tv_sec)
U_INTERNAL_ASSERT_MINOR(tv_sec_old_2, tv_sec)
if ((tv_sec - tv_sec_old_2) != 1 ||
(tv_sec % U_ONE_HOUR_IN_SECOND) == 0)
{
@ -402,8 +396,6 @@ void ULog::updateDate2()
U_INTERNAL_DUMP("tv_sec_old_2 = %lu u_now->tv_sec = %lu", tv_sec_old_2, tv_sec)
U_INTERNAL_ASSERT_MINOR(tv_sec_old_2, tv_sec)
if ((tv_sec - tv_sec_old_2) != 1 ||
(tv_sec % U_ONE_HOUR_IN_SECOND) == 0)
{
@ -444,8 +436,6 @@ void ULog::updateDate3()
U_INTERNAL_DUMP("tv_sec_old_3 = %lu u_now->tv_sec = %lu", tv_sec_old_3, tv_sec)
U_INTERNAL_ASSERT_MINOR(tv_sec_old_3, tv_sec)
if ((tv_sec - tv_sec_old_3) != 1 ||
(tv_sec % U_ONE_HOUR_IN_SECOND) == 0)
{
@ -479,8 +469,6 @@ void ULog::updateDate3()
U_INTERNAL_DUMP("tv_sec_old_3 = %lu u_now->tv_sec = %lu", tv_sec_old_3, tv_sec)
U_INTERNAL_ASSERT_MINOR(tv_sec_old_3, tv_sec)
if ((tv_sec - tv_sec_old_3) != 1 ||
(tv_sec % U_ONE_HOUR_IN_SECOND) == 0)
{

View File

@ -1057,7 +1057,7 @@ start:
U_INTERNAL_ASSERT(socket->isOpen())
# ifdef DEBUG
UServer_Base::read_again++;
UServer_Base::nread_again++;
# endif
U_RETURN(U_NOTIFIER_OK); // NOT BLOCKING...
@ -1066,6 +1066,10 @@ start:
goto end;
}
#ifdef DEBUG
UServer_Base::nread++;
#endif
U_INTERNAL_ASSERT(socket->isOpen())
rstart = 0;

View File

@ -35,11 +35,9 @@
</script>
<hr>
<div id="chat">
<!--#code
(void) UHTTP::callService(U_STRING_FROM_CONSTANT("servlet/cchat"));
-->
</div>
</body>
</html>

View File

@ -29,8 +29,7 @@ uint32_t sz = strings.size();
<p><table border=1>
<tr><th colspan=2>Strings entered so far: <!--#number sz --></th></tr>
<!--#code
<!--#code
UString item;
for (uint32_t i = 0; i < sz; ++i)
@ -39,8 +38,7 @@ uint32_t sz = strings.size();
USP_PRINTF("<tr><td>%v</td><td><a href=\"?remove=%u\">remove</a></td></tr>", item.rep, i);
}
-->
-->
</table></p>
</body>
</html>

View File

@ -489,27 +489,31 @@ public:
}
else
{
if (http_header.find(*UString::str_content_type) != U_NOT_FOUND)
{
(void) xoutput.append(U_CONSTANT_TO_PARAM("\n\t\tU_http_content_type_len = 1;\n\t"));
}
// NB: we use insert because the possibility of UHTTP::callService() (see chat.usp)...
if (http_header.find(*UString::str_content_type) != U_NOT_FOUND) (void) xoutput.append(U_CONSTANT_TO_PARAM("\n\t\tU_http_content_type_len = 1;\n\t"));
UString header = UStringExt::dos2unix(http_header, true);
(void) header.append(U_CONSTANT_TO_PARAM("\r\n\r\n"));
UString encoded(header.size() * 4);
n = header.size();
U_INTERNAL_DUMP("n = %u", size)
UString encoded(n * 4);
UEscape::encode(header, encoded);
UString tmp(encoded.size() + 100U);
U_ASSERT(encoded.isQuoted())
tmp.snprintf("\n\t\t(void) UClientImage_Base::wbuffer->append(\n\t\t\tU_CONSTANT_TO_PARAM(%v));\n\t", encoded.rep);
UString tmp(encoded.size() + 200U);
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);
(void) x.append(tmp);
(void) x.append(U_CONSTANT_TO_PARAM("\n\t\tU_http_info.endHeader = UClientImage_Base::wbuffer->size();\n"));
}
http_header = x;
@ -548,7 +552,7 @@ public:
if (bparallelization) ptr7 = "\t\n\t\tif (UServer_Base::startParallelization(UServer_Base::num_client_for_parallelization)) return;\n\t\n";
UString result(800U + sizeof(USP_TEMPLATE) + declaration.size() + http_header.size() + output.size() + output1.size() + xoutput.size());
UString result(1024U + sizeof(USP_TEMPLATE) + declaration.size() + http_header.size() + output.size() + output1.size() + xoutput.size());
result.snprintf(USP_TEMPLATE,
size, ptr,
@ -568,7 +572,7 @@ public:
ptr6,
ptr7,
http_header.rep,
bform ? "\t\n\t\t(void) UHTTP::processForm();\n" : "",
bform ? "\t\n\t\tif (UHTTP::isGETorPOST()) (void) UHTTP::processForm();\n" : "",
output.rep,
output1.rep,
xoutput.rep,

View File

@ -101,9 +101,10 @@ char* UServer_Base::client_address;
ULock* UServer_Base::lock_user1;
ULock* UServer_Base::lock_user2;
time_t UServer_Base::last_event;
uint32_t UServer_Base::nread;
uint32_t UServer_Base::map_size;
uint32_t UServer_Base::max_depth;
uint32_t UServer_Base::read_again;
uint32_t UServer_Base::nread_again;
uint32_t UServer_Base::vplugin_size;
uint32_t UServer_Base::nClientIndex;
uint32_t UServer_Base::shared_data_add;
@ -1906,10 +1907,10 @@ RETSIGTYPE UServer_Base::handlerForSigTERM(int signo)
"SIGTERM (Interrupt): "
"address space usage: %.2f MBytes - "
"rss usage: %.2f MBytes\n"
"max_nfd_ready = %u max_depth = %u read_again = %u wakeup_for_nothing = %u\n",
"max_nfd_ready = %u max_depth = %u again:read = (%u/%u - %u%%) wakeup_for_nothing = %u\n",
(double)vsz / (1024.0 * 1024.0),
(double)rss / (1024.0 * 1024.0), UNotifier::max_nfd_ready,
(max_depth > UNotifier::min_connection ? max_depth - UNotifier::min_connection : 0), read_again, wakeup_for_nothing);
(max_depth > UNotifier::min_connection ? max_depth - UNotifier::min_connection : 0), nread_again, nread, (nread_again*100)/nread, wakeup_for_nothing);
ostrstream os(buffer + len, sizeof(buffer) - len);
@ -2133,6 +2134,10 @@ try_accept:
}
# endif
# ifdef U_EPOLLET_POSTPONE_STRATEGY
if (CSOCKET->iState == -EAGAIN) U_ClientImage_state = U_PLUGIN_HANDLER_AGAIN;
# endif
goto end;
}

View File

@ -13,7 +13,9 @@
#include <ulib/notifier.h>
#include <ulib/net/socket.h>
#include <ulib/internal/chttp.h>
#include <ulib/utility/interrupt.h>
#include <ulib/net/server/server_plugin.h>
#if defined(ENABLE_THREAD) && defined(U_SERVER_THREAD_APPROACH_SUPPORT)
# include "ulib/thread.h"
@ -28,28 +30,28 @@ UEventTime* UNotifier::time_obj;
#include <errno.h>
/*
typedef union epoll_data {
void* ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;
struct epoll_event {
uint32_t events; // Epoll events
epoll_data_t data; // User data variable
};
struct epoll_ctl_cmd {
int flags; // Reserved flags for future extension, must be 0
int op; // The same as epoll_ctl() op parameter
int fd; // The same as epoll_ctl() fd parameter
uint32_t events; // The same as the "events" field in struct epoll_event
uint64_t data; // The same as the "data" field in struct epoll_event
int error_hint; // Output field, will be set to the return code after this command is executed by kernel
};
*/
/**
* typedef union epoll_data {
* void* ptr;
* int fd;
* uint32_t u32;
* uint64_t u64;
* } epoll_data_t;
*
* struct epoll_event {
* uint32_t events; // Epoll events
* epoll_data_t data; // User data variable
* };
*
* struct epoll_ctl_cmd {
* int flags; // Reserved flags for future extension, must be 0
* int op; // The same as epoll_ctl() op parameter
* int fd; // The same as epoll_ctl() fd parameter
* uint32_t events; // The same as the "events" field in struct epoll_event
* uint64_t data; // The same as the "data" field in struct epoll_event
* int error_hint; // Output field, will be set to the return code after this command is executed by kernel
* };
*/
#ifdef HAVE_EPOLL_CTL_BATCH
int UNotifier::ctl_cmd_cnt;
@ -81,7 +83,9 @@ int UNotifier::fd_write_cnt;
fd_set UNotifier::fd_set_read;
fd_set UNotifier::fd_set_write;
#endif
#ifdef U_EPOLLET_POSTPONE_STRATEGY
bool UNotifier::bepollet;
#endif
int UNotifier::nfd_ready; // the number of file descriptors ready for the requested I/O
int UNotifier::max_nfd_ready;
bool UNotifier::bread;
@ -665,12 +669,39 @@ U_NO_EXPORT void UNotifier::notifyHandlerEvent()
{
U_INTERNAL_DUMP("num_connection = %u", num_connection)
if (LIKELY(handler_event->fd != -1)) handlerDelete(handler_event);
# ifdef HAVE_EPOLL_WAIT
U_INTERNAL_ASSERT_EQUALS(handler_event, pevents->data.ptr)
# endif
if (LIKELY(handler_event->fd != -1)) handlerDelete(handler_event);
# ifdef U_EPOLLET_POSTPONE_STRATEGY
goto decrement;
# endif
# endif
}
#ifdef U_EPOLLET_POSTPONE_STRATEGY
U_INTERNAL_DUMP("U_ClientImage_state = %d %B", U_ClientImage_state, U_ClientImage_state)
if (U_ClientImage_state == U_PLUGIN_HANDLER_AGAIN)
{
U_INTERNAL_DUMP("handler_event->fd = %d", handler_event->fd)
U_INTERNAL_ASSERT_MAJOR(handler_event->fd, 0)
if (bepollet)
{
handler_event->fd = -handler_event->fd;
decrement:
U_INTERNAL_DUMP("nfd_ready = %d", nfd_ready)
U_INTERNAL_ASSERT_MAJOR(nfd_ready, 0)
--nfd_ready;
}
}
#endif
}
#endif
@ -701,10 +732,17 @@ void UNotifier::waitForEvent(UEventTime* timeout)
if (LIKELY(nfd_ready > 0))
{
# ifdef HAVE_EPOLL_WAIT
pevents = events + nfd_ready;
loop:
--pevents;
int i, n = nfd_ready;
# ifdef U_EPOLLET_POSTPONE_STRATEGY
bepollet = (n >= 16);
loop1:
# endif
i = 0;
pevents = events;
loop2:
handler_event = (UEventFd*)pevents->data.ptr;
U_INTERNAL_DUMP("handler_event = %p bread = %b bwrite = %b events[%d].events = %d %B", handler_event,
@ -715,7 +753,7 @@ loop:
U_INTERNAL_ASSERT(pevents >= events)
U_INTERNAL_ASSERT_DIFFERS(handler_event, 0)
if (LIKELY(handler_event->fd != -1))
if (handler_event->fd > 0)
{
/**
* EPOLLIN = 0x0001
@ -745,22 +783,53 @@ loop:
handler_event->handlerError();
handler_event->fd = -1;
# ifdef U_EPOLLET_POSTPONE_STRATEGY
U_INTERNAL_DUMP("nfd_ready = %d", nfd_ready)
U_INTERNAL_ASSERT_MAJOR(nfd_ready, 0)
--nfd_ready;
# endif
}
}
if (--nfd_ready) goto loop;
U_INTERNAL_DUMP("i = %d handler_event->fd = %d nfd_ready = %d", i, handler_event->fd, nfd_ready)
U_INTERNAL_DUMP("events[%d]: return", (pevents-events))
++pevents;
U_INTERNAL_ASSERT_EQUALS(pevents, events)
if (++i < n) goto loop2;
U_INTERNAL_ASSERT_EQUALS(pevents-events, n)
# ifdef U_EPOLLET_POSTPONE_STRATEGY
if (bepollet)
{
if (nfd_ready) goto loop1;
U_INTERNAL_ASSERT_EQUALS(nfd_ready, 0)
loop3: --pevents;
handler_event = (UEventFd*)pevents->data.ptr;
if (handler_event->fd < -1) handler_event->fd = -handler_event->fd;
U_INTERNAL_DUMP("i = %d handler_event->fd = %d", i, handler_event->fd)
if (--i) goto loop3;
U_INTERNAL_ASSERT_EQUALS(pevents, events)
}
# endif
# else
int fd, fd_cnt = (fd_read_cnt + fd_write_cnt);
int fd = 1, fd_cnt = (fd_read_cnt + fd_write_cnt);
U_INTERNAL_DUMP("fd_cnt = %d fd_set_max = %d", fd_cnt, fd_set_max)
U_INTERNAL_ASSERT(nfd_ready <= fd_cnt)
for (fd = 1; fd < fd_set_max; ++fd)
for (int i = nfd_ready; fd < fd_set_max; ++fd)
{
bread = (fd_read_cnt && FD_ISSET(fd, &read_set));
@ -770,7 +839,7 @@ loop:
{
notifyHandlerEvent();
if (--nfd_ready == 0)
if (--i == 0)
{
U_INTERNAL_DUMP("fd = %d: return", fd)

View File

@ -14,6 +14,7 @@
#include <ulib/file.h>
#include <ulib/utility/escape.h>
#include <ulib/internal/chttp.h>
#include <ulib/container/vector.h>
#include <ulib/container/hash_map.h>
struct ustring { ustringrep* rep; };
@ -499,31 +500,9 @@ bool UString::shrink()
U_RETURN(false);
}
void UStringRep::release()
void UStringRep::_release()
{
U_TRACE(0, "UStringRep::release()") // problem with sanitize address
U_INTERNAL_DUMP("this = %p parent = %p references = %u child = %d", this, parent, references, child)
#ifdef DEBUG
bool ok = memory.invariant();
if (ok == false)
{
U_ERROR("UStringRep::release() %s - this = %p parent = %p references = %u child = %d _capacity = %u str(%u) = %.*S",
memory.getErrorType(this),
this, parent, references, child, _capacity, _length, _length, str);
}
#endif
if (references)
{
--references;
return;
}
// NB: we don't use delete (dtor) because add a deallocation to the destroy process...
U_TRACE(0, "UStringRep::_release()")
U_INTERNAL_DUMP("_capacity = %u str(%u) = %.*S", _capacity, _length, _length, str)
@ -877,6 +856,25 @@ __pure bool UStringRep::isEndHeader(uint32_t pos) const
U_RETURN(false);
}
__pure bool UStringRep::findEndHeader(uint32_t pos) const
{
U_TRACE(0, "UStringRep::findEndHeader(%u)", pos)
U_CHECK_MEMORY
if (_length)
{
U_INTERNAL_ASSERT_MINOR(pos, _length)
const char* ptr = str + pos;
uint32_t _remain = (_length - pos);
if (u_findEndHeader1(ptr, _remain) != U_NOT_FOUND) U_RETURN(true); /* find sequence of U_CRLF2 */
}
U_RETURN(false);
}
UString::UString(const char* t)
{
U_TRACE_REGISTER_OBJECT_WITHOUT_CHECK_MEMORY(0, UString, "%S", t)
@ -1799,7 +1797,8 @@ void UString::setFromData(const char** p, uint32_t sz, unsigned char delim)
U_INTERNAL_ASSERT_EQUALS(u__isspace(c), false)
if (c == '@')
if (c == '@' &&
UVector<void*>::istream_loading == false)
{
// get content pointed by string 'meta' (that start with '@')

View File

@ -127,14 +127,8 @@ long UTimeVal::restart()
{
U_TRACE(1, "UTimeVal::restart()")
#ifdef DEBUG
long tv_sec_old = u_now->tv_sec;
#endif
(void) U_SYSCALL(gettimeofday, "%p,%p", u_now, 0);
U_INTERNAL_ASSERT(tv_sec_old <= u_now->tv_sec)
struct timeval time_from_last_start = { u_now->tv_sec - tv_sec, u_now->tv_usec - tv_usec };
tv_sec = u_now->tv_sec;
@ -157,14 +151,8 @@ long UTimeVal::stop()
{
U_TRACE(1, "UTimeVal::stop()")
#ifdef DEBUG
long tv_sec_old = u_now->tv_sec;
#endif
(void) U_SYSCALL(gettimeofday, "%p,%p", u_now, 0);
U_INTERNAL_ASSERT(tv_sec_old <= u_now->tv_sec)
struct timeval time_elapsed = { u_now->tv_sec - tv_sec, u_now->tv_usec - tv_usec };
if (time_elapsed.tv_usec < 0L)

View File

@ -17,6 +17,9 @@
#include <ulib/net/server/server.h>
#include <ulib/utility/hpack_huffman_table.h> // huff_sym_table, huff_decode_table
#define HTTP2_FRAME_HEADER_SIZE 9 // The number of bytes of the frame header
#define HTTP2_HEADER_TABLE_OFFSET 62
int UHTTP2::nerror;
bool UHTTP2::settings_ack;
void* UHTTP2::pConnectionEnd;
@ -429,8 +432,6 @@ void UHTTP2::dtor()
U_TRACE(0, "UHTTP2::dtor()")
}
#define HTTP2_FRAME_HEADER_SIZE 9 // The number of bytes of the frame header
void UHTTP2::sendError()
{
U_TRACE(0, "UHTTP2::sendError()")
@ -559,7 +560,7 @@ uint32_t UHTTP2::hpackEncodeString(unsigned char* dst, const char* src, uint32_t
unsigned char* ptr;
const char* src_end = src + len;
UString buffer(len + 1024);
UString buffer(len + 1024U);
unsigned char* _dst = (unsigned char*)buffer.data();
unsigned char* _dst_end = _dst + len;
@ -665,8 +666,6 @@ err: pvalue->clear();
U_RETURN(nmove + len);
}
#define HEADER_TABLE_OFFSET 62
void UHTTP2::decodeHeaders(const char* ptr, const char* endptr)
{
U_TRACE(0, "UHTTP2::decodeHeaders(%p,%p)", ptr, endptr)
@ -739,9 +738,9 @@ error: nerror = COMPRESSION_ERROR;
// determine the header
U_INTERNAL_ASSERT_MINOR(index, HEADER_TABLE_OFFSET) // existing name (and value?)
U_INTERNAL_ASSERT_MINOR(index, HTTP2_HEADER_TABLE_OFFSET) // existing name (and value?)
static const int dispatch_table[HEADER_TABLE_OFFSET] = {
static const int dispatch_table[HTTP2_HEADER_TABLE_OFFSET] = {
0,/* 0 */
(int)((char*)&&case_1-(char*)&&cdefault), /* 1 :authority */
(int)((char*)&&case_2_3-(char*)&&cdefault), /* 2 :method */
@ -1251,12 +1250,14 @@ loop:
U_INTERNAL_DUMP("ptr = %#.4S", ptr) // "\000\000\f\004" (big endian: 0x11223344)
#ifdef DEBUG
if ((frame.type = ptr[3]) > CONTINUATION)
{
nerror = PROTOCOL_ERROR;
return;
}
#endif
frame.length = ntohl(*(uint32_t*)ptr & 0x00ffffff) >> 8;
@ -1286,6 +1287,7 @@ loop:
U_INTERNAL_DUMP("window_size_increment = %u", window_size_increment)
# ifdef DEBUG
if (frame.length != 4 ||
window_size_increment == 0)
{
@ -1293,6 +1295,7 @@ loop:
goto err;
}
# endif
if (frame.stream_id) pStream->output_window += window_size_increment;
else pConnection->output_window += window_size_increment;
@ -1306,12 +1309,14 @@ loop:
{
if ((frame.flags & FLAG_ACK) != 0)
{
# ifdef DEBUG
if (frame.length)
{
nerror = FRAME_SIZE_ERROR;
goto err;
}
# endif
settings_ack = true;
}
@ -1425,12 +1430,14 @@ void UHTTP2::manageHeaders()
{
padlen = *ptr++;
# ifdef DEBUG
if (frame.length < padlen)
{
nerror = PROTOCOL_ERROR;
return;
}
# endif
endptr -= padlen;
}
@ -1443,12 +1450,14 @@ void UHTTP2::manageHeaders()
}
else
{
# ifdef DEBUG
if ((frame.length - padlen) < 5)
{
nerror = PROTOCOL_ERROR;
return;
}
# endif
uint32_t u4 = ntohl(*(uint32_t*)ptr);
ptr += 4;
@ -1472,6 +1481,7 @@ void UHTTP2::manageHeaders()
wait_CONTINUATION:
readFrame();
# ifdef DEBUG
if (nerror != NO_ERROR ||
frame.type != CONTINUATION ||
frame.stream_id != pStream->id)
@ -1480,6 +1490,7 @@ wait_CONTINUATION:
return;
}
# endif
(void) bufferHeaders.append(frame.payload, frame.length);
@ -1504,19 +1515,20 @@ void UHTTP2::manageData()
return;
}
uint32_t sz;
int32_t padlen;
const char* ptr;
const char* endptr = (ptr = frame.payload) + frame.length;
const char* ptr = frame.payload;;
int32_t padlen = *ptr;
const char* endptr = ptr + frame.length;
if (frame.length < (padlen = *ptr++))
#ifdef DEBUG
if (frame.length < padlen)
{
nerror = PROTOCOL_ERROR;
return;
}
#endif
sz = (endptr - padlen) - ptr;
uint32_t sz = (endptr - padlen) - ++ptr;
U_INTERNAL_ASSERT(sz <= U_http_info.clength)

View File

@ -304,7 +304,7 @@ UString UServices::getUUID()
U_APPEND_HEX(node, 4);
U_APPEND_HEX(node, 5);
#undef U_APPEND_HEX(value, offset)
#undef U_APPEND_HEX
#endif
buffer.size_adjust(36U);

View File

@ -193,6 +193,10 @@ error: U_INTERNAL_DUMP("errno = %d", errno)
goto read;
}
#ifdef U_EPOLLET_POSTPONE_STRATEGY
if (UNotifier::bepollet == false)
#endif
{
if (sk->isBlocking() == false)
{
/**
@ -223,6 +227,7 @@ error: U_INTERNAL_DUMP("errno = %d", errno)
goto read;
}
}
done:
U_INTERNAL_DUMP("byte_read = %d", byte_read)

View File

@ -464,125 +464,131 @@ void UHTTP::in_READ()
union uuinotify_event event;
int i = 0, length = U_SYSCALL(read, "%d,%p,%u", UServer_Base::handler_inotify->fd, buffer, IN_BUFLEN);
while (i < length)
if (length > 0)
{
event.p = buffer + i;
i += sizeof(struct inotify_event);
if (event.ip->len)
while (i < length)
{
wd = event.ip->wd;
mask = event.ip->mask;
len = event.ip->len;
name = event.ip->name;
event.p = buffer + i;
U_INTERNAL_DUMP("The %s %s(%u) was %s", (mask & IN_ISDIR ? "directory" : "file"), name, len,
(mask & IN_CREATE ? "created" :
mask & IN_DELETE ? "deleted" :
mask & IN_MODIFY ? "modified" : "???"))
i += sizeof(struct inotify_event);
// NB: The length contains any potential padding that is, the result of strlen() on the name field may be smaller than len...
while (name[len-1] == '\0') --len;
U_INTERNAL_ASSERT_EQUALS(len, u__strlen(name, __PRETTY_FUNCTION__))
file_data = 0;
if (wd == inotify_wd)
if (event.ip->len)
{
if (inotify_file_data &&
len == inotify_len &&
memcmp(name, inotify_name, len) == 0)
wd = event.ip->wd;
mask = event.ip->mask;
len = event.ip->len;
name = event.ip->name;
U_INTERNAL_DUMP("The %s %s(%u) was %s", (mask & IN_ISDIR ? "directory" : "file"), name, len,
(mask & IN_CREATE ? "created" :
mask & IN_DELETE ? "deleted" :
mask & IN_MODIFY ? "modified" : "???"))
// NB: The length contains any potential padding that is, the result of strlen() on the name field may be smaller than len...
while (name[len-1] == '\0') --len;
U_INTERNAL_ASSERT_EQUALS(len, u__strlen(name, __PRETTY_FUNCTION__))
file_data = 0;
if (wd == inotify_wd)
{
goto next;
}
if (inotify_dir)
{
inotify_len = len;
inotify_name = name;
setInotifyPathname();
goto next;
}
}
inotify_wd = wd;
inotify_len = len;
inotify_name = name;
inotify_dir = 0;
inotify_file_data = 0;
cache_file->callForAllEntry(getInotifyPathDirectory);
next:
if ((mask & IN_CREATE) != 0)
{
if (inotify_file_data == 0) checkFileForCache();
}
else
{
if ((mask & IN_DELETE) != 0)
{
if (inotify_file_data)
if (inotify_file_data &&
len == inotify_len &&
memcmp(name, inotify_name, len) == 0)
{
if (file_data == 0)
{
file_data = cache_file->at(*inotify_pathname);
goto next;
}
U_INTERNAL_ASSERT_EQUALS(file_data, inotify_file_data)
}
if (inotify_dir)
{
inotify_len = len;
inotify_name = name;
cache_file->eraseAfterFind();
setInotifyPathname();
inotify_file_data = 0;
goto next;
}
}
else if ((mask & IN_MODIFY) != 0)
inotify_wd = wd;
inotify_len = len;
inotify_name = name;
inotify_dir = 0;
inotify_file_data = 0;
cache_file->callForAllEntry(getInotifyPathDirectory);
next:
if ((mask & IN_CREATE) != 0)
{
if (inotify_file_data)
if (inotify_file_data == 0) checkFileForCache();
}
else
{
if ((mask & IN_DELETE) != 0)
{
// NB: check if we have the content of file in cache...
if (inotify_file_data->array) inotify_file_data->expire = 0; // NB: we delay the renew...
else
if (inotify_file_data)
{
int fd = inotify_file_data->fd;
if (file_data == 0)
{
file_data = cache_file->at(*inotify_pathname);
U_INTERNAL_ASSERT_EQUALS(file_data, inotify_file_data)
uint32_t sz = inotify_pathname->size();
pathname->setBuffer(sz);
pathname->snprintf("%v", inotify_pathname->rep);
}
cache_file->eraseAfterFind();
checkFileForCache();
inotify_file_data = 0;
}
}
else if ((mask & IN_MODIFY) != 0)
{
if (inotify_file_data)
{
// NB: check if we have the content of file in cache...
if (fd != -1 &&
file->st_ino) // stat() ok...
if (inotify_file_data->array) inotify_file_data->expire = 0; // NB: we delay the renew...
else
{
UFile::close(fd);
int fd = inotify_file_data->fd;
if (file->open()) file_data->fd = file->fd;
if (file_data == 0)
{
file_data = cache_file->at(*inotify_pathname);
U_INTERNAL_ASSERT_EQUALS(file_data, inotify_file_data)
uint32_t sz = inotify_pathname->size();
pathname->setBuffer(sz);
pathname->snprintf("%v", inotify_pathname->rep);
}
cache_file->eraseAfterFind();
checkFileForCache();
if (fd != -1 &&
file->st_ino) // stat() ok...
{
UFile::close(fd);
if (file->open()) file_data->fd = file->fd;
}
}
}
}
}
}
i += event.ip->len;
i += event.ip->len;
}
}
}
#ifdef U_EPOLLET_POSTPONE_STRATEGY
else if (errno == EAGAIN) U_ClientImage_state = U_PLUGIN_HANDLER_AGAIN;
#endif
file_data = 0;
}
@ -2946,7 +2952,6 @@ bool UHTTP::checkIfSourceHasChangedAndCompileUSP()
U_INTERNAL_ASSERT_MAJOR(len, 0)
char buffer[U_PATH_MAX];
char run_dynamic_page[128];
UServletPage* usp_page = (UServletPage*)file_data->ptr;
if (suffix.empty())
@ -2961,16 +2966,14 @@ bool UHTTP::checkIfSourceHasChangedAndCompileUSP()
U_INTERNAL_DUMP("st.st_mtime = %#3D file_data->mtime = %#3D", st.st_mtime, file_data->mtime)
// NB: dlopen() fail if the module name is not prefixed with "./"...
(void) u__snprintf(buffer, sizeof(buffer), "./%.*s.%s", len, ptr, U_LIB_SUFFIX);
usp_page->UDynamic::close();
usp_page->runDynamicPage = 0;
// NB: dlopen() fail if the module name is not prefixed with "./"...
U_INTERNAL_ASSERT(u__strlen(U_LIB_SUFFIX, __PRETTY_FUNCTION__) >= 2)
(void) u__snprintf(buffer, sizeof(buffer), "./%.*s.%s", len, ptr, U_LIB_SUFFIX);
goto compile;
}
@ -2981,30 +2984,34 @@ bool UHTTP::checkIfSourceHasChangedAndCompileUSP()
{
if (U_HTTP_QUERY_STREQ("_nav_")) U_RETURN(false);
++sz; // NB: we must avoid the point '.' before the suffix...
if (usp_page) U_RETURN(true);
usp_page = U_NEW(UHTTP::UServletPage);
// NB: dlopen() fail if the module name is not prefixed with "./"...
U_INTERNAL_ASSERT(u__strlen(U_LIB_SUFFIX, __PRETTY_FUNCTION__) >= 2)
(void) u__snprintf(buffer, sizeof(buffer), "./%.*s%s", len, ptr, U_LIB_SUFFIX);
if (usp_page == 0)
// NB: we must avoid the point '.' before the suffix...
++sz;
--len;
compile:
if (compileUSP(ptr, len) == false)
{
usp_page = U_NEW(UHTTP::UServletPage);
err: setInternalError();
compile: if (compileUSP(ptr, len) == false)
{
err: setInternalError();
if (suffix) delete usp_page;
U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
U_ClientImage_state = U_PLUGIN_HANDLER_ERROR;
U_RETURN(false);
}
U_RETURN(false);
}
if (usp_page->UDynamic::load(buffer) == false) goto err;
char run_dynamic_page[128];
UString file_name = UStringExt::basename(file->getPath());
(void) u__snprintf(run_dynamic_page, sizeof(run_dynamic_page), "runDynamicPage_%.*s", file_name.size() - sz, file_name.data());
@ -3024,8 +3031,6 @@ bool UHTTP::runCGI(bool set_environment)
{
U_TRACE(0, "UHTTP::runCGI(%b)", set_environment)
U_INTERNAL_ASSERT(u_is_cgi(mime_index))
UHTTP::ucgi* cgi = (UHTTP::ucgi*)file_data->ptr;
U_INTERNAL_ASSERT_POINTER(cgi)
@ -3232,11 +3237,18 @@ bool UHTTP::callService(const UString& path) // NB: it is used also by server_pl
U_INTERNAL_ASSERT_POINTER(file_data)
mime_index = file_data->mime_index;
if (u_is_usp(file_data->mime_index))
{
int mime_index_save = mime_index;
if (u_is_usp(mime_index)) ((UServletPage*)(file_data->ptr))->runDynamicPage(0);
((UServletPage*)(file_data->ptr))->runDynamicPage(0);
mime_index = mime_index_save;
}
else
{
U_INTERNAL_ASSERT(u_is_cgi(file_data->mime_index))
if (runCGI(false) == false) U_RETURN(false);
}

View File

@ -22,9 +22,9 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
# PLAINTEXT
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
UMEMPOOL="982,0,0,36,9846,-24,-23,1727,1151"
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="982,0,0,36,9846,-24,-23,1727,1151"
#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
#sed -i "s|CLIENT_THRESHOLD .*|CLIENT_THRESHOLD 4000|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
#sed -i "s|CLIENT_FOR_PARALLELIZATION .*|CLIENT_FOR_PARALLELIZATION 8000|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
@ -58,9 +58,9 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
# JSON
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
#UMEMPOOL="56,0,0,40,150,-24,-13,-20,0"
#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="56,0,0,40,150,-24,-13,-20,0"
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
#sed -i "s|CLIENT_THRESHOLD .*|CLIENT_THRESHOLD 50|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
#sed -i "s|CLIENT_FOR_PARALLELIZATION .*|CLIENT_FOR_PARALLELIZATION 100|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
# ----------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -1,86 +0,0 @@
{
"framework": "ULib",
"tests": [{
"default": {
"setup_file": "setup",
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"framework": "ULib",
"language": "C++",
"orm": "Micro",
"platform": "ULib",
"webserver": "userver_tcp",
"os": "Linux",
"database_os": "Linux",
"display_name": "ULib",
"notes": "",
"versus": ""
},
"mysql": {
"setup_file": "setup_mysql",
"db_url": "/db",
"query_url": "/query?queries=",
"fortune_url": "/fortune",
"update_url": "/update?queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "MySQL",
"framework": "ULib",
"language": "C++",
"orm": "Micro",
"platform": "ULib",
"webserver": "userver_tcp",
"os": "Linux",
"database_os": "Linux",
"display_name": "ULib-mysql",
"notes": "",
"versus": ""
},
"sqlite": {
"setup_file": "setup_sqlite",
"db_url": "/db",
"query_url": "/query?queries=",
"fortune_url": "/fortune",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "SQLite",
"framework": "ULib",
"language": "C++",
"orm": "Micro",
"platform": "ULib",
"webserver": "userver_tcp",
"os": "Linux",
"database_os": "Linux",
"display_name": "ULib-sqlite",
"notes": "",
"versus": ""
},
"postgres": {
"setup_file": "setup_postgres",
"db_url": "/db",
"query_url": "/query?queries=",
"fortune_url": "/fortune",
"update_url": "/update?queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "Postgres",
"framework": "ULib",
"language": "C++",
"orm": "Micro",
"platform": "ULib",
"webserver": "userver_tcp",
"os": "Linux",
"database_os": "Linux",
"display_name": "ULib-postgres",
"notes": "",
"versus": ""
}
}]
}

View File

@ -1,9 +0,0 @@
#!/bin/bash
export UMEMPOOL="136,0,0,85,1160,155,-17,-22,40"
# 1. Change ULib Server configuration
sed -i "s|PREFORK_CHILD .*|PREFORK_CHILD ${MAX_THREADS}|g" ${IROOT}/ULib/benchmark.cfg
# 2. Start ULib Server (userver_tcp)
${IROOT}/ULib/bin/userver_tcp -c ${IROOT}/ULib/benchmark.cfg &

View File

@ -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 benchmark/FrameworkBenchmarks/ULib/userver_tcp.pid

View File

@ -9,7 +9,7 @@ session|Session|example of a session
strings|Strings|sample application, which uses session to collect input from the client
upload|Upload|how to upload files
chat|Chat|simple chat-program using ajax
remove|RemoveSessionCookie|you need to run this before to run the demos that use a session cookie
remove|RemoveSessionCookie|YOU NEED TO RUN THIS BEFORE TO RUN THE DEMOS THAT USE A SESSION COOKIE
json|Test 1 - JSON serialization|This test exercises the framework fundamentals including keep-alive support, request routing, request header parsing, object instantiation, JSON serialization, response header generation, and request count throughput
db|Test 2 - Single database query|This test exercises the framework's object-relational mapper (ORM), random number generator, database driver, and database connection pool
query|Test 3 - Multiple database queries|This test is a variation of Test #2 and also uses the World table. Multiple rows are fetched to more dramatically punish the database driver and connection pool. At the highest queries-per-request tested (20), this test demonstrates all frameworks' convergence toward zero requests-per-second as database activity increases

View File

@ -203,24 +203,18 @@ export UMEMPOOL="136,0,60,100,250,-22,-17,-23,60"
# webserver-1
creat_config -1
start_test $NCAT localhost
#exit 0
# webserver0
creat_config 0
start_test $NCAT localhost
#exit 0
# webserver1
creat_config 1
start_test $NCAT localhost
#exit 0
# webserver2
creat_config 2
start_test $NCAT localhost
#exit 0
# webserver2
# webserverN
creat_config N 2
start_test $NCAT localhost
#exit 0
# webserverV
creat_config V 2
start_test $NCAT www.sito1.com

View File

@ -9,7 +9,7 @@ rm -f rdb_server.log
start_msg rdb_server
start_msg rdb_client
#UTRACE="0 50M 0"
#UTRACE="0 50M -1"
#UOBJDUMP="0 10M 100"
#USIMERR="error.sim"
export UTRACE UOBJDUMP USIMERR

View File

@ -29,11 +29,12 @@ inline void u_destroy(const Product** ptr, uint32_t n)
U_TRACE(0, "u_destroy<Product>(%p,%u)", ptr, n)
}
/*
NB: used by method
void assign(unsigned n, T* elem))
void erase(unsigned first, unsigned last)
*/
/**
* NB: used by method
*
* void assign(unsigned n, T* elem))
* void erase(unsigned first, unsigned last)
*/
static void check_vector_destructor()
{
@ -52,29 +53,29 @@ static void check(UVector<UString>& y)
unsigned n;
UString tmp;
/* input
[
ROOT_DN 0
PASSWORD 1
ROOT_DN_MAIL 2
PASSWORD_MAIL 3
CHECK_QUOTING 4
LDAP_SERVER_ADDRESS 5
LOG_FILE 6
LDAP_SERVER_ADDRESS_MAIL 7
ADMIN_DN 8
ADMIN_DN_MAIL 9
TIME_SLEEP_LDAP_ERROR 10
TIME_SLEEP_MQSERIES_ERROR 11
FILE_WRONG_MESSAGE 12
MAILDELIVERYOPTION 13
MESSAGE_QUEUE_SERVER 14
MESSAGE_QUEUE_MANAGER 15
MAILHOST 16
MESSAGE_QUEUE_NAME 17
MAX_ERROR_FOR_CONNECT 18
]
*/
/**
* input [
* ROOT_DN 0
* PASSWORD 1
* ROOT_DN_MAIL 2
* PASSWORD_MAIL 3
* CHECK_QUOTING 4
* LDAP_SERVER_ADDRESS 5
* LOG_FILE 6
* LDAP_SERVER_ADDRESS_MAIL 7
* ADMIN_DN 8
* ADMIN_DN_MAIL 9
* TIME_SLEEP_LDAP_ERROR 10
* TIME_SLEEP_MQSERIES_ERROR 11
* FILE_WRONG_MESSAGE 12
* MAILDELIVERYOPTION 13
* MESSAGE_QUEUE_SERVER 14
* MESSAGE_QUEUE_MANAGER 15
* MAILHOST 16
* MESSAGE_QUEUE_NAME 17
* MAX_ERROR_FOR_CONNECT 18
* ]
*/
tmp = y.front();
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("ROOT_DN") )
@ -236,16 +237,27 @@ U_EXPORT main (int argc, char* argv[])
U_TRACE(5,"main(%d)",argc)
UString tmp;
UVector<UString> v0(U_STRING_FROM_CONSTANT("[\"\" 0 @PIPPO]"));
uint32_t n = v0.size();
U_INTERNAL_ASSERT( n == 3 )
tmp = v0[0];
U_ASSERT( tmp.isNull() )
tmp = v0[1];
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("0") )
tmp = v0[2];
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("@PIPPO") )
UString content = UFile::contentOf("inp/wifi-utilizzo");
UVector<UString> vec1(content, '\n'), vec2(4);
uint32_t n = vec1.size();
U_ASSERT( n == 2 )
n = vec1.size();
U_INTERNAL_ASSERT( n == 2 )
n = vec2.split(vec1[0], ',');
vec1.clear();
U_ASSERT( n == 4 )
UString tmp = vec2[0];
U_INTERNAL_ASSERT( n == 4 )
tmp = vec2[0];
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("\"2013/09/11\"") )
tmp = U_STRING_FROM_CONSTANT("museoGalileoLungarno-r29587_locoM2 10.8.0.110\n"
@ -255,18 +267,18 @@ U_EXPORT main (int argc, char* argv[])
vec2.clear();
n = vec2.split(tmp);
U_ASSERT( n == 8 )
U_INTERNAL_ASSERT( n == 8 )
n = vec2.findSorted(U_STRING_FROM_CONSTANT("museoGalileoLungarno-r29587_locoM2"), true, true);
U_ASSERT( n == 0 )
U_INTERNAL_ASSERT( n == 0 )
n = vec2.findSorted(U_STRING_FROM_CONSTANT("orSmichele-r29587_picoM2"), false, true);
U_ASSERT( n == 2 )
U_INTERNAL_ASSERT( n == 2 )
n = vec2.findSorted(U_STRING_FROM_CONSTANT("paasBracci-r29587_picoM2"), true, true);
U_ASSERT( n == 4 )
U_INTERNAL_ASSERT( n == 4 )
n = vec2.findSorted(U_STRING_FROM_CONSTANT("paasBronzino-r29587_picoM2"), false, true);
U_ASSERT( n == 6 )
U_INTERNAL_ASSERT( n == 6 )
n = vec2.findSorted(U_STRING_FROM_CONSTANT("paasBronzino"), true, true);
U_ASSERT( n == U_NOT_FOUND )
U_INTERNAL_ASSERT( n == U_NOT_FOUND )
vec2.clear();
@ -275,19 +287,7 @@ U_EXPORT main (int argc, char* argv[])
y.sort(false);
uint32_t i = y.findSorted(U_STRING_FROM_CONSTANT("NULL"));
U_ASSERT( i == U_NOT_FOUND )
/*
i = y.findSorted(U_STRING_FROM_CONSTANT("10sne1"));
U_ASSERT( i == 12 )
i = y.findSorted(U_STRING_FROM_CONSTANT("dakota"));
U_ASSERT( i == 917 )
i = y.findSorted(U_STRING_FROM_CONSTANT("victoria"));
U_ASSERT( i == 2955 )
i = y.findSorted(U_STRING_FROM_CONSTANT("zzz"));
U_ASSERT( i == 3105 )
i = y.findSorted(U_STRING_FROM_CONSTANT("!@#$%"));
U_ASSERT( i == 0 )
*/
U_INTERNAL_ASSERT( i == U_NOT_FOUND )
for (i = 0, n = y.size(); i < n; ++i) { U_ASSERT( i == y.findSorted(y[i]) ) }
@ -313,7 +313,7 @@ U_EXPORT main (int argc, char* argv[])
n = dirwalk.walk(y);
U_ASSERT( n == 3 )
U_INTERNAL_ASSERT( n == 3 )
}
y.sort();
@ -328,58 +328,14 @@ U_EXPORT main (int argc, char* argv[])
y.clear();
bool res = y.empty();
U_ASSERT( res == true )
/*
UString key(U_CAPACITY);
unsigned i, j, k = 0;
// char ctmp[] = " "; // sizeof(tmp) == 53
char ctmp[53];
memset(ctmp, 'a', sizeof(ctmp)-1);
ctmp[52] = '\0';
for (i = 1; i < sizeof(ctmp) - 1; ++i)
{
for (j = 35; j < 122; ++j)
{
ctmp[i] = j;
key.replace(ctmp, sizeof(ctmp));
y.push_back(key);
k = u_random(k);
ctmp[1 + k % (sizeof(ctmp)-1)] = 35 + k % (122 - 35);
key.replace(ctmp, sizeof(ctmp));
y.push_back(key);
}
}
y.sort(false);
n = y.findSorted(U_STRING_FROM_CONSTANT("NULL"));
U_ASSERT( n == U_NOT_FOUND )
n = y.findSorted(U_STRING_FROM_CONSTANT("a$n5;FyAsX*;UGu(T0\\UaxwbV\%el4wZ,QeVqg3L\\],_O&---3PXg#"));
U_ASSERT( n == 4 )
n = y.findSorted(U_STRING_FROM_CONSTANT("axc`)dX,1Xs:M[nlH+*whM(*ff4;&TAFM%Ubd&-Y=F(x(4Q/Hw;pc"));
U_ASSERT( n == 8612 )
n = y.findSorted(U_STRING_FROM_CONSTANT("ayyuf;I=FLC?)G4<^$gftBB+P/1A]`L,I0^>@Y*71d0SDH^ '2E 7"));
U_ASSERT( n == 8873 )
ofstream outf("vector1.sort");
outf << y;
*/
U_INTERNAL_ASSERT(res)
y.clear();
UString yA = U_STRING_FROM_CONSTANT("\n\n# comment line\n\nriga_0\nriga_1\n\n");
n = y.split(yA);
U_ASSERT( n == 2 )
U_INTERNAL_ASSERT( n == 2 )
tmp = y[0];
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("riga_0") )
tmp = y[1];
@ -388,7 +344,7 @@ U_EXPORT main (int argc, char* argv[])
UString y0 = U_STRING_FROM_CONSTANT("word \"word with space\"");
n = y.split(y0);
U_ASSERT( n == 2 )
U_INTERNAL_ASSERT( n == 2 )
tmp = y[2];
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("word") )
tmp = y[3];
@ -397,7 +353,7 @@ U_EXPORT main (int argc, char* argv[])
UString x = U_STRING_FROM_CONSTANT(" word \"word with space\" ");
n = y.split(x);
U_ASSERT( n == 2 )
U_INTERNAL_ASSERT( n == 2 )
tmp = y[4];
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("word") )
tmp = y[5];
@ -408,12 +364,12 @@ U_EXPORT main (int argc, char* argv[])
y.clear();
res = y.empty();
U_ASSERT( res == true )
U_INTERNAL_ASSERT( res )
UString y2 = U_STRING_FROM_CONSTANT("$Version=\"1\";\n Part_Number=\"Riding_Rocket_0023\"; $Path=\"/acme/ammo\";\n Part_Number=\"Rocket_Launcher_0001\"; $Path=\"/acme\"");
n = y.split(y2, "=;, \n");
U_ASSERT( n == 10 )
U_INTERNAL_ASSERT( n == 10 )
tmp = y[0];
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("$Version") )
@ -450,7 +406,7 @@ U_EXPORT main (int argc, char* argv[])
y.clear();
res = y.empty();
U_ASSERT( res == true )
U_INTERNAL_ASSERT( res )
// BINARY HEAP
@ -522,7 +478,7 @@ U_EXPORT main (int argc, char* argv[])
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("riga 11") )
res = y.empty();
U_ASSERT( res == true )
U_INTERNAL_ASSERT( res )
tmp = U_STRING_FROM_CONSTANT("[ \"riga 1\" \"riga 2\" \"riga 3\" \"riga 4\" ]");
@ -568,12 +524,6 @@ U_EXPORT main (int argc, char* argv[])
tmp = U_STRING_FROM_CONSTANT("riga 4");
y1.put(tmp);
/*
U_ASSERT( y1.put(U_STRING_FROM_CONSTANT("riga 5")) == false )
U_ASSERT( y1.put(U_STRING_FROM_CONSTANT("riga 6")) == false )
U_ASSERT( y1.put(U_STRING_FROM_CONSTANT("riga 7")) == false )
*/
y1.get(tmp);
U_ASSERT( tmp == U_STRING_FROM_CONSTANT("riga 1") )
y1.get(tmp);