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

SSE implementation

This commit is contained in:
stefanocasazza 2017-12-05 17:33:34 +01:00
parent 2eb6736227
commit eeac9aca71
42 changed files with 8720 additions and 8341 deletions

View File

@ -44,6 +44,7 @@ The current version offers the following features :
* Support for running natively PHP applications whith a php (embedded) library (experimental). * Support for running natively PHP applications whith a php (embedded) library (experimental).
* Support for load balance between physical server via udp brodcast (experimental). * Support for load balance between physical server via udp brodcast (experimental).
* Support for serialize object by [FlatBuffer schema-less](http://google.github.io/flatbuffers/index.html) like implementation. * Support for serialize object by [FlatBuffer schema-less](http://google.github.io/flatbuffers/index.html) like implementation.
* Support for [SSE (Server Sent Event)](http://en.wikipedia.org/wiki/Server-sent_events) via ULib Servlet Page (USP) dedicate process.
* Preforking mode to improve concurrency with dedicated process for long-time request. * Preforking mode to improve concurrency with dedicated process for long-time request.
* Support for Windows (without preforking). * Support for Windows (without preforking).
* Customizable builds (you can remove unneeded functionality). * Customizable builds (you can remove unneeded functionality).

24
configure vendored
View File

@ -1060,6 +1060,7 @@ enable_log
enable_GSDS enable_GSDS
enable_HCRS enable_HCRS
enable_HPRS enable_HPRS
enable_SSE
enable_http2 enable_http2
enable_check_time enable_check_time
enable_classic enable_classic
@ -1804,6 +1805,7 @@ Optional Features:
--enable-GSDS enable GDB Stack Dump Support [default=no] --enable-GSDS enable GDB Stack Dump Support [default=no]
--enable-HCRS enable Cache Request Support [default=no] --enable-HCRS enable Cache Request Support [default=no]
--enable-HPRS enable Homogeneous Pipeline Request Support [default=no] --enable-HPRS enable Homogeneous Pipeline Request Support [default=no]
--enable-SSE enable Server-Sent Events Support [default=yes]
--enable-http2 enable HTTP/2 support [default=no] --enable-http2 enable HTTP/2 support [default=no]
--enable-check-time enable server check time between request for parallelization [default=no] --enable-check-time enable server check time between request for parallelization [default=no]
--enable-classic enable server classic model support [default=no] --enable-classic enable server classic model support [default=no]
@ -28326,6 +28328,28 @@ $as_echo "#define U_PIPELINE_HOMOGENEOUS_DISABLE 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_HPRS" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_HPRS" >&5
$as_echo "$enable_HPRS" >&6; } $as_echo "$enable_HPRS" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to enable Server-Sent Events support" >&5
$as_echo_n "checking if you want to enable Server-Sent Events support... " >&6; }
# Check whether --enable-SSE was given.
if test "${enable_SSE+set}" = set; then :
enableval=$enable_SSE;
fi
if test -z "$enable_SSE"; then
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_SSE="no"
else
enable_SSE="yes"
fi
fi
if test "$enable_SSE" = "yes"; then
$as_echo "#define U_SSE_ENABLE 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_SSE" >&5
$as_echo "$enable_SSE" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to enable HTTP/2 support" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if you want to enable HTTP/2 support" >&5
$as_echo_n "checking if you want to enable HTTP/2 support... " >&6; } $as_echo_n "checking if you want to enable HTTP/2 support... " >&6; }
# Check whether --enable-http2 was given. # Check whether --enable-http2 was given.

View File

@ -61,7 +61,6 @@ extern U_EXPORT void runDynamicPage_ir_web(int param);
{ {
U_TRACE(0, "::runDynamicPage_ir_web(%d)", param) U_TRACE(0, "::runDynamicPage_ir_web(%d)", param)
if (param) if (param)
{ {
if (param == U_DPAGE_INIT) { usp_init_ir_web(); return; } if (param == U_DPAGE_INIT) { usp_init_ir_web(); return; }

View File

@ -14,7 +14,6 @@ extern U_EXPORT void runDynamicPage_wi_auth(int param);
{ {
U_TRACE(0, "::runDynamicPage_wi_auth(%d)", param) U_TRACE(0, "::runDynamicPage_wi_auth(%d)", param)
if (param) if (param)
{ {
if (param == U_DPAGE_INIT) { usp_init_wi_auth(); return; } if (param == U_DPAGE_INIT) { usp_init_wi_auth(); return; }

View File

@ -258,8 +258,13 @@ typedef enum {
U_HASH_RIPEMD160 = 9 U_HASH_RIPEMD160 = 9
} UHashType; } UHashType;
#if SIZEOF_LONG == 4
# define U_INT2PTR(x) ((void*)(long)(x))
#else
# define U_INT2PTR(x) ((void*)((long)(x) & 0x00000000FFFFFFFFULL))
#endif
#define U_PTR2INT(x) ((unsigned int)(long)x) #define U_PTR2INT(x) ((unsigned int)(long)x)
#define U_INT2PTR(x) ( (void*)(long)x)
union uucflag { union uucflag {
unsigned char c[4]; unsigned char c[4];

View File

@ -868,6 +868,9 @@
/* enable server thread approach support */ /* enable server thread approach support */
#undef U_SERVER_THREAD_APPROACH_SUPPORT #undef U_SERVER_THREAD_APPROACH_SUPPORT
/* enable Server-Sent Events support */
#undef U_SSE_ENABLE
/* STATIC_HANDLER_ECHO */ /* STATIC_HANDLER_ECHO */
#undef U_STATIC_HANDLER_ECHO #undef U_STATIC_HANDLER_ECHO

View File

@ -6,6 +6,10 @@
typedef _Bool bool; typedef _Bool bool;
#endif #endif
#ifndef _SYS_SYSMACROS_H_OUTER
#define _SYS_SYSMACROS_H_OUTER 1
#endif
#define U_CSP_INTERFACE #define U_CSP_INTERFACE
#include <ulib/base/base.h> #include <ulib/base/base.h>
#include <ulib/internal/chttp.h> #include <ulib/internal/chttp.h>

View File

@ -289,8 +289,20 @@ public:
union jval getKey() const { return pkey; } union jval getKey() const { return pkey; }
int64_t getInt64() const { return -(long)getPayload(); } uint64_t getUInt64() const
uint64_t getUInt64() const { return (long)getPayload(); } {
U_TRACE_NO_PARAM(0, "UValue::getUInt64()")
uint64_t n = u_getPayload(value.ival);
U_INTERNAL_DUMP("n = %llu", n)
U_INTERNAL_ASSERT(n <= 140737488355327ULL)
U_RETURN(n);
}
int64_t getInt64() const { return -getUInt64(); }
UString getString() { return getString(value.ival); } UString getString() { return getString(value.ival); }
@ -958,21 +970,12 @@ protected:
U_INTERNAL_DUMP("o.ival = %llu", o.ival) U_INTERNAL_DUMP("o.ival = %llu", o.ival)
} }
#if SIZEOF_LONG == 4 static void setValue(uint8_t tag, char* pval) { setValue(tag, U_INT2PTR(*pval)); }
static void setValue(uint8_t tag, char* pval) { setValue(tag, (void*)*pval); } static void setValue(uint8_t tag, unsigned char* pval) { setValue(tag, U_INT2PTR(*pval)); }
static void setValue(uint8_t tag, unsigned char* pval) { setValue(tag, (void*)*pval); } static void setValue(uint8_t tag, short* pval) { setValue(tag, U_INT2PTR(*pval)); }
static void setValue(uint8_t tag, short* pval) { setValue(tag, (void*)*pval); } static void setValue(uint8_t tag, unsigned short* pval) { setValue(tag, U_INT2PTR(*pval)); }
static void setValue(uint8_t tag, unsigned short* pval) { setValue(tag, (void*)*pval); } static void setValue(uint8_t tag, int* pval) { setValue(tag, U_INT2PTR(*pval)); }
static void setValue(uint8_t tag, int* pval) { setValue(tag, (void*)*pval); } static void setValue(uint8_t tag, unsigned int* pval) { setValue(tag, U_INT2PTR(*pval)); }
static void setValue(uint8_t tag, unsigned int* pval) { setValue(tag, (void*)*pval); }
#else
static void setValue(uint8_t tag, char* pval) { setValue(tag, (void*)(*pval & 0x00000000FFFFFFFFULL)); }
static void setValue(uint8_t tag, unsigned char* pval) { setValue(tag, (void*)(*pval & 0x00000000FFFFFFFFULL)); }
static void setValue(uint8_t tag, short* pval) { setValue(tag, (void*)(*pval & 0x00000000FFFFFFFFULL)); }
static void setValue(uint8_t tag, unsigned short* pval) { setValue(tag, (void*)(*pval & 0x00000000FFFFFFFFULL)); }
static void setValue(uint8_t tag, int* pval) { setValue(tag, (void*)(*pval & 0x00000000FFFFFFFFULL)); }
static void setValue(uint8_t tag, unsigned int* pval) { setValue(tag, (void*)(*pval & 0x00000000FFFFFFFFULL)); }
#endif
static void setUInt64(uint64_t l) static void setUInt64(uint64_t l)
{ {

View File

@ -103,7 +103,7 @@ class UFlatBuffer;
template <class T> class UFlatBufferTypeHandler; template <class T> class UFlatBufferTypeHandler;
class U_NO_EXPORT UFlatBufferValue { class U_EXPORT UFlatBufferValue {
public: public:
/** /**
@ -337,6 +337,8 @@ protected:
} }
private: private:
UFlatBufferValue() {}
friend class UFlatBuffer; friend class UFlatBuffer;
U_DISALLOW_COPY_AND_ASSIGN(UFlatBufferValue) U_DISALLOW_COPY_AND_ASSIGN(UFlatBufferValue)
@ -355,6 +357,11 @@ public:
UFlatBuffer() UFlatBuffer()
{ {
U_TRACE_REGISTER_OBJECT(0, UFlatBuffer, "", 0) U_TRACE_REGISTER_OBJECT(0, UFlatBuffer, "", 0)
// coverity[uninit_ctor]
# ifdef U_COVERITY_FALSE_POSITIVE
reset();
# endif
} }
~UFlatBuffer() ~UFlatBuffer()
@ -364,6 +371,17 @@ public:
// SERVICES // SERVICES
void reset()
{
U_TRACE_NO_PARAM(0, "UFlatBuffer::reset()")
data_ = U_NULLPTR;
buffer_idx = 0;
type_ = UFlatBufferValue::TYPE_NULL;
byte_width_ =
parent_width_ = UFlatBufferValue::BIT_WIDTH_8;
}
uint8_t GetType() const { return type_; } uint8_t GetType() const { return type_; }
static bool IsBool(uint8_t type) { return type == UFlatBufferValue::TYPE_BOOL; } static bool IsBool(uint8_t type) { return type == UFlatBufferValue::TYPE_BOOL; }
@ -675,14 +693,11 @@ public:
// Reset all state so we can re-use the buffers // Reset all state so we can re-use the buffers
setStackPointer(stack_idx = buffer_idx = 0); reset();
setStackPointer((stack_idx = 0));
pvalue->reset(); pvalue->reset();
data_ = U_NULLPTR;
type_ = UFlatBufferValue::TYPE_NULL;
byte_width_ =
parent_width_ = UFlatBufferValue::BIT_WIDTH_8;
} }
uint32_t EndBuild() uint32_t EndBuild()

View File

@ -1213,7 +1213,9 @@ protected:
friend class UFile; friend class UFile;
friend class UHTTP2; friend class UHTTP2;
friend class UValue; friend class UValue;
friend class UServices;
friend class UStringExt; friend class UStringExt;
friend class USocketExt;
friend class UClientImage_Base; friend class UClientImage_Base;
friend class UREDISClient_Base; friend class UREDISClient_Base;
@ -1243,7 +1245,7 @@ protected:
void setFromData(const char** ptr, uint32_t sz, unsigned char delim); void setFromData(const char** ptr, uint32_t sz, unsigned char delim);
public: public:
// mutable // mutable
UStringRep* rep; UStringRep* rep;
// SERVICES // SERVICES
@ -1306,6 +1308,23 @@ protected:
U_INTERNAL_ASSERT(invariant()) U_INTERNAL_ASSERT(invariant())
} }
uint32_t getReserveNeed(uint32_t n)
{
U_TRACE(0, "UString::getReserveNeed(%u)", n)
uint32_t need = rep->_length + n;
if (need < U_CAPACITY) need = U_CAPACITY;
else if (need > U_CAPACITY)
{
if (need < 2*1024*1024) need = (need * 2) + (PAGESIZE * 2);
need += PAGESIZE; // NB: to avoid duplication on realloc...
}
U_RETURN(need);
}
public: public:
void _assign(UStringRep* r) void _assign(UStringRep* r)
{ {
@ -1620,7 +1639,7 @@ public:
if (rep->space() < n) if (rep->space() < n)
{ {
_reserve(*this, n); _reserve(*this, rep->_length + n);
U_RETURN(true); // return true if it has changed rep... U_RETURN(true); // return true if it has changed rep...
} }
@ -1628,7 +1647,23 @@ public:
U_RETURN(false); U_RETURN(false);
} }
static void _reserve(UString& buffer, uint32_t n); static void _reserve(UString& buffer, uint32_t n)
{
U_TRACE(0, "UString::_reserve(%V,%u)", buffer.rep, n)
UStringRep* rep = buffer.rep;
U_INTERNAL_DUMP("rep = %p rep->parent = %p rep->references = %u rep->child = %d rep->_length = %u rep->_capacity = %u",
rep, rep->parent, rep->references, rep->child, rep->_length, rep->_capacity)
U_ASSERT(rep->space() < n)
U_INTERNAL_ASSERT(n <= max_size())
U_INTERNAL_ASSERT_MAJOR(n, rep->_length)
buffer._set(UStringRep::create(rep->_length, n, rep->str));
U_INTERNAL_ASSERT(buffer.invariant())
}
// Element access // Element access
@ -1637,8 +1672,8 @@ public:
char* pend() const { return rep->pend(); } char* pend() const { return rep->pend(); }
// operator const char *() const { return rep->data(); } // operator const char *() const { return rep->data(); }
// operator char *() { return rep->data(); } // operator char *() { return rep->data(); }
// Modifiers // Modifiers
@ -2061,7 +2096,25 @@ public:
} }
void setBuffer(uint32_t n); void setBuffer(uint32_t n);
void moveToBeginDataInBuffer(uint32_t n);
void moveToBeginDataInBuffer(uint32_t n)
{
U_TRACE(1, "UString::moveToBeginDataInBuffer(%u)", n)
U_INTERNAL_ASSERT_MAJOR(rep->_length, n)
U_INTERNAL_ASSERT_RANGE(1, n, max_size())
U_INTERNAL_ASSERT_MAJOR(rep->_capacity, n)
# if defined(DEBUG) && !defined(U_SUBSTR_INC_REF)
U_INTERNAL_ASSERT(rep->references == 0)
# endif
rep->_length -= n;
(void) U_SYSCALL(memmove, "%p,%p,%u", (void*)rep->str, rep->str + n, rep->_length);
U_INTERNAL_ASSERT(invariant())
}
static vpFpcu printValueToBuffer; static vpFpcu printValueToBuffer;
@ -2179,7 +2232,7 @@ public:
{ {
U_TRACE(0, "UString::appendNumber32(%u)", number) U_TRACE(0, "UString::appendNumber32(%u)", number)
(void) reserve(12U); U_ASSERT_MAJOR(space(), 12)
uint32_t sz = size(); uint32_t sz = size();
char* ptr = c_pointer(sz); char* ptr = c_pointer(sz);
@ -2193,7 +2246,7 @@ public:
{ {
U_TRACE(0, "UString::appendNumber32s(%d)", number) U_TRACE(0, "UString::appendNumber32s(%d)", number)
(void) reserve(12U); U_ASSERT_MAJOR(space(), 12)
uint32_t sz = size(); uint32_t sz = size();
char* ptr = c_pointer(sz); char* ptr = c_pointer(sz);
@ -2207,7 +2260,7 @@ public:
{ {
U_TRACE(0, "UString::appendNumber64(%llu)", number) U_TRACE(0, "UString::appendNumber64(%llu)", number)
(void) reserve(22U); U_ASSERT_MAJOR(space(), 22)
uint32_t sz = size(); uint32_t sz = size();
char* ptr = c_pointer(sz); char* ptr = c_pointer(sz);
@ -2221,7 +2274,7 @@ public:
{ {
U_TRACE(0, "UString::appendNumber64s(%lld)", number) U_TRACE(0, "UString::appendNumber64s(%lld)", number)
(void) reserve(22U); U_ASSERT_MAJOR(space(), 22)
uint32_t sz = size(); uint32_t sz = size();
char* ptr = c_pointer(sz); char* ptr = c_pointer(sz);
@ -2235,7 +2288,7 @@ public:
{ {
U_TRACE(0, "UString::appendNumberDouble(%g)", number) U_TRACE(0, "UString::appendNumberDouble(%g)", number)
(void) reserve(32U); U_ASSERT_MAJOR(space(), 32)
uint32_t sz = size(); uint32_t sz = size();
char* ptr = c_pointer(sz); char* ptr = c_pointer(sz);
@ -2249,6 +2302,8 @@ public:
{ {
U_TRACE(0, "UString::appendData(%.*S,%u)", tlen, t, tlen) U_TRACE(0, "UString::appendData(%.*S,%u)", tlen, t, tlen)
U_ASSERT_MAJOR(space(), tlen)
uint32_t sz = size(); uint32_t sz = size();
char* ptr = c_pointer(sz); char* ptr = c_pointer(sz);

View File

@ -359,7 +359,14 @@ public:
// SERVICES // SERVICES
void nanosleep(); void nanosleep();
static void nanosleep(time_t timeoutMS) { UTimeVal(timeoutMS / 1000L, (timeoutMS % 1000L) * 1000L).nanosleep(); } static void nanosleep(time_t timeoutMS)
{
U_TRACE(0, "UTimeVal::nanosleep(%ld)", timeoutMS)
U_INTERNAL_ASSERT(timeoutMS >= 100)
UTimeVal(timeoutMS / 1000L, (timeoutMS % 1000L) * 1000L).nanosleep();
}
// CHRONOMETER // CHRONOMETER

View File

@ -26,7 +26,6 @@
class U_EXPORT UStringExt { class U_EXPORT UStringExt {
public: public:
#ifdef USE_LIBSSL #ifdef USE_LIBSSL
static UString BIOtoString(BIO* bio); static UString BIOtoString(BIO* bio);
static UString ASN1TimetoString(ASN1_GENERALIZEDTIME* t); static UString ASN1TimetoString(ASN1_GENERALIZEDTIME* t);
@ -41,6 +40,10 @@ public:
static UString stripTags(const UString& html, UString* list_tags_allowed = U_NULLPTR); static UString stripTags(const UString& html, UString* list_tags_allowed = U_NULLPTR);
#endif #endif
#ifndef U_LOG_DISABLE
static const char* deflate_agent;
#endif
static bool isDelimited(const UString& s, const char* delimiter = "()") static bool isDelimited(const UString& s, const char* delimiter = "()")
{ {
U_TRACE(0, "UStringExt::isDelimited(%V,%S)", s.rep, delimiter) U_TRACE(0, "UStringExt::isDelimited(%V,%S)", s.rep, delimiter)

View File

@ -676,6 +676,59 @@ public:
U_RETURN_STRING(keyid); U_RETURN_STRING(keyid);
} }
#ifdef U_SSE_ENABLE // SERVER SENT EVENTS (SSE)
static bool bsse;
static uint32_t getSSELastEventID()
{
U_TRACE_NO_PARAM(0, "UHTTP::getSSELastEventID()")
U_INTERNAL_ASSERT(bsse)
const char* ptr = UHTTP::getHeaderValuePtr(U_CONSTANT_TO_PARAM("last-event-id"), true);
uint32_t last_event_id = (ptr ? u_atoi(ptr) : 0);
U_RETURN(last_event_id);
}
static void writeSSE(uint32_t id, const UString& data, const UString* pevent = U_NULLPTR)
{
U_TRACE(0, "UHTTP::writeSSE(%u,%V,%p)", id, data.rep, pevent)
if (pevent) UClientImage_Base::wbuffer->snprintf_add(U_CONSTANT_TO_PARAM("id:%u\nevent:%v\ndata:"), id, pevent->rep);
else UClientImage_Base::wbuffer->snprintf_add(U_CONSTANT_TO_PARAM("id:%u\ndata:"), id);
UVector<UString> vec(data, '\n');
UClientImage_Base::wbuffer->append(vec[0]);
for (uint32_t i = 1, n = vec.size(); i < n; ++i)
{
UClientImage_Base::wbuffer->snprintf_add(U_CONSTANT_TO_PARAM("\ndata:%v"), vec[i].rep);
}
UClientImage_Base::wbuffer->append(U_CONSTANT_TO_PARAM("\n\n"));
}
static void sendSSE(uint32_t id, const UString& data, const UString* pevent = U_NULLPTR)
{
U_TRACE(0, "UHTTP::sendSSE(%u,%V,%p)", id, data.rep, pevent)
U_INTERNAL_ASSERT(bsse)
UClientImage_Base::wbuffer->setBuffer(U_CAPACITY);
writeSSE(id, data, pevent);
uint32_t sz = UClientImage_Base::wbuffer->size();
U_SRV_LOG_WITH_ADDR("send message (%u bytes) %#.*S to", sz, sz, UClientImage_Base::wbuffer->data());
if (USocketExt::write(UServer_Base::csocket, UClientImage_Base::wbuffer->data(), sz, UServer_Base::timeoutMS) != (int32_t)sz) UServer_Base::endNewChild(); // no return
}
#endif
// HTML Pagination // HTML Pagination
static uint32_t num_page_end, static uint32_t num_page_end,
@ -842,7 +895,7 @@ public:
const char* dump(bool reset) const U_EXPORT; const char* dump(bool reset) const U_EXPORT;
#endif #endif
private: private:
bool load() U_NO_EXPORT; bool load() U_NO_EXPORT;
bool isPath(const char* pathname, uint32_t len) bool isPath(const char* pathname, uint32_t len)
{ {
@ -859,6 +912,7 @@ public:
template <class T> friend void u_construct(const T**,bool); template <class T> friend void u_construct(const T**,bool);
}; };
static UServletPage* usp;
static bool bcallInitForAllUSP; static bool bcallInitForAllUSP;
static UVector<UServletPage*>* vusp; static UVector<UServletPage*>* vusp;
@ -867,8 +921,8 @@ public:
static void callSigHUPForAllUSP(); static void callSigHUPForAllUSP();
static void callAfterForkForAllUSP(); static void callAfterForkForAllUSP();
static bool checkForUSP(); static bool checkForUSP();
static UServletPage* getUSP(const char* key, uint32_t key_len); static bool getUSP(const char* key, uint32_t key_len);
// CSP (C Servlet Page) // CSP (C Servlet Page)

View File

@ -209,6 +209,21 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
fi fi
AC_MSG_RESULT([$enable_HPRS]) AC_MSG_RESULT([$enable_HPRS])
AC_MSG_CHECKING(if you want to enable Server-Sent Events support)
AC_ARG_ENABLE(SSE,
[ --enable-SSE enable Server-Sent Events Support [[default=yes]]])
if test -z "$enable_SSE"; then
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_SSE="no"
else
enable_SSE="yes"
fi
fi
if test "$enable_SSE" = "yes"; then
AC_DEFINE(U_SSE_ENABLE, 1, [enable Server-Sent Events support])
fi
AC_MSG_RESULT([$enable_SSE])
AC_MSG_CHECKING(if you want to enable HTTP/2 support) AC_MSG_CHECKING(if you want to enable HTTP/2 support)
AC_ARG_ENABLE(http2, AC_ARG_ENABLE(http2,
[ --enable-http2 enable HTTP/2 support [[default=no]]]) [ --enable-http2 enable HTTP/2 support [[default=no]]])

View File

@ -390,7 +390,7 @@ U_NO_EXPORT bool UCommand::postCommand(UString* input, UString* output)
UProcess::kill(pid, SIGTERM); UProcess::kill(pid, SIGTERM);
UTimeVal::nanosleep(1L); UTimeVal::nanosleep(1000L);
UProcess::kill(pid, SIGKILL); UProcess::kill(pid, SIGKILL);
} }

View File

@ -515,6 +515,8 @@ void UMemoryPool::deallocate(void* ptr, uint32_t length)
{ {
U_TRACE(1, "UMemoryPool::deallocate(%p,%u)", ptr, length) U_TRACE(1, "UMemoryPool::deallocate(%p,%u)", ptr, length)
U_INTERNAL_ASSERT_MINOR(length, U_TO_FREE)
if (UFile::isLastAllocation(ptr, length)) if (UFile::isLastAllocation(ptr, length))
{ {
UFile::pfree = (char*)ptr; UFile::pfree = (char*)ptr;

View File

@ -717,12 +717,15 @@ void ULog::logResponse(const UString& data, const char* format, uint32_t fmt_siz
len = (UServer_Base::mod_name[0][0] ? u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("%s"), UServer_Base::mod_name) : 0); len = (UServer_Base::mod_name[0][0] ? u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("%s"), UServer_Base::mod_name) : 0);
len += u__snprintf(buffer-len, sizeof(buffer)-len, U_CONSTANT_TO_PARAM("received response (%u bytes) %#.*S"), sz, sz, ptr); len += u__snprintf(buffer-len, sizeof(buffer)-len, U_CONSTANT_TO_PARAM("received response (%u bytes) %#.*S"), sz, sz, ptr);
va_list argp; if (fmt_size)
va_start(argp, fmt_size); {
va_list argp;
va_start(argp, fmt_size);
len += u__vsnprintf(buffer+len, sizeof(buffer)-len, format, fmt_size, argp); len += u__vsnprintf(buffer+len, sizeof(buffer)-len, format, fmt_size, argp);
va_end(argp); va_end(argp);
}
write(buffer, len); write(buffer, len);

View File

@ -365,7 +365,7 @@ fd_set* UPing::checkForPingAsyncCompletion(uint32_t nfds)
if (nfds && if (nfds &&
SHM_counter < nfds) SHM_counter < nfds)
{ {
UTimeVal::nanosleep(1L); UTimeVal::nanosleep(1000L);
U_INTERNAL_DUMP("SHM_counter = %u addrmask = %B", SHM_counter, __FDS_BITS(addrmask)[0]) U_INTERNAL_DUMP("SHM_counter = %u addrmask = %B", SHM_counter, __FDS_BITS(addrmask)[0])

View File

@ -900,7 +900,7 @@ void UClientImage_Base::manageReadBufferResize(uint32_t n)
{ {
const char* ptr = rbuffer->data(); const char* ptr = rbuffer->data();
UString::_reserve(*rbuffer, n); UString::_reserve(*rbuffer, rbuffer->getReserveNeed(n));
diff += rbuffer->data() - ptr; diff += rbuffer->data() - ptr;
} }

View File

@ -579,15 +579,13 @@ int UHttpPlugIn::handlerRun() // NB: we use this method instead of handlerInit()
UHTTP::bcallInitForAllUSP = true; UHTTP::bcallInitForAllUSP = true;
UHTTP::UServletPage* usp = UHTTP::getUSP(U_CONSTANT_TO_PARAM("modupload")); if (UHTTP::getUSP(U_CONSTANT_TO_PARAM("modupload")))
if (usp)
{ {
U_INTERNAL_DUMP("modupload->runDynamicPage = %p", usp->runDynamicPage) U_INTERNAL_DUMP("modupload->runDynamicPage = %p", UHTTP::usp->runDynamicPage)
U_INTERNAL_ASSERT_POINTER(usp->runDynamicPage) U_INTERNAL_ASSERT_POINTER(UHTTP::usp->runDynamicPage)
UHTTP::on_upload = usp->runDynamicPage; UHTTP::on_upload = UHTTP::usp->runDynamicPage;
} }
if (UHTTP::upload_dir->empty()) (void) UHTTP::upload_dir->assign(U_CONSTANT_TO_PARAM("uploads")); if (UHTTP::upload_dir->empty()) (void) UHTTP::upload_dir->assign(U_CONSTANT_TO_PARAM("uploads"));

View File

@ -78,15 +78,13 @@ int UWebSocketPlugIn::handlerRun()
U_NEW(UString, UWebSocket::rbuffer, UString(U_CAPACITY)); U_NEW(UString, UWebSocket::rbuffer, UString(U_CAPACITY));
UHTTP::UServletPage* usp = UHTTP::getUSP(U_CONSTANT_TO_PARAM("modsocket")); if (UHTTP::getUSP(U_CONSTANT_TO_PARAM("modsocket")))
if (usp)
{ {
U_INTERNAL_DUMP("modsocket->runDynamicPage = %p", usp->runDynamicPage) U_INTERNAL_DUMP("modsocket->runDynamicPage = %p", UHTTP::usp->runDynamicPage)
U_INTERNAL_ASSERT_POINTER(usp->runDynamicPage) U_INTERNAL_ASSERT_POINTER(UHTTP::usp->runDynamicPage)
on_message = usp->runDynamicPage; on_message = UHTTP::usp->runDynamicPage;
} }
else else
{ {

View File

@ -152,6 +152,8 @@ public:
* <!--#vcode ... --> * <!--#vcode ... -->
* <!--#pcode ... --> * <!--#pcode ... -->
* <!--#lcode ... --> * <!--#lcode ... -->
* <!--#ssecode ... -->
* <!--#sseloop ... -->
* <!--#number ... --> * <!--#number ... -->
* <!--#puts ... --> * <!--#puts ... -->
* <!--#xmlputs ... --> * <!--#xmlputs ... -->
@ -301,16 +303,6 @@ public:
manageDirectiveArgsOrCpath("UHTTP::getPathComponent", true); manageDirectiveArgsOrCpath("UHTTP::getPathComponent", true);
} }
else if (strncmp(directive, U_CONSTANT_TO_PARAM("header")) == 0)
{
U_ASSERT(vcode.empty())
U_ASSERT(http_header.empty())
U_INTERNAL_ASSERT_EQUALS(bfirst_pass, false)
setDirectiveItem(directive, U_CONSTANT_SIZE("header"));
http_header = token;
}
else if (strncmp(directive, U_CONSTANT_TO_PARAM("vcode")) == 0) // validation code else if (strncmp(directive, U_CONSTANT_TO_PARAM("vcode")) == 0) // validation code
{ {
U_ASSERT(vcode.empty()) // NB: <!--#vcode ... --> must be before other code and uniq... U_ASSERT(vcode.empty()) // NB: <!--#vcode ... --> must be before other code and uniq...
@ -376,6 +368,111 @@ public:
output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep); output0.snprintf_add(U_CONSTANT_TO_PARAM("\n\t%v\n\t\n"), token.rep);
} }
else if (strncmp(directive, U_CONSTANT_TO_PARAM("ssecode")) == 0) // SSE code
{
U_ASSERT(output2.empty())
U_ASSERT(http_header.empty())
U_INTERNAL_ASSERT_EQUALS(bfirst_pass, false)
setDirectiveItem(directive, U_CONSTANT_SIZE("ssecode"));
U_INTERNAL_ASSERT(token)
token = UStringExt::substitute(token, '\n', U_CONSTANT_TO_PARAM("\n\t\t"));
/**
* we must insert:
*
* <!--#header
* Content-Type: text/event-stream
* Cache-Control: no-cache
* -->
*/
(void) http_header.reserve(1000U + token.size());
(void) http_header.snprintf(U_CONSTANT_TO_PARAM(
"\n\tif (U_http_accept_len != U_CONSTANT_SIZE(\"text/event-stream\") ||"
" u_get_unalignedp64(U_http_info.accept) != U_MULTICHAR_CONSTANT64('t','e','x','t','/','e','v','e')) UHTTP::setBadRequest();"
"\n\telse"
"\n\t\t{"
"\n\t\tUHTTP::bsse = true;"
"\n\t\t(void) UServer_Base::csocket->shutdown(SHUT_RD);"
"\n\t\tU_INTERNAL_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false)"
"\n\t\tU_http_info.endHeader = 61;"
"\n\t\t(void) UClientImage_Base::wbuffer->insert(0, U_CONSTANT_TO_PARAM(\"Content-Type: text/event-stream\\r\\nCache-Control: no-cache\\r\\n\\r\\n\"));"
"\n\t\tU_http_content_type_len = 1;"
"\n\t\t%v"
"\n\t\t}"), token.rep);
}
else if (strncmp(directive, U_CONSTANT_TO_PARAM("sseloop")) == 0) // SSE loop
{
U_ASSERT(sseloop.empty())
U_INTERNAL_ASSERT_EQUALS(bfirst_pass, false)
setDirectiveItem(directive, U_CONSTANT_SIZE("sseloop"));
U_INTERNAL_ASSERT(token)
uint32_t sz = token.size();
const char* data = token.data();
uint32_t sse_time_to_sleep = 1;
if (*data == ':')
{
++data;
sse_time_to_sleep = u_strtoulp(&data);
sz = token.remain(data);
}
char buffer[200];
(void) vars.append(buffer, u__snprintf(buffer, sizeof(buffer), U_CONSTANT_TO_PARAM("\n\tUTimeVal sse_time_to_sleep(%u, 0L);\n\t\n"), sse_time_to_sleep));
sseloop = UStringExt::substitute(data, sz, '\n', U_CONSTANT_TO_PARAM("\n\t"));
(void) output2.reserve(200U + sseloop.size());
output2.snprintf(U_CONSTANT_TO_PARAM(
"\n\treturn;\n\t\n"
"sseloop:"
"\n\tsse_time_to_sleep.nanosleep();"
"\n\t%v"
"\n\tgoto sseloop;"), sseloop.rep);
}
else if (strncmp(directive, U_CONSTANT_TO_PARAM("header")) == 0)
{
U_ASSERT(vcode.empty())
U_ASSERT(http_header.empty())
U_INTERNAL_ASSERT_EQUALS(bfirst_pass, false)
setDirectiveItem(directive, U_CONSTANT_SIZE("header"));
// NB: we use insert because the possibility of UHTTP::callService() (see chat.usp)...
if (U_STRING_FIND(token, 0, "Content-Type") != U_NOT_FOUND) (void) output2.assign(U_CONSTANT_TO_PARAM("\n\tU_http_content_type_len = 1;\n\t\n"));
http_header = UStringExt::dos2unix(token, true);
(void) http_header.append(U_CONSTANT_TO_PARAM("\r\n\r\n"));
uint32_t n = http_header.size();
UString encoded(n * 4);
UEscape::encode(http_header, encoded);
U_ASSERT(encoded.isQuoted())
(void) http_header.reserve(200U + encoded.size());
(void) http_header.snprintf(U_CONSTANT_TO_PARAM("\n\tU_INTERNAL_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false)"
"\n\tU_http_info.endHeader = %u;"
"\n\t(void) UClientImage_Base::wbuffer->insert(0, U_CONSTANT_TO_PARAM(%v));\n\t\n"), n, encoded.rep);
}
else if (strncmp(directive, U_CONSTANT_TO_PARAM("number")) == 0) else if (strncmp(directive, U_CONSTANT_TO_PARAM("number")) == 0)
{ {
U_INTERNAL_ASSERT_EQUALS(bfirst_pass, false) U_INTERNAL_ASSERT_EQUALS(bfirst_pass, false)
@ -602,6 +699,7 @@ loop: distance = t.getDistance();
bsighup, // usp_sighup bsighup, // usp_sighup
bfork; // usp_fork bfork; // usp_fork
const char* ptr0 = (sseloop ? "\n\t\tif (UHTTP::bsse) goto sseloop;\n\t" : "");
char ptr1[100] = { '\0' }; char ptr1[100] = { '\0' };
char ptr2[100] = { '\0' }; char ptr2[100] = { '\0' };
char ptr3[100] = { '\0' }; char ptr3[100] = { '\0' };
@ -686,9 +784,13 @@ loop: distance = t.getDistance();
: "\n\t\tif (param >= U_DPAGE_FORK) return;\n"); : "\n\t\tif (param >= U_DPAGE_FORK) return;\n");
} }
// NB: we check for HTML without HTTP headers... if (bvar)
{
(void) vars.append(U_CONSTANT_TO_PARAM("\n\tuint32_t usp_sz = 0;"
"\n\tchar usp_buffer[10 * 4096];\n\t"));
}
UString output2; // NB: we check for HTML without HTTP headers...
if (http_header.empty()) if (http_header.empty())
{ {
@ -696,32 +798,8 @@ loop: distance = t.getDistance();
(void) http_header.append(U_CONSTANT_TO_PARAM("\n\tU_http_info.endHeader = 0;\n")); (void) http_header.append(U_CONSTANT_TO_PARAM("\n\tU_http_info.endHeader = 0;\n"));
} }
else
{
// NB: we use insert because the possibility of UHTTP::callService() (see chat.usp)...
if (U_STRING_FIND(http_header, 0, "Content-Type") != U_NOT_FOUND) (void) output2.assign(U_CONSTANT_TO_PARAM("\n\t\tU_http_content_type_len = 1;\n\t")); UString result(1024U + declaration.size() + http_header.size() + output0.size() + output1.size() + output2.size() + sseloop.size() + vars.size());
http_header = UStringExt::dos2unix(http_header, true);
(void) http_header.append(U_CONSTANT_TO_PARAM("\r\n\r\n"));
uint32_t n = http_header.size();
UString encoded(n * 4);
UEscape::encode(http_header, encoded);
U_ASSERT(encoded.isQuoted())
(void) http_header.reserve(200U + encoded.size());
(void) http_header.snprintf(U_CONSTANT_TO_PARAM("\n\tU_INTERNAL_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false)"
"\n\tU_http_info.endHeader = %u;"
"\n\t(void) UClientImage_Base::wbuffer->insert(0, U_CONSTANT_TO_PARAM(%v));\n\t\n"), n, encoded.rep);
}
UString result(1024U + declaration.size() + http_header.size() + output0.size() + output1.size() + output2.size());
result.snprintf(U_CONSTANT_TO_PARAM( result.snprintf(U_CONSTANT_TO_PARAM(
"// %.*s.cpp - dynamic page translation (%.*s.usp => %.*s.cpp)\n" "// %.*s.cpp - dynamic page translation (%.*s.usp => %.*s.cpp)\n"
@ -729,16 +807,14 @@ loop: distance = t.getDistance();
"#include <ulib/net/server/usp_macro.h>\n" "#include <ulib/net/server/usp_macro.h>\n"
"\t\n" "\t\n"
"%v" "%v"
"\t\n" "\n\t\n"
"\t\n"
"extern \"C\" {\n" "extern \"C\" {\n"
"extern U_EXPORT void runDynamicPage_%.*s(int param);\n" "extern U_EXPORT void runDynamicPage_%.*s(int param);\n"
" U_EXPORT void runDynamicPage_%.*s(int param)\n" " U_EXPORT void runDynamicPage_%.*s(int param)\n"
"{\n" "{\n"
"\tU_TRACE(0, \"::runDynamicPage_%.*s(%%d)\", param)\n" "\tU_TRACE(0, \"::runDynamicPage_%.*s(%%d)\", param)\n"
"\t\n" "\t\n"
"%s" "%v"
"\t\n"
"\tif (param)\n" "\tif (param)\n"
"\t\t{\n" "\t\t{\n"
"%s" "%s"
@ -747,6 +823,7 @@ loop: distance = t.getDistance();
"%s" "%s"
"%s" "%s"
"%s" "%s"
"%s"
"\t\t}\n" "\t\t}\n"
"\t\n" "\t\n"
"%v" "%v"
@ -765,9 +842,8 @@ loop: distance = t.getDistance();
basename_sz, basename_ptr, basename_sz, basename_ptr,
basename_sz, basename_ptr, basename_sz, basename_ptr,
basename_sz, basename_ptr, basename_sz, basename_ptr,
bvar ? "\n\tuint32_t usp_sz = 0;" vars.rep,
"\n\tchar usp_buffer[10 * 4096];\n" ptr0,
: "",
ptr1, ptr1,
ptr2, ptr2,
ptr3, ptr3,
@ -791,7 +867,7 @@ loop: distance = t.getDistance();
private: private:
UTokenizer t; UTokenizer t;
UVector<UString> vdefine; UVector<UString> vdefine;
UString pinclude, usp, token, output0, output1, declaration, vcode, http_header; UString pinclude, usp, token, output0, output1, output2, declaration, vcode, http_header, sseloop, vars;
bool bvar, bsession, bstorage, bfirst_pass, is_html, test_if_html, bpreprocessing_failed; bool bvar, bsession, bstorage, bfirst_pass, is_html, test_if_html, bpreprocessing_failed;
U_DISALLOW_COPY_AND_ASSIGN(Application) U_DISALLOW_COPY_AND_ASSIGN(Application)

View File

@ -311,7 +311,7 @@ loop:
errno == EADDRINUSE && errno == EADDRINUSE &&
++counter <= 3) ++counter <= 3)
{ {
UTimeVal::nanosleep(1L); UTimeVal::nanosleep(1000L);
goto loop; goto loop;
} }

View File

@ -271,11 +271,11 @@ loop:
// First create a vector out of all keys // First create a vector out of all keys
uint8_t keys[20]; UFlatBufferValue keys;
CreateVector(start, len, 2, true, false, (UFlatBufferValue*)keys); CreateVector(start, len, 2, true, false, &keys);
pkeys = (UFlatBufferValue*)keys; pkeys = &keys;
CreateVector(start+1, len, 2, false, false, U_NULLPTR); CreateVector(start+1, len, 2, false, false, U_NULLPTR);

View File

@ -881,7 +881,7 @@ void UStringRep::_release()
{ {
if (_capacity != U_NOT_FOUND) if (_capacity != U_NOT_FOUND)
{ {
# if defined(USE_LIBTDB) || defined(USE_MONGODB) # if defined(USE_LIBZOPFLI) || defined(USE_LIBTDB) || defined(USE_MONGODB)
if (_capacity == U_TO_FREE) { U_SYSCALL_VOID(free, "%p", (void*)str); } if (_capacity == U_TO_FREE) { U_SYSCALL_VOID(free, "%p", (void*)str); }
else else
# endif # endif
@ -1199,53 +1199,6 @@ void UString::setBuffer(uint32_t n)
U_INTERNAL_ASSERT(invariant()) U_INTERNAL_ASSERT(invariant())
} }
void UString::moveToBeginDataInBuffer(uint32_t n)
{
U_TRACE(1, "UString::moveToBeginDataInBuffer(%u)", n)
U_INTERNAL_ASSERT_MAJOR(rep->_length, n)
U_INTERNAL_ASSERT_RANGE(1, n, max_size())
U_INTERNAL_ASSERT_MAJOR(rep->_capacity, n)
#if defined(DEBUG) && !defined(U_SUBSTR_INC_REF)
U_INTERNAL_ASSERT(rep->references == 0)
#endif
rep->_length -= n;
(void) U_SYSCALL(memmove, "%p,%p,%u", (void*)rep->str, rep->str + n, rep->_length);
U_INTERNAL_ASSERT(invariant())
}
void UString::_reserve(UString& buffer, uint32_t n)
{
U_TRACE(0, "UString::_reserve(%V,%u)", buffer.rep, n)
UStringRep* rep = buffer.rep;
U_INTERNAL_DUMP("rep = %p rep->parent = %p rep->references = %u rep->child = %d rep->_length = %u rep->_capacity = %u",
rep, rep->parent, rep->references, rep->child, rep->_length, rep->_capacity)
U_ASSERT(rep->space() < n)
U_INTERNAL_ASSERT(n <= max_size())
uint32_t need = rep->_length + n;
if (need < U_CAPACITY) need = U_CAPACITY;
else if (need > U_CAPACITY)
{
if (need < 2*1024*1024) need = (need * 2) + (PAGESIZE * 2);
need += PAGESIZE; // NB: to avoid duplication on realloc...
}
buffer._set(UStringRep::create(rep->_length, need, rep->str));
U_INTERNAL_ASSERT(buffer.invariant())
U_INTERNAL_ASSERT(buffer.space() >= n)
}
// manage UString as memory mapped area... // manage UString as memory mapped area...
void UString::mmap(const char* map, uint32_t len) void UString::mmap(const char* map, uint32_t len)
@ -1983,7 +1936,7 @@ void UString::printKeyValue(const char* key, uint32_t keylen, const char* _data,
n += u_buffer_len; n += u_buffer_len;
} }
if (rep->space() < n) _reserve(*this, n); if (rep->space() < n) _reserve(*this, rep->_length + n);
char* ptr = (char*)rep->str + rep->_length; char* ptr = (char*)rep->str + rep->_length;

View File

@ -115,7 +115,7 @@ bool UServices::read(int fd, UString& buffer, uint32_t count, int timeoutMS)
if (ncount < chunk) if (ncount < chunk)
{ {
UString::_reserve(buffer, chunk); UString::_reserve(buffer, buffer.getReserveNeed(chunk));
ncount = buffer.space(); ncount = buffer.space();
} }
@ -165,7 +165,7 @@ read:
// NB: may be there are available more bytes to read... // NB: may be there are available more bytes to read...
UString::_reserve(buffer, ncount * 2); UString::_reserve(buffer, buffer.getReserveNeed(ncount * 2));
ptr = buffer.c_pointer(start); ptr = buffer.c_pointer(start);

View File

@ -70,7 +70,7 @@ bool USocketExt::read(USocket* sk, UString& buffer, uint32_t count, int timeoutM
if (UNLIKELY(ncount < chunk)) if (UNLIKELY(ncount < chunk))
{ {
if (sk == UServer_Base::csocket) UClientImage_Base::manageReadBufferResize(chunk); if (sk == UServer_Base::csocket) UClientImage_Base::manageReadBufferResize(chunk);
else UString::_reserve(buffer, chunk); else UString::_reserve(buffer, buffer.getReserveNeed(chunk));
ncount = buffer.space(); ncount = buffer.space();
} }
@ -193,7 +193,7 @@ error: U_INTERNAL_DUMP("errno = %d", errno)
buffer.rep->_length = start + byte_read; buffer.rep->_length = start + byte_read;
if (sk == UServer_Base::csocket) UClientImage_Base::manageReadBufferResize(ncount * 2); if (sk == UServer_Base::csocket) UClientImage_Base::manageReadBufferResize(ncount * 2);
else UString::_reserve(buffer, ncount * 2); else UString::_reserve(buffer, buffer.getReserveNeed(ncount * 2));
ptr = buffer.c_pointer(start); ptr = buffer.c_pointer(start);
ncount = buffer.space(); ncount = buffer.space();

View File

@ -36,6 +36,10 @@
# include <pwd.h> # include <pwd.h>
#endif #endif
#ifndef U_LOG_DISABLE
const char* UStringExt::deflate_agent = "gzip";
#endif
#ifdef USE_LIBSSL #ifdef USE_LIBSSL
UString UStringExt::BIOtoString(BIO* bio) UString UStringExt::BIOtoString(BIO* bio)
{ {
@ -256,7 +260,7 @@ UString UStringExt::substitute(const char* s, uint32_t n, const char* a, uint32_
if (x.space() < len2) if (x.space() < len2)
{ {
UString::_reserve(x, len2); UString::_reserve(x, x.rep->_length + len2);
p2 = x.pend(); p2 = x.pend();
} }
@ -290,7 +294,7 @@ UString UStringExt::substitute(const char* s, uint32_t n, const char* a, uint32_
if (breserve && if (breserve &&
x.space() < n) x.space() < n)
{ {
UString::_reserve(x, n); UString::_reserve(x, x.rep->_length + n);
p2 = x.pend(); p2 = x.pend();
} }
@ -428,7 +432,7 @@ found:
if (x.space() < len2) if (x.space() < len2)
{ {
UString::_reserve(x, len2); UString::_reserve(x, x.rep->_length + len2);
p2 = x.pend(); p2 = x.pend();
} }
@ -464,7 +468,7 @@ found:
if (breserve && if (breserve &&
x.space() < len) x.space() < len)
{ {
UString::_reserve(x, len); UString::_reserve(x, x.rep->_length + len);
p2 = x.pend(); p2 = x.pend();
} }
@ -550,7 +554,7 @@ loop:
if (x.space() < len2) if (x.space() < len2)
{ {
UString::_reserve(x, len2); UString::_reserve(x, x.rep->_length + len2);
p2 = x.pend(); p2 = x.pend();
} }
@ -583,7 +587,7 @@ loop:
if (breserve && if (breserve &&
x.space() < len) x.space() < len)
{ {
UString::_reserve(x, len); UString::_reserve(x, x.rep->_length + len);
p2 = x.pend(); p2 = x.pend();
} }
@ -1572,42 +1576,15 @@ UString UStringExt::brotli(const char* s, uint32_t len, uint32_t quality, uint32
{ {
U_TRACE(1, "UStringExt::brotli(%.*S,%u,%u,%u,%u)", len, s, len, quality, mode, lgwin) U_TRACE(1, "UStringExt::brotli(%.*S,%u,%u,%u,%u)", len, s, len, quality, mode, lgwin)
int rc;
size_t sz = U_SYSCALL(BrotliEncoderMaxCompressedSize, "%u", len); /* Get an estimation about the output buffer... */ size_t sz = U_SYSCALL(BrotliEncoderMaxCompressedSize, "%u", len); /* Get an estimation about the output buffer... */
if (sz == 0) return UString::getStringNull(); if (sz == 0) return UString::getStringNull();
if (UFile::isAllocableFromPool(sz)) UString result;
{ bool bpool = UFile::isAllocableFromPool(sz);
rc = U_SYSCALL(BrotliEncoderCompress, "%u,%u,%u,%u,%p,%p,%p", quality, lgwin, (BrotliEncoderMode)mode, (size_t)len, (uint8_t*)s, &sz, (uint8_t*)UFile::pfree); char* ptr = (bpool ? (result.setConstant(UFile::pfree, sz), UFile::pfree) : (UString::_reserve(result, sz), result.data()));
ratio = (sz * 100U) / len; int rc = U_SYSCALL(BrotliEncoderCompress, "%u,%u,%u,%u,%p,%p,%p", quality, lgwin, (BrotliEncoderMode)mode, (size_t)len, (uint8_t*)s, &sz, (uint8_t*)ptr);
U_INTERNAL_DUMP("BrotliEncoderCompress() = %d ratio = %u (%u%%)", rc, ratio, 100-ratio)
if (rc == 0 ||
ratio > ratio_threshold)
{
return UString::getStringNull();
}
U_INTERNAL_DUMP("BrotliEncoderCompress() = %#.4S", UFile::pfree)
len = UFile::getSizeAligned(sz);
UString result(sz, len, UFile::pfree);
UFile::pfree += len;
UFile::nfree -= len;
// U_INTERNAL_ASSERT(isBrotli(result)) // check magic byte
U_RETURN_STRING(result);
}
UString r(sz);
rc = U_SYSCALL(BrotliEncoderCompress, "%u,%u,%u,%u,%p,%p,%p", quality, lgwin, (BrotliEncoderMode)mode, (size_t)len, (uint8_t*)s, &sz, (uint8_t*)r.data());
ratio = (sz * 100U) / len; ratio = (sz * 100U) / len;
@ -1619,13 +1596,19 @@ UString UStringExt::brotli(const char* s, uint32_t len, uint32_t quality, uint32
return UString::getStringNull(); return UString::getStringNull();
} }
U_INTERNAL_DUMP("BrotliEncoderCompress() = %#.4S", r.data()) result.rep->_length = sz;
r.rep->_length = sz; if (bpool)
{
len = UFile::getSizeAligned(sz);
// U_INTERNAL_ASSERT(isBrotli(r)) // check magic byte UFile::pfree += len;
UFile::nfree -= len;
}
U_RETURN_STRING(r); // U_INTERNAL_ASSERT(isBrotli(result)) // check magic byte
U_RETURN_STRING(result);
} }
#endif #endif
@ -1673,77 +1656,77 @@ UString UStringExt::deflate(const char* s, uint32_t len, uint32_t quality) // .g
{ {
U_TRACE(1, "UStringExt::deflate(%.*S,%u,%u)", len, s, len, quality) U_TRACE(1, "UStringExt::deflate(%.*S,%u,%u)", len, s, len, quality)
// The zlib documentation states that destination buffer size must be at least 0.1% larger than avail_in plus 12 bytes #ifdef USE_LIBZOPFLI
if (quality == 0)
uint32_t sz = len + (len / 10) + 12U;
if (UFile::isAllocableFromPool(sz))
{ {
# ifdef USE_LIBZOPFLI size_t outsize = 0;
if (quality == 0) ZopfliOptions options;
{ unsigned char* out = U_NULLPTR;
size_t outsize = 0;
ZopfliOptions options;
unsigned char* out = U_NULLPTR;
U_SYSCALL_VOID(ZopfliInitOptions, "%p", &options); # ifndef U_LOG_DISABLE
deflate_agent = "zopfli";
U_SYSCALL_VOID(ZopfliCompress, "%p,%d,%p,%u,%p,%p", &options, ZOPFLI_FORMAT_GZIP, (unsigned char*)s, (size_t)len, &out, &outsize);
ratio = (outsize * 100U) / len;
U_INTERNAL_DUMP("ZopfliCompress(%u) = %u ratio = %u (%u%%)", len, outsize, ratio, 100-ratio)
if (ratio > ratio_threshold) return UString::getStringNull();
U_MEMCPY(UFile::pfree, out, sz = outsize);
U_SYSCALL_VOID(free, "%p", out);
}
else
# endif # endif
{
sz = u_gz_deflate(s, len, UFile::pfree, (quality ? quality : Z_BEST_COMPRESSION));
ratio = (sz * 100U) / len; U_SYSCALL_VOID(ZopfliInitOptions, "%p", &options);
U_INTERNAL_DUMP("u_gz_deflate(%u) = %u ratio = %u (%u%%)", len, sz, ratio, 100-ratio) U_SYSCALL_VOID(ZopfliCompress, "%p,%d,%p,%u,%p,%p", &options, ZOPFLI_FORMAT_GZIP, (unsigned char*)s, (size_t)len, &out, &outsize);
if (ratio > ratio_threshold) return UString::getStringNull(); ratio = (outsize * 100U) / len;
U_INTERNAL_DUMP("ZopfliCompress(%u) = %u ratio = %u (%u%%)", len, outsize, ratio, 100-ratio)
if (ratio > ratio_threshold)
{
U_SYSCALL_VOID(free, "%p", out);
return UString::getStringNull();
}
UString str((const char*)out, outsize);
str.rep->_capacity = U_TO_FREE;
U_RETURN_STRING(str);
} }
#endif
UString result(sz, len = UFile::getSizeAligned(sz), UFile::pfree); UString result;
uint32_t sz = len + (len / 10) + 12U; // The zlib documentation states that destination buffer size must be at least 0.1% larger than avail_in plus 12 bytes
bool bpool = UFile::isAllocableFromPool(sz);
char* ptr = (bpool ? (result.setConstant(UFile::pfree, sz), UFile::pfree) : (UString::_reserve(result, sz), result.data()));
UFile::pfree += len; #ifndef U_LOG_DISABLE
UFile::nfree -= len; deflate_agent = "gzip";
#endif
U_INTERNAL_ASSERT(isGzip(result)) // check magic byte ratio = ((sz = u_gz_deflate(s, len, ptr, (quality ? quality : Z_BEST_COMPRESSION))) * 100U) / len;
U_RETURN_STRING(result); U_INTERNAL_DUMP("u_gz_deflate(%u) = %u ratio = %u (%u%%)", len, sz, ratio, 100-ratio)
}
UString r(sz);
r.rep->_length = u_gz_deflate(s, len, r.rep->data(), (quality ? quality : Z_BEST_COMPRESSION));
ratio = (r.rep->_length * 100U) / len;
U_INTERNAL_DUMP("u_gz_deflate(%u) = %u ratio = %u (%u%%)", len, r.rep->_length, ratio, 100-ratio)
if (ratio > ratio_threshold) return UString::getStringNull(); if (ratio > ratio_threshold) return UString::getStringNull();
result.rep->_length = sz;
if (bpool)
{
len = UFile::getSizeAligned(sz);
UFile::pfree += len;
UFile::nfree -= len;
}
#ifdef DEBUG #ifdef DEBUG
uint32_t* psize_original = (uint32_t*)r.c_pointer(r.size() - 4); uint32_t* psize_original = (uint32_t*)result.c_pointer(sz - 4);
# if __BYTE_ORDER == __LITTLE_ENDIAN # if __BYTE_ORDER == __LITTLE_ENDIAN
U_INTERNAL_DUMP("size original = %u (LE)", *psize_original) U_INTERNAL_DUMP("size original = %u (LE)", *psize_original)
# else # else
U_INTERNAL_DUMP("size original = %u (BE)", u_invert32(*psize_original)) U_INTERNAL_DUMP("size original = %u (BE)", u_invert32(*psize_original))
# endif # endif
#endif #endif
U_INTERNAL_ASSERT(isGzip(r)) // check magic byte U_INTERNAL_ASSERT(isGzip(result)) // check magic byte
U_RETURN_STRING(r); U_RETURN_STRING(result);
} }
#endif #endif
@ -1827,7 +1810,7 @@ next:
do { ++ptr_header_value; } while (u__isspace(*ptr_header_value)); do { ++ptr_header_value; } while (u__isspace(*ptr_header_value));
U_INTERNAL_DUMP("ptr_header_value = %.*S", 20, ptr_header_value) U_INTERNAL_DUMP("ptr_header_value = %.20S", ptr_header_value)
return ptr_header_value; return ptr_header_value;
} }

View File

@ -122,6 +122,7 @@ UModProxyService* UHTTP::service;
UVector<UString>* UHTTP::vmsg_error; UVector<UString>* UHTTP::vmsg_error;
UVector<UString>* UHTTP::form_name_value; UVector<UString>* UHTTP::form_name_value;
UHashMap<UString>* UHTTP::prequestHeader; UHashMap<UString>* UHTTP::prequestHeader;
UHTTP::UServletPage* UHTTP::usp;
UVector<UModProxyService*>* UHTTP::vservice; UVector<UModProxyService*>* UHTTP::vservice;
UVector<UHTTP::UServletPage*>* UHTTP::vusp; UVector<UHTTP::UServletPage*>* UHTTP::vusp;
URDBObjectHandler<UDataStorage*>* UHTTP::db_session; URDBObjectHandler<UDataStorage*>* UHTTP::db_session;
@ -167,6 +168,9 @@ USSLSession* UHTTP::data_session_ssl;
UVector<UIPAllow*>* UHTTP::vallow_IP; UVector<UIPAllow*>* UHTTP::vallow_IP;
URDBObjectHandler<UDataStorage*>* UHTTP::db_session_ssl; URDBObjectHandler<UDataStorage*>* UHTTP::db_session_ssl;
#endif #endif
#ifdef U_SSE_ENABLE // SERVER SENT EVENTS (SSE)
bool UHTTP::bsse;
#endif
#ifdef USE_LOAD_BALANCE #ifdef USE_LOAD_BALANCE
UClient<USSLSocket>* UHTTP::client_http; UClient<USSLSocket>* UHTTP::client_http;
#endif #endif
@ -4453,14 +4457,14 @@ file_in_cache:
# endif # endif
{ {
# ifndef U_COVERITY_FALSE_POSITIVE // FORWARD_NULL # ifndef U_COVERITY_FALSE_POSITIVE // FORWARD_NULL
UServletPage* usp = (UServletPage*)file_data->ptr; usp = (UServletPage*)file_data->ptr;
U_INTERNAL_ASSERT_POINTER(usp) U_INTERNAL_ASSERT_POINTER(usp)
U_INTERNAL_ASSERT_POINTER(usp->runDynamicPage) U_INTERNAL_ASSERT_POINTER(usp->runDynamicPage)
U_SET_MODULE_NAME(usp); U_SET_MODULE_NAME(usp);
U_DUMP("U_http_info.nResponseCode = %u", U_http_info.nResponseCode) U_INTERNAL_DUMP("U_http_info.nResponseCode = %u", U_http_info.nResponseCode)
usp->runDynamicPage(0); usp->runDynamicPage(0);
# endif # endif
@ -4819,7 +4823,7 @@ U_NO_EXPORT inline bool UHTTP::compress(const UString& body)
ext->rep->_length = U_CONSTANT_SIZE("Content-Encoding: gzip\r\n"); ext->rep->_length = U_CONSTANT_SIZE("Content-Encoding: gzip\r\n");
U_SRV_LOG("dynamic response: %u bytes - (%u%%) gzip compression ratio", UClientImage_Base::body->size(), 100-UStringExt::ratio); U_SRV_LOG("dynamic response: %u bytes - (%u%%) %s compression ratio", UClientImage_Base::body->size(), 100-UStringExt::ratio, UStringExt::deflate_agent);
U_RETURN(true); U_RETURN(true);
} }
@ -5307,6 +5311,33 @@ void UHTTP::setEndRequestProcessing()
U_INTERNAL_DUMP("U_ClientImage_request = %b U_http_info.nResponseCode = %u U_ClientImage_request_is_cached = %b U_http_info.startHeader = %u", U_INTERNAL_DUMP("U_ClientImage_request = %b U_http_info.nResponseCode = %u U_ClientImage_request_is_cached = %b U_http_info.startHeader = %u",
U_ClientImage_request, U_http_info.nResponseCode, U_ClientImage_request_is_cached, U_http_info.startHeader) U_ClientImage_request, U_http_info.nResponseCode, U_ClientImage_request_is_cached, U_http_info.startHeader)
#ifdef U_SSE_ENABLE
U_INTERNAL_DUMP("bsse = %b", bsse)
if (bsse)
{
U_INTERNAL_DUMP("Accept: = %.*S", U_HTTP_ACCEPT_TO_TRACE)
U_INTERNAL_ASSERT_EQUALS(u_get_unalignedp64(U_http_info.accept+8), U_MULTICHAR_CONSTANT64('n','t','-','s','t','r','e','a'))
if (UServer_Base::startParallelization())
{
// parent
bsse = false;
return;
}
U_INTERNAL_ASSERT_POINTER(usp)
U_INTERNAL_ASSERT_POINTER(usp->runDynamicPage)
U_SET_MODULE_NAME(sse);
usp->runDynamicPage(1);
}
#endif
#ifndef U_CACHE_REQUEST_DISABLE #ifndef U_CACHE_REQUEST_DISABLE
if (isGETorHEAD() && if (isGETorHEAD() &&
UClientImage_Base::isRequestCacheable() && UClientImage_Base::isRequestCacheable() &&
@ -7097,6 +7128,19 @@ void UHTTP::setDynamicResponse()
} }
# endif # endif
# ifdef U_SSE_ENABLE
U_INTERNAL_DUMP("bsse = %b", bsse)
if (bsse)
{
*ext = *UClientImage_Base::wbuffer;
handlerResponse();
return;
}
# endif
if (bcompress == false) if (bcompress == false)
{ {
(void) UClientImage_Base::body->replace(pEndHeader + U_http_info.endHeader, clength); (void) UClientImage_Base::body->replace(pEndHeader + U_http_info.endHeader, clength);
@ -7217,7 +7261,7 @@ U_NO_EXPORT bool UHTTP::processAuthorization(const char* request, uint32_t sz, c
const char* ptr; const char* ptr;
uint32_t pos = 0; uint32_t pos = 0;
bool result = false, bpass = false; bool result = false, bpass = false;
UString buffer(100U), fpasswd, content, tmp; UString buffer(U_CAPACITY), fpasswd, content, tmp;
if (pattern) if (pattern)
{ {
@ -7267,8 +7311,12 @@ U_NO_EXPORT bool UHTTP::processAuthorization(const char* request, uint32_t sz, c
ptr = getHeaderValuePtr(U_CONSTANT_TO_PARAM("Authorization"), false); ptr = getHeaderValuePtr(U_CONSTANT_TO_PARAM("Authorization"), false);
U_INTERNAL_DUMP("ptr = %p", ptr)
if (ptr) if (ptr)
{ {
U_INTERNAL_DUMP("ptr = %.20S", ptr)
if (digest_authentication) if (digest_authentication)
{ {
if (u_get_unalignedp32(ptr) != U_MULTICHAR_CONSTANT32('D','i','g','e')) goto end; if (u_get_unalignedp32(ptr) != U_MULTICHAR_CONSTANT32('D','i','g','e')) goto end;
@ -7465,10 +7513,8 @@ U_NO_EXPORT bool UHTTP::processAuthorization(const char* request, uint32_t sz, c
result = (ha3 == response); result = (ha3 == response);
} }
else else if (content.size() < 1000) // Authorization: Basic cy5jYXNhenphOnN0ZWZhbm8x==
{ {
// Authorization: Basic cy5jYXNhenphOnN0ZWZhbm8x==
UBase64::decode(content, buffer); UBase64::decode(content, buffer);
if (buffer) if (buffer)
@ -7476,12 +7522,12 @@ U_NO_EXPORT bool UHTTP::processAuthorization(const char* request, uint32_t sz, c
t.setData(buffer); t.setData(buffer);
t.setDelimiter(":"); t.setDelimiter(":");
UString password(100U); UString password(1000U);
if (t.next(*user_authentication, (bool*)U_NULLPTR) && if (t.next(*user_authentication, (bool*)U_NULLPTR) &&
t.next(password, (bool*)U_NULLPTR)) t.next(password, (bool*)U_NULLPTR))
{ {
UString line(100U), output(100U); UString line(1000U), output(1000U);
UServices::generateDigest(U_HASH_SHA1, 0, password, output, true); UServices::generateDigest(U_HASH_SHA1, 0, password, output, true);
@ -8240,7 +8286,7 @@ next:
} }
#endif #endif
U_SRV_LOG("File cached: %V - %u bytes - compression ratio (gzip %u%%, brotli %u%%)", pathname->rep, file_data->size, 100-ratio1, 100-ratio2); U_SRV_LOG("File cached: %V - %u bytes - compression ratio (%s %u%%, brotli %u%%)", pathname->rep, file_data->size, UStringExt::deflate_agent, 100-ratio1, 100-ratio2);
} }
void UHTTP::checkFileForCache() void UHTTP::checkFileForCache()
@ -8611,9 +8657,9 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& basename, const UStrin
struct stat st; struct stat st;
char buffer[U_PATH_MAX]; char buffer[U_PATH_MAX];
UServletPage* usp = getUSP(basename_ptr, name_len); bool usp_found = getUSP(basename_ptr, name_len);
if (usp) if (usp_found)
{ {
if (usp_dll && if (usp_dll &&
usp->isPath(file_ptr, len) == false) usp->isPath(file_ptr, len) == false)
@ -8639,7 +8685,7 @@ U_NO_EXPORT void UHTTP::manageDataForCache(const UString& basename, const UStrin
if (compileUSP(file_ptr, len) == false) goto error; if (compileUSP(file_ptr, len) == false) goto error;
} }
if (usp == U_NULLPTR) if (usp_found == false)
{ {
U_NEW(UHTTP::UServletPage, usp, UHTTP::UServletPage(file_ptr, len, basename_ptr, name_len)); U_NEW(UHTTP::UServletPage, usp, UHTTP::UServletPage(file_ptr, len, basename_ptr, name_len));
} }
@ -11207,9 +11253,10 @@ bool UHTTP::checkIfSourceHasChangedAndCompileUSP()
#if defined(DEBUG) && !defined(U_STATIC_ONLY) #if defined(DEBUG) && !defined(U_STATIC_ONLY)
UString suffix = file->getSuffix(); UString suffix = file->getSuffix();
const char* ptr = file->getPathRelativ(); const char* ptr = file->getPathRelativ();
UServletPage* usp = (UServletPage*)file_data->ptr;
uint32_t len = file->getPathRelativLen()-suffix.size()-1; // NB: we must avoid the point '.' before the suffix... uint32_t len = file->getPathRelativLen()-suffix.size()-1; // NB: we must avoid the point '.' before the suffix...
usp = (UServletPage*)file_data->ptr;
U_INTERNAL_DUMP("pathname = %V file = %.*S suffix = %V usp = %p", pathname->rep, U_FILE_TO_TRACE(*file), suffix.rep, usp) U_INTERNAL_DUMP("pathname = %V file = %.*S suffix = %V usp = %p", pathname->rep, U_FILE_TO_TRACE(*file), suffix.rep, usp)
if (suffix.empty()) if (suffix.empty())
@ -11259,7 +11306,7 @@ err: setInternalError();
U_RETURN(true); U_RETURN(true);
} }
UHTTP::UServletPage* UHTTP::getUSP(const char* key, uint32_t key_len) bool UHTTP::getUSP(const char* key, uint32_t key_len)
{ {
U_TRACE(0+256, "UHTTP::getUSP(%.*S,%u)", key_len, key, key_len) U_TRACE(0+256, "UHTTP::getUSP(%.*S,%u)", key_len, key, key_len)
@ -11267,10 +11314,9 @@ UHTTP::UServletPage* UHTTP::getUSP(const char* key, uint32_t key_len)
U_INTERNAL_ASSERT_POINTER(vusp) U_INTERNAL_ASSERT_POINTER(vusp)
U_INTERNAL_ASSERT_MAJOR(key_len, 0) U_INTERNAL_ASSERT_MAJOR(key_len, 0)
UServletPage* usp; int32_t high;
int32_t high = vusp->size();
if (high == 0) U_RETURN_POINTER(U_NULLPTR, UHTTP::UServletPage); if ((high = vusp->size()) == 0) U_RETURN(false);
U_INTERNAL_DUMP("bcallInitForAllUSP = %b", bcallInitForAllUSP) U_INTERNAL_DUMP("bcallInitForAllUSP = %b", bcallInitForAllUSP)
@ -11286,11 +11332,11 @@ UHTTP::UServletPage* UHTTP::getUSP(const char* key, uint32_t key_len)
{ {
U_INTERNAL_DUMP("USP found(%u) = %V", i, usp->basename.rep) U_INTERNAL_DUMP("USP found(%u) = %V", i, usp->basename.rep)
U_RETURN_POINTER(usp, UHTTP::UServletPage); U_RETURN(true);
} }
} }
U_RETURN_POINTER(U_NULLPTR, UHTTP::UServletPage); U_RETURN(false);
} }
UString x; UString x;
@ -11319,7 +11365,7 @@ UHTTP::UServletPage* UHTTP::getUSP(const char* key, uint32_t key_len)
if (low == -1 || if (low == -1 ||
vusp->at(low)->basename.equal(key, key_len) == false) vusp->at(low)->basename.equal(key, key_len) == false)
{ {
U_RETURN_POINTER(U_NULLPTR, UHTTP::UServletPage); U_RETURN(false);
} }
probe = low; probe = low;
@ -11329,7 +11375,7 @@ found:
U_INTERNAL_DUMP("USP found(%u) = %V", probe, usp->basename.rep) U_INTERNAL_DUMP("USP found(%u) = %V", probe, usp->basename.rep)
U_RETURN_POINTER(usp, UHTTP::UServletPage); U_RETURN(true);
} }
bool UHTTP::checkForUSP() bool UHTTP::checkForUSP()
@ -11343,10 +11389,8 @@ bool UHTTP::checkForUSP()
if (u_get_unalignedp16(ptr) == U_MULTICHAR_CONSTANT16(' ','/')) if (u_get_unalignedp16(ptr) == U_MULTICHAR_CONSTANT16(' ','/'))
{ {
static uint32_t old_sz; static uint32_t old_sz;
static UServletPage* old_usp;
uint32_t sz; uint32_t sz;
UServletPage* usp;
unsigned char* ptr1 = (ptr += 2); unsigned char* ptr1 = (ptr += 2);
loop: while (u__isalpha(*++ptr1)) {} loop: while (u__isalpha(*++ptr1)) {}
@ -11359,45 +11403,38 @@ loop: while (u__isalpha(*++ptr1)) {}
if (sz == old_sz) if (sz == old_sz)
{ {
U_ASSERT(old_usp->basename.equal((const char*)ptr, sz)) U_ASSERT(usp->basename.equal((const char*)ptr, sz))
usp = old_usp;
goto next; goto next;
} }
if (u_get_unalignedp64(ptr) != U_MULTICHAR_CONSTANT64('p','l','a','i','n','t','e','x')) if (u_get_unalignedp64(ptr) != U_MULTICHAR_CONSTANT64('p','l','a','i','n','t','e','x') &&
getUSP((const char*)ptr, sz))
{ {
usp = getUSP((const char*)ptr, sz); old_sz = sz;
if (usp) next: if (*ptr1 == '?')
{ {
old_sz = sz; U_http_info.query = (const char*)(ptr1 += U_CONSTANT_SIZE("?queries"));
old_usp = usp;
next: if (*ptr1 == '?') while (*++ptr1 != ' ') {}
{
U_http_info.query = (const char*)(ptr1 += U_CONSTANT_SIZE("?queries"));
while (*++ptr1 != ' ') {} U_http_info.query_len = (const char*)ptr1 - U_http_info.query;
U_http_info.query_len = (const char*)ptr1 - U_http_info.query; U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
U_INTERNAL_DUMP("query = %.*S", U_HTTP_QUERY_TO_TRACE)
}
U_http_content_type_len = 0;
U_http_info.nResponseCode = HTTP_OK;
usp->runDynamicPage(0);
setDynamicResponse();
(void) UServer_Base::pClientImage->writeResponse();
U_RETURN(true);
} }
U_http_content_type_len = 0;
U_http_info.nResponseCode = HTTP_OK;
usp->runDynamicPage(0);
setDynamicResponse();
(void) UServer_Base::pClientImage->writeResponse();
U_RETURN(true);
} }
} }
@ -11410,8 +11447,6 @@ void UHTTP::callInitForAllUSP()
U_INTERNAL_ASSERT_POINTER(vusp) U_INTERNAL_ASSERT_POINTER(vusp)
UServletPage* usp;
for (uint32_t i = 0, n = vusp->size(); i < n; ++i) for (uint32_t i = 0, n = vusp->size(); i < n; ++i)
{ {
usp = vusp->at(i); usp = vusp->at(i);
@ -11431,8 +11466,6 @@ void UHTTP::callEndForAllUSP()
U_INTERNAL_ASSERT_POINTER(vusp) U_INTERNAL_ASSERT_POINTER(vusp)
U_INTERNAL_ASSERT(bcallInitForAllUSP) U_INTERNAL_ASSERT(bcallInitForAllUSP)
UServletPage* usp;
for (uint32_t i = 0, n = vusp->size(); i < n; ++i) for (uint32_t i = 0, n = vusp->size(); i < n; ++i)
{ {
usp = vusp->at(i); usp = vusp->at(i);
@ -11452,8 +11485,6 @@ void UHTTP::callSigHUPForAllUSP()
U_INTERNAL_ASSERT_POINTER(vusp) U_INTERNAL_ASSERT_POINTER(vusp)
U_INTERNAL_ASSERT(bcallInitForAllUSP) U_INTERNAL_ASSERT(bcallInitForAllUSP)
UServletPage* usp;
for (uint32_t i = 0, n = vusp->size(); i < n; ++i) for (uint32_t i = 0, n = vusp->size(); i < n; ++i)
{ {
usp = vusp->at(i); usp = vusp->at(i);
@ -11473,8 +11504,6 @@ void UHTTP::callAfterForkForAllUSP()
U_INTERNAL_ASSERT_POINTER(vusp) U_INTERNAL_ASSERT_POINTER(vusp)
U_INTERNAL_ASSERT(bcallInitForAllUSP) U_INTERNAL_ASSERT(bcallInitForAllUSP)
UServletPage* usp;
for (uint32_t i = 0, n = vusp->size(); i < n; ++i) for (uint32_t i = 0, n = vusp->size(); i < n; ++i)
{ {
usp = vusp->at(i); usp = vusp->at(i);

View File

@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in
DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include
EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest python \ EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest python sse_example \
*.properties *.test *.sh error_msg workflow doc_parse robots.txt alias.txt throttling.txt css js benchmark websocket docroot php.sh test_http_parser.h *.properties *.test *.sh error_msg workflow doc_parse robots.txt alias.txt throttling.txt css js benchmark websocket docroot php.sh test_http_parser.h
## DEFS = -DU_TEST @DEFS@ ## DEFS = -DU_TEST @DEFS@

View File

@ -624,7 +624,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
MAINTAINERCLEANFILES = Makefile.in MAINTAINERCLEANFILES = Makefile.in
DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include DEFAULT_INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/examples/http_header/include
EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest python \ EXTRA_DIST = inp ok CA CSP LCSP TSA RSIGN XAdES nocat wi-auth WAGSM RA IR/WEB IR/benchmark IR/doc_dir *.cfg .htpasswd .htdigest python sse_example \
*.properties *.test *.sh error_msg workflow doc_parse robots.txt alias.txt throttling.txt css js benchmark websocket docroot php.sh test_http_parser.h *.properties *.test *.sh error_msg workflow doc_parse robots.txt alias.txt throttling.txt css js benchmark websocket docroot php.sh test_http_parser.h
TESTS = client_server.test test_manager.test IR.test web_server.test \ TESTS = client_server.test test_manager.test IR.test web_server.test \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
<!--#declaration
static uint32_t counter;
static UString getPrice()
{
U_TRACE_NO_PARAM(5, "::getPrice()")
static double price = 1.2;
if (counter++)
{
price = price + (double)rand() / RAND_MAX * 2.0 - 1;
if (price <= 0.01) price = 0.01;
}
UString x = UStringExt::numberToString(price);
U_RETURN_STRING(x);
}
-->
<!--#ssecode
UHTTP::writeSSE(1, getPrice());
-->
<!--#sseloop:5
UHTTP::sendSSE(counter, getPrice());
-->

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="jquery.min.js"></script>
<title>SSE example</title>
</head>
<body>
<h1>Stock Price</h1>
<script type="text/javascript">
function read_data() {
var stream = new EventSource('/get_ticker');
stream.onmessage = function(e){
document.getElementById('price').innerHTML=e.data;
};
stream.onerror = function(e){
console.log(e);
};
}
read_data();
</script>
<p>Price: <span id="price"></span></p>
</body>

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,9 @@
(cd benchmark; rm -f db; creat_link FrameworkBenchmarks/ULib/db db) (cd benchmark; rm -f db; creat_link FrameworkBenchmarks/ULib/db db)
DOC_ROOT=sse_example
#DOC_ROOT=ruby/blog #DOC_ROOT=ruby/blog
DOC_ROOT=benchmark/docroot #DOC_ROOT=benchmark/docroot
rm -f tmp/usp_compile.sh.err /tmp/*.hpack.* \ rm -f tmp/usp_compile.sh.err /tmp/*.hpack.* \
$DOC_ROOT/web_server.log* \ $DOC_ROOT/web_server.log* \
@ -66,7 +67,7 @@ userver {
#LOAD_BALANCE_CLUSTER 10.30.0.1,10.30.0.2 #LOAD_BALANCE_CLUSTER 10.30.0.1,10.30.0.2
#LOAD_BALANCE_DEVICE_NETWORK enp0s20u1 #LOAD_BALANCE_DEVICE_NETWORK enp0s20u1
#LOAD_BALANCE_LOADAVG_THRESHOLD 4.0 #LOAD_BALANCE_LOADAVG_THRESHOLD 4.0
#PREFORK_CHILD 0 PREFORK_CHILD 0
#CRASH_COUNT 1 #CRASH_COUNT 1
#CRASH_EMAIL_NOTIFY mail.unirel.com:stefano.casazza@unirel.com #CRASH_EMAIL_NOTIFY mail.unirel.com:stefano.casazza@unirel.com
#DOS_SITE_COUNT 1 #DOS_SITE_COUNT 1
@ -75,14 +76,17 @@ userver {
#REQ_TIMEOUT 300 #REQ_TIMEOUT 300
#PLUGIN "ssi http" #PLUGIN "ssi http"
#ORM_DRIVER "sqlite mysql" #ORM_DRIVER "sqlite mysql"
ORM_DRIVER sqlite #ORM_DRIVER sqlite
DOCUMENT_ROOT sse_example
PLUGIN_DIR ../../../src/ulib/net/server/plugin/.libs
ORM_DRIVER_DIR ../../../src/ulib/orm/driver/.libs
#DOCUMENT_ROOT docroot #DOCUMENT_ROOT docroot
#PLUGIN_DIR ../../../src/ulib/net/server/plugin/.libs #PLUGIN_DIR ../../../src/ulib/net/server/plugin/.libs
#ORM_DRIVER_DIR ../../../src/ulib/orm/driver/.libs #ORM_DRIVER_DIR ../../../src/ulib/orm/driver/.libs
#DOCUMENT_ROOT JONATHAN/docroot #DOCUMENT_ROOT JONATHAN/docroot
DOCUMENT_ROOT benchmark/docroot #DOCUMENT_ROOT benchmark/docroot
PLUGIN_DIR ../../../../src/ulib/net/server/plugin/.libs #PLUGIN_DIR ../../../../src/ulib/net/server/plugin/.libs
ORM_DRIVER_DIR ../../../../src/ulib/orm/driver/.libs #ORM_DRIVER_DIR ../../../../src/ulib/orm/driver/.libs
#DOCUMENT_ROOT . #DOCUMENT_ROOT .
#PLUGIN_DIR ../../src/ulib/net/server/plugin/.libs #PLUGIN_DIR ../../src/ulib/net/server/plugin/.libs
#ORM_DRIVER_DIR ../../src/ulib/orm/driver/.libs #ORM_DRIVER_DIR ../../src/ulib/orm/driver/.libs
@ -101,7 +105,7 @@ http {
REQUEST_READ_TIMEOUT 30 REQUEST_READ_TIMEOUT 30
APACHE_LIKE_LOG /var/log/httpd/access_log APACHE_LIKE_LOG /var/log/httpd/access_log
LOG_FILE_SZ 10M LOG_FILE_SZ 10M
#DIGEST_AUTHENTICATION yes DIGEST_AUTHENTICATION no
#CACHE_FILE_STORE nocat/webif.gz #CACHE_FILE_STORE nocat/webif.gz
#CACHE_FILE_MASK inp/http/data/file1|*.flv|*.svgz #CACHE_FILE_MASK inp/http/data/file1|*.flv|*.svgz
#URI_REQUEST_STRICT_TRANSPORT_SECURITY_MASK * #URI_REQUEST_STRICT_TRANSPORT_SECURITY_MASK *

View File

@ -6,11 +6,12 @@ plugin/product1.lo: plugin/product1.cpp /usr/include/stdc-predef.h \
../../include/ulib/base/base.h ../../include/ulib/internal/config.h \ ../../include/ulib/base/base.h ../../include/ulib/internal/config.h \
../../include/ulib/internal/platform.h /usr/include/sys/mman.h \ ../../include/ulib/internal/platform.h /usr/include/sys/mman.h \
/usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/features.h /usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ /usr/include/bits/wordsize.h /usr/include/bits/long-double.h \
/usr/include/gnu/stubs-64.h /usr/include/bits/types.h \ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-64.h \
/usr/include/bits/typesizes.h /usr/include/bits/mman.h \ /usr/include/bits/types.h /usr/include/bits/typesizes.h \
/usr/include/bits/mman-linux.h /usr/include/stdio.h /usr/include/libio.h \ /usr/include/bits/mman.h /usr/include/bits/mman-linux.h \
/usr/include/_G_config.h /usr/include/wchar.h \ /usr/include/stdio.h /usr/include/bits/libc-header-start.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdarg.h \ /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdarg.h \
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
/usr/include/bits/stdio.h /usr/include/bits/stdio2.h \ /usr/include/bits/stdio.h /usr/include/bits/stdio2.h \
@ -19,15 +20,21 @@ plugin/product1.lo: plugin/product1.cpp /usr/include/stdc-predef.h \
/usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
/usr/include/bits/confname.h /usr/include/getopt.h \ /usr/include/bits/confname.h /usr/include/getopt.h \
/usr/include/bits/unistd.h /usr/include/sys/uio.h \ /usr/include/bits/unistd.h /usr/include/sys/uio.h \
/usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ /usr/include/sys/types.h /usr/include/bits/types/clock_t.h \
/usr/include/bits/types/clockid_t.h /usr/include/bits/types/time_t.h \
/usr/include/bits/types/timer_t.h /usr/include/endian.h \
/usr/include/bits/endian.h /usr/include/bits/byteswap.h \ /usr/include/bits/endian.h /usr/include/bits/byteswap.h \
/usr/include/bits/byteswap-16.h /usr/include/sys/select.h \ /usr/include/bits/byteswap-16.h /usr/include/bits/uintn-identity.h \
/usr/include/bits/select.h /usr/include/bits/sigset.h \ /usr/include/sys/select.h /usr/include/bits/select.h \
/usr/include/bits/time.h /usr/include/bits/select2.h \ /usr/include/bits/sigset.h /usr/include/bits/types/struct_timeval.h \
/usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ /usr/include/bits/types/struct_timespec.h /usr/include/bits/select2.h \
/usr/include/bits/uio.h /usr/include/sys/stat.h /usr/include/bits/stat.h \ /usr/include/sys/sysmacros.h /usr/include/bits/sysmacros.h \
/usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ /usr/include/bits/pthreadtypes.h /usr/include/bits/uio.h \
/usr/include/bits/timex.h /usr/include/xlocale.h \ /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/pthread.h \
/usr/include/sched.h /usr/include/bits/sched.h /usr/include/time.h \
/usr/include/bits/time.h /usr/include/bits/timex.h \
/usr/include/bits/types/struct_tm.h \
/usr/include/bits/types/struct_itimerspec.h /usr/include/xlocale.h \
/usr/include/bits/setjmp.h /usr/include/signal.h \ /usr/include/bits/setjmp.h /usr/include/signal.h \
/usr/include/bits/signum.h /usr/include/bits/siginfo.h \ /usr/include/bits/signum.h /usr/include/bits/siginfo.h \
/usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \
@ -46,8 +53,9 @@ plugin/product1.lo: plugin/product1.cpp /usr/include/stdc-predef.h \
/usr/include/ctype.h ../../include/ulib/base/replace/replace.h \ /usr/include/ctype.h ../../include/ulib/base/replace/replace.h \
/usr/src/linux/include/generated/uapi/linux/version.h \ /usr/src/linux/include/generated/uapi/linux/version.h \
/usr/include/openssl/opensslv.h /usr/include/string.h \ /usr/include/openssl/opensslv.h /usr/include/string.h \
/usr/include/bits/string3.h /usr/include/fcntl.h \ /usr/include/bits/string3.h /usr/include/bits/strings_fortified.h \
/usr/include/bits/fcntl.h /usr/include/bits/fcntl-linux.h \ /usr/include/fcntl.h /usr/include/bits/fcntl.h \
/usr/include/bits/fcntl-linux.h /usr/include/linux/falloc.h \
/usr/include/bits/fcntl2.h /usr/include/errno.h \ /usr/include/bits/fcntl2.h /usr/include/errno.h \
/usr/include/bits/errno.h /usr/include/linux/errno.h \ /usr/include/bits/errno.h /usr/include/linux/errno.h \
/usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \
@ -191,6 +199,8 @@ plugin/product.h:
/usr/include/bits/wordsize.h: /usr/include/bits/wordsize.h:
/usr/include/bits/long-double.h:
/usr/include/gnu/stubs.h: /usr/include/gnu/stubs.h:
/usr/include/gnu/stubs-64.h: /usr/include/gnu/stubs-64.h:
@ -205,6 +215,8 @@ plugin/product.h:
/usr/include/stdio.h: /usr/include/stdio.h:
/usr/include/bits/libc-header-start.h:
/usr/include/libio.h: /usr/include/libio.h:
/usr/include/_G_config.h: /usr/include/_G_config.h:
@ -243,7 +255,13 @@ plugin/product.h:
/usr/include/sys/types.h: /usr/include/sys/types.h:
/usr/include/time.h: /usr/include/bits/types/clock_t.h:
/usr/include/bits/types/clockid_t.h:
/usr/include/bits/types/time_t.h:
/usr/include/bits/types/timer_t.h:
/usr/include/endian.h: /usr/include/endian.h:
@ -253,18 +271,24 @@ plugin/product.h:
/usr/include/bits/byteswap-16.h: /usr/include/bits/byteswap-16.h:
/usr/include/bits/uintn-identity.h:
/usr/include/sys/select.h: /usr/include/sys/select.h:
/usr/include/bits/select.h: /usr/include/bits/select.h:
/usr/include/bits/sigset.h: /usr/include/bits/sigset.h:
/usr/include/bits/time.h: /usr/include/bits/types/struct_timeval.h:
/usr/include/bits/types/struct_timespec.h:
/usr/include/bits/select2.h: /usr/include/bits/select2.h:
/usr/include/sys/sysmacros.h: /usr/include/sys/sysmacros.h:
/usr/include/bits/sysmacros.h:
/usr/include/bits/pthreadtypes.h: /usr/include/bits/pthreadtypes.h:
/usr/include/bits/uio.h: /usr/include/bits/uio.h:
@ -279,8 +303,16 @@ plugin/product.h:
/usr/include/bits/sched.h: /usr/include/bits/sched.h:
/usr/include/time.h:
/usr/include/bits/time.h:
/usr/include/bits/timex.h: /usr/include/bits/timex.h:
/usr/include/bits/types/struct_tm.h:
/usr/include/bits/types/struct_itimerspec.h:
/usr/include/xlocale.h: /usr/include/xlocale.h:
/usr/include/bits/setjmp.h: /usr/include/bits/setjmp.h:
@ -339,12 +371,16 @@ plugin/product.h:
/usr/include/bits/string3.h: /usr/include/bits/string3.h:
/usr/include/bits/strings_fortified.h:
/usr/include/fcntl.h: /usr/include/fcntl.h:
/usr/include/bits/fcntl.h: /usr/include/bits/fcntl.h:
/usr/include/bits/fcntl-linux.h: /usr/include/bits/fcntl-linux.h:
/usr/include/linux/falloc.h:
/usr/include/bits/fcntl2.h: /usr/include/bits/fcntl2.h:
/usr/include/errno.h: /usr/include/errno.h:

View File

@ -6,11 +6,12 @@ plugin/product2.lo: plugin/product2.cpp /usr/include/stdc-predef.h \
../../include/ulib/base/base.h ../../include/ulib/internal/config.h \ ../../include/ulib/base/base.h ../../include/ulib/internal/config.h \
../../include/ulib/internal/platform.h /usr/include/sys/mman.h \ ../../include/ulib/internal/platform.h /usr/include/sys/mman.h \
/usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/features.h /usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ /usr/include/bits/wordsize.h /usr/include/bits/long-double.h \
/usr/include/gnu/stubs-64.h /usr/include/bits/types.h \ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-64.h \
/usr/include/bits/typesizes.h /usr/include/bits/mman.h \ /usr/include/bits/types.h /usr/include/bits/typesizes.h \
/usr/include/bits/mman-linux.h /usr/include/stdio.h /usr/include/libio.h \ /usr/include/bits/mman.h /usr/include/bits/mman-linux.h \
/usr/include/_G_config.h /usr/include/wchar.h \ /usr/include/stdio.h /usr/include/bits/libc-header-start.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdarg.h \ /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdarg.h \
/usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
/usr/include/bits/stdio.h /usr/include/bits/stdio2.h \ /usr/include/bits/stdio.h /usr/include/bits/stdio2.h \
@ -19,15 +20,21 @@ plugin/product2.lo: plugin/product2.cpp /usr/include/stdc-predef.h \
/usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
/usr/include/bits/confname.h /usr/include/getopt.h \ /usr/include/bits/confname.h /usr/include/getopt.h \
/usr/include/bits/unistd.h /usr/include/sys/uio.h \ /usr/include/bits/unistd.h /usr/include/sys/uio.h \
/usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ /usr/include/sys/types.h /usr/include/bits/types/clock_t.h \
/usr/include/bits/types/clockid_t.h /usr/include/bits/types/time_t.h \
/usr/include/bits/types/timer_t.h /usr/include/endian.h \
/usr/include/bits/endian.h /usr/include/bits/byteswap.h \ /usr/include/bits/endian.h /usr/include/bits/byteswap.h \
/usr/include/bits/byteswap-16.h /usr/include/sys/select.h \ /usr/include/bits/byteswap-16.h /usr/include/bits/uintn-identity.h \
/usr/include/bits/select.h /usr/include/bits/sigset.h \ /usr/include/sys/select.h /usr/include/bits/select.h \
/usr/include/bits/time.h /usr/include/bits/select2.h \ /usr/include/bits/sigset.h /usr/include/bits/types/struct_timeval.h \
/usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ /usr/include/bits/types/struct_timespec.h /usr/include/bits/select2.h \
/usr/include/bits/uio.h /usr/include/sys/stat.h /usr/include/bits/stat.h \ /usr/include/sys/sysmacros.h /usr/include/bits/sysmacros.h \
/usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ /usr/include/bits/pthreadtypes.h /usr/include/bits/uio.h \
/usr/include/bits/timex.h /usr/include/xlocale.h \ /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/pthread.h \
/usr/include/sched.h /usr/include/bits/sched.h /usr/include/time.h \
/usr/include/bits/time.h /usr/include/bits/timex.h \
/usr/include/bits/types/struct_tm.h \
/usr/include/bits/types/struct_itimerspec.h /usr/include/xlocale.h \
/usr/include/bits/setjmp.h /usr/include/signal.h \ /usr/include/bits/setjmp.h /usr/include/signal.h \
/usr/include/bits/signum.h /usr/include/bits/siginfo.h \ /usr/include/bits/signum.h /usr/include/bits/siginfo.h \
/usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \
@ -46,8 +53,9 @@ plugin/product2.lo: plugin/product2.cpp /usr/include/stdc-predef.h \
/usr/include/ctype.h ../../include/ulib/base/replace/replace.h \ /usr/include/ctype.h ../../include/ulib/base/replace/replace.h \
/usr/src/linux/include/generated/uapi/linux/version.h \ /usr/src/linux/include/generated/uapi/linux/version.h \
/usr/include/openssl/opensslv.h /usr/include/string.h \ /usr/include/openssl/opensslv.h /usr/include/string.h \
/usr/include/bits/string3.h /usr/include/fcntl.h \ /usr/include/bits/string3.h /usr/include/bits/strings_fortified.h \
/usr/include/bits/fcntl.h /usr/include/bits/fcntl-linux.h \ /usr/include/fcntl.h /usr/include/bits/fcntl.h \
/usr/include/bits/fcntl-linux.h /usr/include/linux/falloc.h \
/usr/include/bits/fcntl2.h /usr/include/errno.h \ /usr/include/bits/fcntl2.h /usr/include/errno.h \
/usr/include/bits/errno.h /usr/include/linux/errno.h \ /usr/include/bits/errno.h /usr/include/linux/errno.h \
/usr/include/asm/errno.h /usr/include/asm-generic/errno.h \ /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \
@ -191,6 +199,8 @@ plugin/product.h:
/usr/include/bits/wordsize.h: /usr/include/bits/wordsize.h:
/usr/include/bits/long-double.h:
/usr/include/gnu/stubs.h: /usr/include/gnu/stubs.h:
/usr/include/gnu/stubs-64.h: /usr/include/gnu/stubs-64.h:
@ -205,6 +215,8 @@ plugin/product.h:
/usr/include/stdio.h: /usr/include/stdio.h:
/usr/include/bits/libc-header-start.h:
/usr/include/libio.h: /usr/include/libio.h:
/usr/include/_G_config.h: /usr/include/_G_config.h:
@ -243,7 +255,13 @@ plugin/product.h:
/usr/include/sys/types.h: /usr/include/sys/types.h:
/usr/include/time.h: /usr/include/bits/types/clock_t.h:
/usr/include/bits/types/clockid_t.h:
/usr/include/bits/types/time_t.h:
/usr/include/bits/types/timer_t.h:
/usr/include/endian.h: /usr/include/endian.h:
@ -253,18 +271,24 @@ plugin/product.h:
/usr/include/bits/byteswap-16.h: /usr/include/bits/byteswap-16.h:
/usr/include/bits/uintn-identity.h:
/usr/include/sys/select.h: /usr/include/sys/select.h:
/usr/include/bits/select.h: /usr/include/bits/select.h:
/usr/include/bits/sigset.h: /usr/include/bits/sigset.h:
/usr/include/bits/time.h: /usr/include/bits/types/struct_timeval.h:
/usr/include/bits/types/struct_timespec.h:
/usr/include/bits/select2.h: /usr/include/bits/select2.h:
/usr/include/sys/sysmacros.h: /usr/include/sys/sysmacros.h:
/usr/include/bits/sysmacros.h:
/usr/include/bits/pthreadtypes.h: /usr/include/bits/pthreadtypes.h:
/usr/include/bits/uio.h: /usr/include/bits/uio.h:
@ -279,8 +303,16 @@ plugin/product.h:
/usr/include/bits/sched.h: /usr/include/bits/sched.h:
/usr/include/time.h:
/usr/include/bits/time.h:
/usr/include/bits/timex.h: /usr/include/bits/timex.h:
/usr/include/bits/types/struct_tm.h:
/usr/include/bits/types/struct_itimerspec.h:
/usr/include/xlocale.h: /usr/include/xlocale.h:
/usr/include/bits/setjmp.h: /usr/include/bits/setjmp.h:
@ -339,12 +371,16 @@ plugin/product.h:
/usr/include/bits/string3.h: /usr/include/bits/string3.h:
/usr/include/bits/strings_fortified.h:
/usr/include/fcntl.h: /usr/include/fcntl.h:
/usr/include/bits/fcntl.h: /usr/include/bits/fcntl.h:
/usr/include/bits/fcntl-linux.h: /usr/include/bits/fcntl-linux.h:
/usr/include/linux/falloc.h:
/usr/include/bits/fcntl2.h: /usr/include/bits/fcntl2.h:
/usr/include/errno.h: /usr/include/errno.h:

View File

@ -23,7 +23,7 @@ static bool WaitNValue(int value)
{ {
if (n == value) U_RETURN(true); if (n == value) U_RETURN(true);
UThread::nanosleep(10); UThread::nanosleep(100);
} }
U_RETURN(false); U_RETURN(false);
@ -39,7 +39,7 @@ static bool WaitChangeNValue(int value)
{ {
if (n != value) U_RETURN(true); if (n != value) U_RETURN(true);
UThread::nanosleep(10); UThread::nanosleep(100);
} }
U_RETURN(false); U_RETURN(false);