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

fix+brotli

This commit is contained in:
stefanocasazza 2017-09-28 16:51:51 +02:00
parent 4522e58477
commit cb3ff25402
74 changed files with 6459 additions and 5635 deletions

82
configure vendored
View File

@ -1071,6 +1071,7 @@ with_distcc
with_libz
enable_zip
with_libzopfli
with_libbrotli
with_magic
enable_ssl_staticlib_deps
with_ssl
@ -1839,6 +1840,7 @@ Optional Packages:
--with-distcc using distcc we must avoid to use some gcc flags (-mtune=native,-flto,...)
--with-libz use system LIBZ library - [will check /usr /usr/local] [default=use if present]
--with-libzopfli use system zopfli library - [will check /usr /usr/local] [default=use if present]
--with-libbrotli use system brotli library - [will check /usr /usr/local] [default=use if present]
--with-magic use system libmagic library - [will check /usr /usr/local] [default=use if present]
--with-ssl use system SSL library - [will check /usr /usr/local] [default=use if present]
--with-pcre use system PCRE library - [will check /usr /usr/local] [default=use if present]
@ -27659,6 +27661,7 @@ $as_echo "${T_MD}C++ stuff:${T_ME}" >&6; }
ulib_ldap_msg="no (--with-ldap)"
ulib_libz_msg="no (--with-libz)"
ulib_libzopfli_msg="no (--with-libzopfli)"
ulib_libbrotli_msg="no (--with-libbrotli)"
ulib_libtdb_msg="no (--with-libtdb)"
ulib_curl_msg="no (--with-curl)"
ulib_expat_msg="no (--with-expat)"
@ -28853,6 +28856,7 @@ $as_echo "$use_distcc" >&6; }
libz_version="unknow"
libzopfli_version="unknown"
libbrotli_version="unknown"
libtdb_version="unknown"
pcre_version="unknown"
ldap_version="unknown"
@ -29021,6 +29025,73 @@ $as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if brotli library is wanted" >&5
$as_echo_n "checking if brotli library is wanted... " >&6; }
wanted=1;
if test -z "$with_libbrotli" ; then
wanted=0;
if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO" -o "$enable_shared" = "no"; then
with_libbrotli="no";
else
with_libbrotli="${CROSS_ENVIRONMENT}/usr";
fi
fi
# Check whether --with-libbrotli was given.
if test "${with_libbrotli+set}" = set; then :
withval=$with_libbrotli;
if test "$withval" = "no"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do
libbrotlidir="$dir"
if test -f "$dir/include/brotli/encode.h"; then
found_libbrotli="yes";
break;
fi
done
if test x_$found_libbrotli != x_yes; then
msg="Cannot find libbrotli library";
if test $wanted = 1; then
as_fn_error $? "$msg" "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5
$as_echo "$msg" >&6; }
fi
else
echo "${T_MD}libbrotli found in $libbrotlidir${T_ME}"
USE_LIBBROTLI=yes
$as_echo "#define USE_LIBBROTLI 1" >>confdefs.h
if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then
libbrotli_version=$(pkg-config --modversion libbrotlienc 2>/dev/null)
fi
if test -z "${libbrotli_version}"; then
libbrotli_version=$(ls $libbrotlidir/lib*/libbrotli*.so.*.* 2>/dev/null | head -n 1 | awk -F'.so.' '{n=2; print $n}' 2>/dev/null)
fi
if test -z "${libzopfli_version}"; then
libzopfli_version="unknown"
fi
ULIB_LIBS="$ULIB_LIBS -lbrotlidec -lbrotlienc";
if test $libbrotlidir != "${CROSS_ENVIRONMENT}/" -a $libbrotlidir != "${CROSS_ENVIRONMENT}/usr" -a $libbrotlidir != "${CROSS_ENVIRONMENT}/usr/local"; then
CPPFLAGS="$CPPFLAGS -I$libbrotlidir/include"
LDFLAGS="$LDFLAGS -L$libbrotlidir/lib -Wl,-R$libbrotlidir/lib";
PRG_LDFLAGS="$PRG_LDFLAGS -L$libbrotlidir/lib";
fi
fi
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if MAGIC library is wanted" >&5
$as_echo_n "checking if MAGIC library is wanted... " >&6; }
wanted=1;
@ -30503,6 +30574,10 @@ if test "$USE_LIBZOPFLI" = "yes"; then
ulib_libzopfli_msg="yes ( $libzopfli_version )"
fi
if test "$USE_LIBBROTLI" = "yes"; then
ulib_libbrotli_msg="yes ( $libbrotli_version )"
fi
if test "$USE_LIBTDB" = "yes"; then
ulib_libtdb_msg="yes ( $libtdb_version )"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tdb_traverse_read in -ltdb" >&5
@ -31968,6 +32043,11 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
cat >>confdefs.h <<_ACEOF
#define _LIBBROTLI_VERSION "$libbrotli_version"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define _LIBTDB_VERSION "$libtdb_version"
_ACEOF
@ -35099,6 +35179,7 @@ ULIB_SYSCONFDIR="$u_sysconfdir"
LIBZ support: ${ulib_libz_msg}
LIBZOPFLI support: ${ulib_libzopfli_msg}
LIBBROTLI support: ${ulib_libbrotli_msg}
LIBTDB support: ${ulib_libtdb_msg}
PCRE support: ${ulib_pcre_msg}
SSL support: ${ulib_ssl_msg}
@ -35161,6 +35242,7 @@ $as_echo "$as_me: Configured to build src/ulib/lib${ULIB}:
LIBZ support: ${ulib_libz_msg}
LIBZOPFLI support: ${ulib_libzopfli_msg}
LIBBROTLI support: ${ulib_libbrotli_msg}
LIBTDB support: ${ulib_libtdb_msg}
PCRE support: ${ulib_pcre_msg}
SSL support: ${ulib_ssl_msg}

View File

@ -1203,6 +1203,7 @@ dnl initialize all the info variables to 'no'
ulib_ldap_msg="no (--with-ldap)"
ulib_libz_msg="no (--with-libz)"
ulib_libzopfli_msg="no (--with-libzopfli)"
ulib_libbrotli_msg="no (--with-libbrotli)"
ulib_libtdb_msg="no (--with-libtdb)"
ulib_curl_msg="no (--with-curl)"
ulib_expat_msg="no (--with-expat)"
@ -1354,6 +1355,7 @@ AC_MSG_RESULT($use_distcc)
libz_version="unknow"
libzopfli_version="unknown"
libbrotli_version="unknown"
libtdb_version="unknown"
pcre_version="unknown"
ldap_version="unknown"
@ -1409,6 +1411,10 @@ if test "$USE_LIBZOPFLI" = "yes"; then
ulib_libzopfli_msg="yes ( $libzopfli_version )"
fi
if test "$USE_LIBBROTLI" = "yes"; then
ulib_libbrotli_msg="yes ( $libbrotli_version )"
fi
if test "$USE_LIBTDB" = "yes"; then
ulib_libtdb_msg="yes ( $libtdb_version )"
AC_CHECK_LIB(tdb,tdb_traverse_read)
@ -1830,6 +1836,7 @@ AC_DEFINE_UNQUOTED(_LDAP_VERSION, "$ldap_version", [Ldap version])
AC_DEFINE_UNQUOTED(_EXPAT_VERSION, "$expat_version", [Expat version])
AC_DEFINE_UNQUOTED(_LIBZ_VERSION, "$libz_version", [libz - general purpose compression library version])
AC_DEFINE_UNQUOTED(_LIBZOPFLI_VERSION, "$libzopfli_version", [libzopfli - google compression library version])
AC_DEFINE_UNQUOTED(_LIBBROTLI_VERSION, "$libbrotli_version", [libbrotli - google compression library version])
AC_DEFINE_UNQUOTED(_LIBTDB_VERSION, "$libtdb_version", [libtdb - samba Trivial DB library version])
AC_DEFINE_UNQUOTED(_LIBSSH_VERSION, "$libssh_version", [libSSH version])
AC_DEFINE_UNQUOTED(_SSL_VERSION, "$ssl_version", [SSL version])
@ -2779,6 +2786,7 @@ AC_MSG_NOTICE([Configured to build src/ulib/lib${ULIB}:
LIBZ support: ${ulib_libz_msg}
LIBZOPFLI support: ${ulib_libzopfli_msg}
LIBBROTLI support: ${ulib_libbrotli_msg}
LIBTDB support: ${ulib_libtdb_msg}
PCRE support: ${ulib_pcre_msg}
SSL support: ${ulib_ssl_msg}

View File

@ -230,7 +230,7 @@ public:
U_RETURN(false);
}
static bool casellaUpdate(const UString& key)
static bool casellaUpdate(UString& key)
{
U_TRACE(5, "Application::casellaUpdate(%.*S)", U_STRING_TO_TRACE(key))
@ -380,7 +380,7 @@ public:
if (*ptipo == ' ')
{
(void) callForAllEntryField(U_destinatari, Application::casellaUpdate);
(void) callForAllEntryField(U_destinatari, (bPFstr)Application::casellaUpdate);
return;
}

View File

@ -103,8 +103,12 @@ extern U_EXPORT void runDynamicPage_wi_auth(int param);
POST_ENTRY(uploader)
};
U_http_info.nResponseCode = 0; // NB: it is used by server_plugin_ssi to continue processing with a shell script...
UHTTP::manageRequest(GET_table, U_NUM_ELEMENTS(GET_table), POST_table, U_NUM_ELEMENTS(POST_table));
if (U_http_info.nResponseCode == 0) (void) UClientImage_Base::environment->append(U_CONSTANT_TO_PARAM("HTTP_RESPONSE_CODE=0\n"));
UClientImage_Base::setRequestNoCache();

View File

@ -81,5 +81,9 @@ static UHTTP::service_info POST_table[] = { // NB: the table must be ordered alp
POST_ENTRY(uploader)
};
U_http_info.nResponseCode = 0; // NB: it is used by server_plugin_ssi to continue processing with a shell script...
UHTTP::manageRequest(GET_table, U_NUM_ELEMENTS(GET_table), POST_table, U_NUM_ELEMENTS(POST_table));
if (U_http_info.nResponseCode == 0) (void) UClientImage_Base::environment->append(U_CONSTANT_TO_PARAM("HTTP_RESPONSE_CODE=0\n"));
-->

View File

@ -77,9 +77,7 @@ public:
{
U_TRACE(5, "Element::setFileName(%.*S)", U_STRING_TO_TRACE(namefile))
filename = namefile;
filename.duplicate();
filename = namefile.copy();
namefile.clear();
}

View File

@ -316,12 +316,14 @@ extern U_EXPORT const char* restrict u_name_function;
/* MIME type identification */
static inline bool u_is_gz(int mime_index) { return (mime_index == U_gz); }
static inline bool u_is_br(int mime_index) { return (mime_index == U_br); }
static inline bool u_is_js(int mime_index) { return (mime_index == U_js); }
static inline bool u_is_css(int mime_index) { return (mime_index == U_css); }
static inline bool u_is_gif(int mime_index) { return (mime_index == U_gif); }
static inline bool u_is_jpg(int mime_index) { return (mime_index == U_jpg); }
static inline bool u_is_png(int mime_index) { return (mime_index == U_png); }
static inline bool u_is_flv(int mime_index) { return (mime_index == U_flv); }
static inline bool u_is_svg(int mime_index) { return (mime_index == U_svg); }
static inline bool u_is_html(int mime_index) { return (mime_index == U_html); }
static inline bool u_is_usp(int mime_index) { return (mime_index == U_usp); }
@ -344,8 +346,14 @@ static inline bool u_is_cacheable(int mime_index) { return (u_is_js(mime_index)
u_is_css(mime_index) ||
u_is_img(mime_index) ||
u_is_ssi(mime_index) ||
u_is_svg(mime_index) ||
u_is_html(mime_index)); }
static inline bool u_is_compressable(int mime_index) { return (u_is_ssi(mime_index) == false &&
u_is_gz( mime_index) == false &&
u_is_br( mime_index) == false); }
/**
* Print with format extension: bBCDHMNOPQrRSvVUYwW
* ----------------------------------------------------------------------------

View File

@ -207,8 +207,8 @@ enum AffermationType {
/* MIME type */
#define U_unknow -1
#define U_know 'K'
#define U_unknow -1
#define U_css 'c' /* text/css */
#define U_flv 'f' /* video/x-flv */
@ -217,10 +217,12 @@ enum AffermationType {
#define U_ico 'i' /* image/x-icon */
#define U_js 'j' /* application/javascript */
#define U_png 'p' /* image/png */
#define U_svg 's' /* image/svg+xml */
#define U_txt 't' /* text/plain */
#define U_jpg 'J' /* image/jpg */
#define U_gz 'Z' /* gzip */
#define U_br 'B' /* brotli */
/* MIME type for dynamic content */

View File

@ -26,8 +26,8 @@ extern "C" {
#endif
extern U_EXPORT int u_trace_fd;
extern U_EXPORT int u_trace_signal;
extern U_EXPORT int u_trace_suspend; /* on-off */
extern U_EXPORT bool u_trace_signal;
extern U_EXPORT char u_trace_tab[256]; /* 256 max indent */
extern U_EXPORT void* u_trace_mask_level;
extern U_EXPORT uint32_t u_trace_num_tab;
@ -37,7 +37,8 @@ U_EXPORT void u_trace_close(void);
U_EXPORT void u_trace_unlock(void);
U_EXPORT void u_trace_initFork(void);
U_EXPORT void u_trace_check_init(void);
U_EXPORT void u_trace_init(int bsignal);
U_EXPORT void u_print_status_trace(void);
U_EXPORT void u_trace_init(bool bsignal);
U_EXPORT void u_trace_handlerSignal(void);
U_EXPORT void u_trace_check_if_interrupt(void); /* check for context manage signal event - interrupt */
U_EXPORT int u_trace_check_if_active(int level);

View File

@ -178,8 +178,8 @@ public:
int32_t getNumArgument() const { return ncmd; }
int32_t getNumFileArgument() const { return nfile; }
UString getStringCommand() { return command; }
UString getStringEnvironment() { return environment; }
UString getStringCommand() { return command; }
UString getStringEnvironment() { return environment; }
void setCommand(const UString& cmd)
{
@ -307,7 +307,7 @@ protected:
static void outputCommandWithDialog(const UString& cmd, char** envp, UString* output, int fd_stdin, int fd_stderr, bool dialog);
private:
void setEnvironment(const UString& env) U_NO_EXPORT;
void setEnvironment(UString& env) U_NO_EXPORT;
inline void execute(bool flag_stdin, bool flag_stdout, bool flag_stderr) U_NO_EXPORT;
static bool wait() U_NO_EXPORT;

View File

@ -165,8 +165,6 @@ public:
return vec[--_length];
}
const void* pop_front() { return pop(); } // remove last element
// LIST OPERATIONS
void insert(uint32_t pos, const void* elem); // add elem before pos
@ -518,8 +516,6 @@ public:
U_RETURN_POINTER(elem, T);
}
T* pop_front() { return pop(); } // remove last element
// LIST OPERATIONS
void insert(uint32_t pos, const T* elem) // add elem before pos
@ -1072,8 +1068,6 @@ public:
U_RETURN_STRING(str);
}
UString pop_front() { return pop(); } // remove last element
// LIST OPERATIONS
void insert(uint32_t pos, const UString& str) // add elem before pos

View File

@ -288,7 +288,7 @@ public:
// Check if the column named \a id has NULL value
bool isNull(const UString& id)
bool isNull(UString& id)
{
U_TRACE(1, "UDBIRow::isNull(%V)", id.rep)

View File

@ -18,6 +18,7 @@
#include <ulib/internal/error.h>
#ifdef DEBUG
U_EXPORT void u_debug_print_info();
U_EXPORT void u_debug_exit(int exit_value);
U_EXPORT pid_t u_debug_fork( pid_t pid, int trace_active);
U_EXPORT pid_t u_debug_vfork(pid_t pid, int trace_active);

View File

@ -30,9 +30,9 @@ union uuvararg {
struct U_EXPORT USimulationError {
static bool flag_init;
static char* file_mem;
static uint32_t file_size;
static bool flag_init;
static char* file_mem;
static uint32_t file_size;
static union uuvararg var_arg; // buffer for return value (simulation of error)
static void init();

View File

@ -118,7 +118,7 @@ public:
static void close();
static void initFork();
static void init(bool flag, bool info);
static void init(bool flag);
static void U_EXPORT registerObject(UObjectDumpable* dumper); // Add the 'dumper' to the list of registered objects
static void U_EXPORT unregisterObject(const void* ptr_object); // Use 'ptr_object' to locate and remove the associated 'dumper' from the list of registered objects
@ -131,9 +131,9 @@ public:
static uint32_t dumpObject(char* buffer, uint32_t buffer_size, const void* ptr_object);
private:
static char* file_ptr;
static char* file_mem;
static char* file_limit;
static char* file_ptr;
static char* file_mem;
static char* file_limit;
static uint32_t file_size;
static char* lbuf;
@ -153,6 +153,8 @@ private:
static bool printObjLive(const UObjectDumpable* dumper) U_NO_EXPORT;
static int compareDumper(const void* dumper1, const void* dumper2) __pure U_NO_EXPORT;
static bool checkIfObject(const char* name_class, const void* ptr_object) __pure U_NO_EXPORT;
friend void u_debug_print_info();
};
#endif

View File

@ -2504,10 +2504,12 @@ next:
{
U_TRACE_NO_PARAM(5, "WiAuthUser::checkTypeUID()")
U_INTERNAL_ASSERT(*uid)
uint32_t sz = uid->size();
if (sz == 0) U_RETURN(false);
U_ASSERT_EQUALS(*uid, UStringExt::trim(*uid))
uint32_t sz = uid->size();
const char* ptr = uid->data();
isIP = u_isIPv4Addr(ptr, sz);
@ -4251,8 +4253,7 @@ static bool askNodogToLogoutUser(const UString& _ip, const UString& _mac, bool b
}
else
{
if (U_http_info.nResponseCode == 0 ||
U_http_info.nResponseCode == HTTP_MOVED_TEMP)
if (U_http_info.nResponseCode == HTTP_MOVED_TEMP)
{
// 4) (302) => (response from redirect to portal with request GET /info?... but portal NOT responding
@ -4280,7 +4281,7 @@ static bool askNodogToLogoutUser(const UString& _ip, const UString& _mac, bool b
U_RETURN(false);
}
U_INTERNAL_DUMP("U_http_info.nResponseCode = %d", U_http_info.nResponseCode)
U_INTERNAL_DUMP("U_http_info.nResponseCode = %u", U_http_info.nResponseCode)
}
// U_LOGGER("*** LOGOUT SUCCESS: UID(%v) IP(%v) MAC(%v) AP(%v) ***", uid->rep, _ip.rep, _mac.rep, ap_address->rep);

View File

@ -182,8 +182,17 @@ public:
// NB: the string can be not writable so path_relativ[path_relativ_len] can be != '\0'...
UString getName() const;
UString getDirName() const;
UString getName() const;
UString getDirName() const;
UString getDirParent() const
{
U_TRACE_NO_PARAM(0, "UFile::getDirParent()")
U_INTERNAL_ASSERT(S_ISDIR(st_mode))
return getDirName();
}
UString& getPath() { return pathname; }
UString getSuffix() const { return getSuffix(u_getsuffix(path_relativ, path_relativ_len)); }
char* getPathRelativ() const { return (char*)path_relativ; }
@ -1079,6 +1088,16 @@ protected:
void setPathRelativ(const UString* environment = U_NULLPTR);
void setPath(const UFile& file, char* buffer_path, const char* suffix, uint32_t len);
static uint32_t getMmapSize(uint32_t length)
{
U_TRACE(0, "UFile::getMmapSize(%u)", length)
length = ((length % PAGESIZE) == 0 ? length + PAGESIZE
: (length + U_PAGEMASK) & ~U_PAGEMASK);
U_RETURN(length);
}
UString getSuffix(const char* ptr) const
{
U_TRACE(0, "UFile::getSuffix(%p)", ptr)

View File

@ -220,6 +220,7 @@ extern U_EXPORT uclientimage_info u_clientimage_info;
#define U_http_method_type u_clientimage_info.http_info.method_type
#define U_line_terminator_len u_clientimage_info.flag.c[0]
#define U_ClientImage_state u_clientimage_info.flag.c[1]
#define U_ClientImage_close u_clientimage_info.flag.c[2]
#define U_ClientImage_request u_clientimage_info.flag.c[3]
@ -240,34 +241,30 @@ extern U_EXPORT uclientimage_info u_clientimage_info;
#define U_http_ip_client_len u_clientimage_info.http_info.flag[ 9]
#define U_http_content_type_len u_clientimage_info.http_info.flag[10]
#define U_http_accept_language_len u_clientimage_info.http_info.flag[11]
#define U_http_flag u_clientimage_info.http_info.flag[12]
#define U_http_flag u_clientimage_info.http_info.flag[12]
#define U_http_flag_save UHttpClient_Base::u_http_info_save.flag[12]
#define U_http_len_user1 u_clientimage_info.http_info.flag[13]
#define U_http_len_user2 u_clientimage_info.http_info.flag[14]
#define U_http_len_user3 u_clientimage_info.http_info.flag[15]
#define U_http_len_user1 u_clientimage_info.http_info.flag[13]
#define U_http_len_user2 u_clientimage_info.http_info.flag[14]
#define U_http_len_user3 u_clientimage_info.http_info.flag[15]
enum HttpRequestType {
HTTP_IS_KEEP_ALIVE = 0x0001,
HTTP_IS_DATA_CHUNKED = 0x0002,
HTTP_IS_ACCEPT_GZIP = 0x0004,
HTTP_IS_NOCACHE_FILE = 0x0008,
HTTP_IS_RESPONSE_GZIP = 0x0010,
HTTP_IS_REQUEST_NOSTAT = 0x0020,
HTTP_METHOD_NOT_IMPLEMENTED = 0x0040
HTTP_IS_KEEP_ALIVE = 0x01,
HTTP_IS_DATA_CHUNKED = 0x02,
HTTP_IS_ACCEPT_GZIP = 0x04,
HTTP_IS_ACCEPT_BROTLI = 0x08,
HTTP_IS_NOCACHE_FILE = 0x10,
HTTP_IS_REQUEST_NOSTAT = 0x20,
HTTP_METHOD_NOT_IMPLEMENTED = 0x40
};
#define U_http_keep_alive ((U_http_flag & HTTP_IS_KEEP_ALIVE) != 0)
#define U_http_data_chunked ((U_http_flag & HTTP_IS_DATA_CHUNKED) != 0)
#define U_http_is_accept_gzip ((U_http_flag & HTTP_IS_ACCEPT_GZIP) != 0)
#define U_http_is_accept_brotli ((U_http_flag & HTTP_IS_ACCEPT_BROTLI) != 0)
#define U_http_is_nocache_file ((U_http_flag & HTTP_IS_NOCACHE_FILE) != 0)
#define U_http_is_response_gzip ((U_http_flag & HTTP_IS_RESPONSE_GZIP) != 0)
#define U_http_is_request_nostat ((U_http_flag & HTTP_IS_REQUEST_NOSTAT) != 0)
#define U_http_method_not_implemented ((U_http_flag & HTTP_METHOD_NOT_IMPLEMENTED) != 0)
#define U_http_is_accept_gzip ((U_http_flag & HTTP_IS_ACCEPT_GZIP) != 0)
#define U_http_is_accept_gzip_save ((U_http_flag_save & HTTP_IS_ACCEPT_GZIP) != 0)
#define U_HTTP_INFO_INIT(c) (void) U_SYSCALL(memset, "%p,%d,%u", &(u_clientimage_info.http_info), c, sizeof(uhttpinfo))
#define U_HTTP_INFO_RESET(c) (void) U_SYSCALL(memset, "%p,%d,%u", &(u_clientimage_info.http_info.nResponseCode), c, 52)

View File

@ -702,6 +702,9 @@
/* Define if we have support for crc32 intrinsics */
#undef USE_HARDWARE_CRC32
/* Define if enable libbrotli support */
#undef USE_LIBBROTLI
/* Define if enable libcurl support */
#undef USE_LIBCURL
@ -962,6 +965,9 @@
/* Ldap version */
#undef _LDAP_VERSION
/* libbrotli - google compression library version */
#undef _LIBBROTLI_VERSION
/* libevent - event notification library version */
#undef _LIBEVENT_VERSION

View File

@ -181,8 +181,7 @@ protected:
uint32_t method_num;
bool bFollowRedirects, bproxy;
static bool server_context_flag;
static struct uhttpinfo u_http_info_save;
static bool server_context_flag, data_chunked;
bool sendRequestEngine();
bool parseRequest(uint32_t n);

View File

@ -121,7 +121,7 @@ public:
U_RETURN(false);
}
bool isAllowed(const UString& ip_client) { return isAllowed(ip_client.c_str()); }
bool isAllowed(UString& ip_client) { return isAllowed(ip_client.c_str()); }
bool isAllowed(in_addr_t client) __pure;
bool isAllowed(in_addr_t ifa_addr, in_addr_t ifa_netmask)

View File

@ -144,13 +144,13 @@ public:
// request state processing
enum RequestStatusType {
// NOT_FOUND = 0x0000,
FORBIDDEN = 0x0001,
NO_CACHE = 0x0002,
IN_FILE_CACHE = 0x0004,
ALREADY_PROCESSED = 0x0008,
FILE_CACHE_PROCESSED = 0x0010,
REQUEST_FROM_USERVER = 0x0020
// NOT_FOUND = 0x00,
FORBIDDEN = 0x01,
NO_CACHE = 0x02,
IN_FILE_CACHE = 0x04,
ALREADY_PROCESSED = 0x08,
FILE_CACHE_PROCESSED = 0x10,
REQUEST_FROM_USERVER = 0x20
};
static bool isRequestNotFound()
@ -168,48 +168,96 @@ public:
U_RETURN(false);
}
static void setRequestProcessed()
static bool isRequestAlreadyProcessed()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestProcessed()")
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestAlreadyProcessed()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
if ((U_ClientImage_request & ALREADY_PROCESSED) != 0) U_RETURN(true);
if ((U_ClientImage_request & ALREADY_PROCESSED) == 0) U_ClientImage_request |= ALREADY_PROCESSED;
U_RETURN(false);
}
static void setRequestNeedProcessing()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestNeedProcessing()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
U_ASSERT(isRequestAlreadyProcessed())
U_ClientImage_request &= ~ALREADY_PROCESSED;
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
}
static bool isRequestNeedProcessing()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestNeedProcessing()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
if ((U_ClientImage_request & ALREADY_PROCESSED) == 0) U_RETURN(true);
U_RETURN(false);
}
static bool isRequestAlreadyProcessed()
static void setRequestProcessed()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestAlreadyProcessed()")
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestProcessed()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
U_ASSERT(isRequestNeedProcessing())
if ((U_ClientImage_request & ALREADY_PROCESSED) != 0) U_RETURN(true);
U_ClientImage_request |= ALREADY_PROCESSED;
}
static bool isRequestForbidden()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestForbidden()")
if ((U_ClientImage_request & FORBIDDEN) != 0) U_RETURN(true);
U_RETURN(false);
}
static void setRequestForbidden()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestForbidden()")
U_ASSERT_EQUALS(isRequestForbidden(), false)
U_ClientImage_request |= FORBIDDEN;
}
static bool isRequestInFileCache()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestInFileCache()")
if ((U_ClientImage_request & IN_FILE_CACHE) != 0) U_RETURN(true);
U_RETURN(false);
}
static void setRequestInFileCache()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestInFileCache()")
U_ASSERT_EQUALS(isRequestInFileCache(), false)
U_ClientImage_request |= IN_FILE_CACHE;
}
static bool isRequestFileCacheProcessed()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestFileCacheProcessed()")
if ((U_ClientImage_request & FILE_CACHE_PROCESSED) != 0) U_RETURN(true);
U_RETURN(false);
}
static void setRequestFileCacheProcessed()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestFileCacheProcessed()")
U_ASSERT_EQUALS(isRequestFileCacheProcessed(), false)
U_ClientImage_request |= FILE_CACHE_PROCESSED;
}
static bool isRequestRedirected()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestRedirected()")
@ -227,66 +275,6 @@ public:
U_RETURN(false);
}
static void setRequestForbidden()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestForbidden()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
U_ClientImage_request |= FORBIDDEN | ALREADY_PROCESSED;
}
static bool isRequestForbidden()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestForbidden()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
if ((U_ClientImage_request & FORBIDDEN) != 0) U_RETURN(true);
U_RETURN(false);
}
static void setRequestInFileCache()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestInFileCache()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
U_ClientImage_request |= IN_FILE_CACHE | ALREADY_PROCESSED;
}
static bool isRequestInFileCache()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestInFileCache()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
if ((U_ClientImage_request & IN_FILE_CACHE) != 0) U_RETURN(true);
U_RETURN(false);
}
static void setRequestFileCacheProcessed()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestFileCacheProcessed()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
U_ClientImage_request |= FILE_CACHE_PROCESSED;
}
static bool isRequestFileCacheProcessed()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::isRequestFileCacheProcessed()")
U_INTERNAL_DUMP("U_ClientImage_request = %d %B", U_ClientImage_request, U_ClientImage_request)
if ((U_ClientImage_request & FILE_CACHE_PROCESSED) != 0) U_RETURN(true);
U_RETURN(false);
}
static void setRequestNoCache()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::setRequestNoCache()")

View File

@ -179,7 +179,7 @@ public:
static PKCS7* sign(const UString& data,
const UString& signcert,
const UString& pkey,
UString& pkey,
const UString& passwd,
const UString& certs, int flags = PKCS7_BINARY);

View File

@ -112,6 +112,7 @@ class UXMLEscape;
class UMimeHeader;
class UPop3Client;
class UHttpPlugIn;
class UProxyPlugIn;
class Application;
class UServer_Base;
class UHashMapNode;
@ -215,7 +216,7 @@ public:
}
bool isNullTerminated() const { return (str [_length] == '\0'); }
void setNullTerminated() const { ((char*)str)[_length] = '\0'; }
void setNullTerminated() { ((char*)str)[_length] = '\0'; }
uint32_t space() const
{
@ -1004,6 +1005,7 @@ private:
friend class UMimeHeader;
friend class UHttpPlugIn;
friend class Application;
friend class UProxyPlugIn;
friend class UHashMapNode;
friend class UServer_Base;
friend class UMongoDBClient;
@ -1741,9 +1743,22 @@ public:
// C-Style String
void setNullTerminated() const;
void setNullTerminated()
{
U_TRACE_NO_PARAM(0, "UString::setNullTerminated()")
const char* c_str() const
U_INTERNAL_ASSERT_MAJOR(rep->_length, 0)
if (writeable()) rep->setNullTerminated();
else
{
duplicate();
}
U_ASSERT_EQUALS(u__strlen(rep->str, __PRETTY_FUNCTION__), rep->_length)
}
const char* c_str()
{
U_TRACE_NO_PARAM(0, "UString::c_str()")
@ -1968,7 +1983,18 @@ public:
// set uniq
void duplicate() const;
void duplicate()
{
U_TRACE_NO_PARAM(0, "UString::duplicate()")
uint32_t sz = size();
U_INTERNAL_ASSERT_MAJOR(sz, 0)
_set(UStringRep::create(sz, sz, rep->str));
U_INTERNAL_ASSERT(invariant())
}
bool uniq() const { return rep->uniq(); }
bool writeable() const { return rep->writeable(); }

View File

@ -247,7 +247,7 @@ struct U_EXPORT UServices {
static UString getFileName(long hash, bool crl = false);
static ENGINE* loadEngine(const char* id, unsigned int flags);
static bool setupOpenSSLStore(const char* CAfile = U_NULLPTR, const char* CApath = U_NULLPTR, int store_flags = U_STORE_FLAGS);
static EVP_PKEY* loadKey(const UString& x, const char* format, bool _private = true, const char* password = U_NULLPTR, ENGINE* e = U_NULLPTR);
static EVP_PKEY* loadKey(UString& x, const char* format, bool _private = true, const char* password = U_NULLPTR, ENGINE* e = U_NULLPTR);
/**
* data is the data to be signed
@ -255,8 +255,8 @@ struct U_EXPORT UServices {
* passwd is the corresponsding password for the private key
*/
static bool verifySignature( int alg, const UString& data, const UString& signature, const UString& pkey, ENGINE* e = U_NULLPTR);
static UString getSignatureValue(int alg, const UString& data, const UString& pkey, const UString& passwd, int base64, ENGINE* e = U_NULLPTR);
static bool verifySignature( int alg, const UString& data, const UString& signature, UString& pkey, ENGINE* e = U_NULLPTR);
static UString getSignatureValue(int alg, const UString& data, UString& pkey, UString& passwd, int base64, ENGINE* e = U_NULLPTR);
#endif
};

View File

@ -19,6 +19,10 @@
#ifdef USE_LIBSSL
# include <openssl/pem.h>
#endif
#ifdef USE_LIBBROTLI
# include <brotli/encode.h>
# include <brotli/decode.h>
#endif
class U_EXPORT UStringExt {
public:
@ -64,6 +68,15 @@ public:
static UString compress(const UString& s) { return compress(U_STRING_TO_PARAM(s)); }
static UString decompress(const UString& s) { return decompress(U_STRING_TO_PARAM(s)); }
#ifdef USE_LIBBROTLI
static UString unbrotli(const char* s, uint32_t n);
static UString unbrotli(const UString& s) { return unbrotli(U_STRING_TO_PARAM(s)); }
static UString brotli(const char* s, uint32_t n, uint32_t quality = BROTLI_MAX_QUALITY, uint32_t mode = BROTLI_MODE_TEXT, uint32_t lgwin = BROTLI_DEFAULT_WINDOW);
static UString brotli(const UString& s, uint32_t quality = BROTLI_MAX_QUALITY, uint32_t mode = BROTLI_MODE_TEXT, uint32_t lgwin = BROTLI_DEFAULT_WINDOW)
{ return brotli(U_STRING_TO_PARAM(s), quality, mode, lgwin); }
#endif
// GZIP method
static bool isGzip(const char* s) { return (u_get_unalignedp16(s) == U_MULTICHAR_CONSTANT16('\x1F','\x8B')); }

View File

@ -193,11 +193,11 @@ public:
static void setStatusDescription();
static void setEndRequestProcessing();
static bool callService(const UString& path);
static void checkContentLength(uint32_t length);
static bool isUriRequestNeedCertificate() __pure;
static bool isValidMethod(const char* ptr) __pure;
static bool checkContentLength(const UString& response);
static bool manageSendfile(const char* ptr, uint32_t len);
static bool checkContentLength(uint32_t length, uint32_t pos);
static bool scanfHeaderRequest(const char* ptr, uint32_t size);
static bool scanfHeaderResponse(const char* ptr, uint32_t size);
static bool readHeaderResponse(USocket* socket, UString& buffer);
@ -294,35 +294,6 @@ public:
U_RETURN(agent);
}
static void setPathName()
{
U_TRACE_NO_PARAM(0, "UHTTP::setPathName()")
U_INTERNAL_ASSERT(pathname->empty())
U_ASSERT(pathname->capacity() >= u_cwd_len + U_http_info.uri_len)
char* ptr = pathname->data();
U_MEMCPY(ptr, u_cwd, u_cwd_len);
U_MEMCPY(ptr+u_cwd_len, U_http_info.uri, U_http_info.uri_len);
pathname->size_adjust_force(u_cwd_len + U_http_info.uri_len); // NB: pathname can be referenced by file obj...
}
static void checkForPathName()
{
U_TRACE_NO_PARAM(0, "UHTTP::checkForPathName()")
if (pathname->empty())
{
setPathName();
file->setPath(*pathname);
U_INTERNAL_DUMP("file = %.*S", U_FILE_TO_TRACE(*file))
}
}
static bool isSizeForSendfile(uint32_t sz)
{
U_TRACE(0, "UHTTP::isSizeForSendfile(%u)", sz)
@ -930,7 +901,7 @@ public:
if (relocated) UMemoryPool::_free(relocated, size, 1);
}
bool compile(const UString& program);
bool compile(UString& program);
// DEBUG
@ -1127,9 +1098,9 @@ public:
U_MEMORY_DEALLOCATOR
void* ptr; // data
UVector<UString>* array; // content, header, gzip(content, header)
UVector<UString>* array; // content, header, gzip(content, header), brotli(content, header)
#ifndef U_HTTP2_DISABLE
UVector<UString>* http2; // header, gzip(header)
UVector<UString>* http2; // header, gzip( header), brotli( header)
#endif
time_t mtime; // time of last modification
time_t expire; // expire time of the entry
@ -1183,18 +1154,6 @@ public:
U_RETURN(false);
}
static bool isDataCompressFromCache()
{
U_TRACE_NO_PARAM(0, "UHTTP::isDataCompressFromCache()")
U_INTERNAL_ASSERT_POINTER(file_data)
U_INTERNAL_ASSERT_POINTER(file_data->array)
if (file_data->array->size() > 2) U_RETURN(true);
U_RETURN(false);
}
static void checkFileForCache();
static void renewFileDataInCache();
@ -1203,15 +1162,13 @@ public:
{
U_TRACE(0, "UHTTP::checkFileInCache(%.*S,%u)", len, path, len)
file_data = cache_file->at(path, len);
if (file_data)
if ((file_data = cache_file->at(path, len)))
{
file->st_size = file_data->size;
file->st_mode = file_data->mode;
file->st_mtime = file_data->mtime;
U_INTERNAL_DUMP("file_data->fd = %d st_size = %I st_mtime = %ld dir() = %b", file_data->fd, file->st_size, file->st_mtime, file->dir())
U_DUMP("file_data->fd = %d st_size = %I st_mtime = %#3D dir() = %b", file_data->fd, file->st_size, file->st_mtime, file->dir())
U_RETURN(true);
}
@ -1241,61 +1198,56 @@ public:
U_RETURN(false);
}
static UString getDataFromCache(int idx);
static UString getDataFromCache(UVector<UString>* array, uint32_t idx)
{
U_TRACE(0, "UHTTP::getDataFromCache(%p,%u)", array, idx)
static UString getBodyFromCache() { return getDataFromCache(0); }
static UString getBodyCompressFromCache() { return getDataFromCache(2); }
U_INTERNAL_ASSERT_MINOR(idx, 6)
U_INTERNAL_DUMP("U_http_version = %C", U_http_version)
if (array &&
idx < array->size())
{
UString result = array->at(idx);
U_RETURN_STRING(result);
}
return UString::getStringNull();
}
#ifdef U_HTTP2_DISABLE
static UString getHeaderFromCache() { return getDataFromCache(1); };
static UString getHeaderCompressFromCache() { return getDataFromCache(3); };
static UString getHeaderFromCache(uint32_t idx) { return getDataFromCache(file_data->array, idx); }
#else
static UString getHeaderFromCache()
{
U_TRACE_NO_PARAM(0, "UHTTP::getHeaderFromCache()")
UString result;
U_INTERNAL_DUMP("U_http_version = %C", U_http_version)
if (U_http_version != '2') result = getDataFromCache(1);
else if (file_data->http2) result = file_data->http2->operator[](0);
U_RETURN_STRING(result);
}
static UString getHeaderCompressFromCache()
{
U_TRACE_NO_PARAM(0, "UHTTP::getHeaderCompressFromCache()")
UString result;
U_INTERNAL_DUMP("U_http_version = %C", U_http_version)
if (U_http_version != '2') result = getDataFromCache(3);
else if (file_data->http2) result = file_data->http2->operator[](1);
U_RETURN_STRING(result);
}
static UString getHeaderFromCache(uint32_t idx) { return getDataFromCache((U_http_version != '2' ? file_data->array : (idx /= 2, file_data->http2)), idx); }
#endif
static UString getBodyFromCache() { return getDataFromCache(file_data->array, 0); }
static UString getHeaderFromCache() { return getHeaderFromCache(1); }
static UString getBodyCompressFromCache() { return getDataFromCache(file_data->array, 2); }
static UString getHeaderCompressFromCache() { return getHeaderFromCache(3); }
static UString getBodyCompressBrotliFromCache() { return getDataFromCache(file_data->array, 4); }
static UString getHeaderCompressBrotliFromCache() { return getHeaderFromCache(5); }
static UString contentOfFromCache(const char* path, uint32_t len)
{
U_TRACE(0, "UHTTP::contentOfFromCache(%.*S,%u)", len, path, len)
UString result;
if ((file_data = cache_file->at(path, len)))
{
UString result = getBodyFromCache();
file_data = cache_file->at(path, len);
U_RETURN_STRING(result);
}
if (file_data) result = getBodyFromCache();
U_RETURN_STRING(result);
return UString::getStringNull();
}
static UString contentOfFromCache(const UString& path) { return contentOfFromCache(U_STRING_TO_PARAM(path)); }
private:
static uint32_t old_response_code;
static uint32_t old_response_code, is_response_compressed;
static void setMimeIndex()
{
@ -1387,30 +1339,35 @@ private:
static bool checkForInotifyDirectory(UStringRep* key, void* value) U_NO_EXPORT;
#endif
#if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
static inline void setAcceptEncoding(const char* ptr, uint32_t len) U_NO_EXPORT;
#endif
#ifdef U_STATIC_ONLY
static void loadStaticLinkedServlet(const char* name, uint32_t len, vPFi runDynamicPage) U_NO_EXPORT;
#endif
static bool callService() U_NO_EXPORT;
static void checkPathName() U_NO_EXPORT;
static bool checkPathName() U_NO_EXPORT;
static void checkIPClient() U_NO_EXPORT;
static bool runDynamicPage() U_NO_EXPORT;
static bool readBodyRequest() U_NO_EXPORT;
static bool processFileCache() U_NO_EXPORT;
static bool readHeaderRequest() U_NO_EXPORT;
static bool processGetRequest() U_NO_EXPORT;
static void processDataFromCache() U_NO_EXPORT;
static bool checkRequestForHeader() U_NO_EXPORT;
static bool checkGetRequestIfRange() U_NO_EXPORT;
static bool checkGetRequestIfModified() U_NO_EXPORT;
static void setCGIShellScript(UString& command) U_NO_EXPORT;
static bool checkIfSourceHasChangedAndCompileUSP() U_NO_EXPORT;
static void setResponseCompressed(const UString& data) U_NO_EXPORT;
static bool compileUSP(const char* path, uint32_t len) U_NO_EXPORT;
static int checkGetRequestForRange(const UString& data) U_NO_EXPORT;
static int sortRange(const void* a, const void* b) __pure U_NO_EXPORT;
static bool addHTTPVariables(UStringRep* key, void* value) U_NO_EXPORT;
static void setSendfile(int fd, uint32_t start, uint32_t count) U_NO_EXPORT;
static bool splitCGIOutput(const char*& ptr1, const char* ptr2) U_NO_EXPORT;
static void putDataInCache(const UString& fmt, UString& content) U_NO_EXPORT;
static void setHeaderForCache(UFileCacheData* ptr, const UString& data) U_NO_EXPORT;
static bool readDataChunked(USocket* sk, UString* pbuffer, UString& body) U_NO_EXPORT;
static void setResponseForRange(uint32_t start, uint32_t end, uint32_t header) U_NO_EXPORT;
static void manageDataForCache(const UString& basename, const UString& suffix) U_NO_EXPORT;
@ -1420,9 +1377,10 @@ private:
static inline void resetFileCache() U_NO_EXPORT;
static inline void setUpgrade(const char* ptr) U_NO_EXPORT;
static inline bool checkPathName(uint32_t len) U_NO_EXPORT;
static inline bool checkGetRequestIfModified() U_NO_EXPORT;
static inline void setIfModSince(const char* ptr) U_NO_EXPORT;
static inline void setConnection(const char* ptr) U_NO_EXPORT;
static void setAcceptEncoding(const char* ptr) U_NO_EXPORT;
static inline bool setSendfile(int fd, uint32_t start, uint32_t count) U_NO_EXPORT;
static inline void setContentLength(const char* ptr1, const char* ptr2) U_NO_EXPORT;
static inline bool checkDataChunked(UString* pbuffer) U_NO_EXPORT;
@ -1443,6 +1401,10 @@ private:
friend class USSIPlugIn;
friend class UHttpPlugIn;
friend class UClientImage_Base;
#ifdef U_STDCPP_ENABLE
friend istream& operator>>(istream&, UHTTP::UFileCacheData&);
#endif
};
template <> inline void u_destroy(const UHTTP::UFileCacheData* elem)

View File

@ -108,6 +108,59 @@ AC_DEFUN([AC_CHECK_PACKAGE],[
fi
], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(if brotli library is wanted)
wanted=1;
if test -z "$with_libbrotli" ; then
wanted=0;
if test -n "$CROSS_ENVIRONMENT" -o "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO" -o "$enable_shared" = "no"; then
with_libbrotli="no";
else
with_libbrotli="${CROSS_ENVIRONMENT}/usr";
fi
fi
AC_ARG_WITH(libbrotli, [ --with-libbrotli use system brotli library - [[will check /usr /usr/local]] [[default=use if present]]], [
if test "$withval" = "no"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
for dir in $withval ${CROSS_ENVIRONMENT}/ ${CROSS_ENVIRONMENT}/usr ${CROSS_ENVIRONMENT}/usr/local; do
libbrotlidir="$dir"
if test -f "$dir/include/brotli/encode.h"; then
found_libbrotli="yes";
break;
fi
done
if test x_$found_libbrotli != x_yes; then
msg="Cannot find libbrotli library";
if test $wanted = 1; then
AC_MSG_ERROR($msg)
else
AC_MSG_RESULT($msg)
fi
else
echo "${T_MD}libbrotli found in $libbrotlidir${T_ME}"
USE_LIBBROTLI=yes
AC_DEFINE(USE_LIBBROTLI, 1, [Define if enable libbrotli support])
if test -z "$CROSS_ENVIRONMENT" -a x_$PKG_CONFIG != x_no; then
libbrotli_version=$(pkg-config --modversion libbrotlienc 2>/dev/null)
fi
if test -z "${libbrotli_version}"; then
libbrotli_version=$(ls $libbrotlidir/lib*/libbrotli*.so.*.* 2>/dev/null | head -n 1 | awk -F'.so.' '{n=2; print $n}' 2>/dev/null)
fi
if test -z "${libzopfli_version}"; then
libzopfli_version="unknown"
fi
ULIB_LIBS="$ULIB_LIBS -lbrotlidec -lbrotlienc";
if test $libbrotlidir != "${CROSS_ENVIRONMENT}/" -a $libbrotlidir != "${CROSS_ENVIRONMENT}/usr" -a $libbrotlidir != "${CROSS_ENVIRONMENT}/usr/local"; then
CPPFLAGS="$CPPFLAGS -I$libbrotlidir/include"
LDFLAGS="$LDFLAGS -L$libbrotlidir/lib -Wl,-R$libbrotlidir/lib";
PRG_LDFLAGS="$PRG_LDFLAGS -L$libbrotlidir/lib";
fi
fi
fi
], [AC_MSG_RESULT(no)])
AC_MSG_CHECKING(if MAGIC library is wanted)
wanted=1;
if test -z "$with_magic" ; then

View File

@ -19,8 +19,8 @@
#include <ulib/base/utility.h>
int u_trace_fd = -1;
int u_trace_signal;
int u_trace_suspend;
bool u_trace_signal;
char u_trace_tab[256]; /* 256 max indent */
void* u_trace_mask_level;
uint32_t u_trace_num_tab;
@ -47,27 +47,6 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
*/
static void printInfo(void)
{
U_INTERNAL_TRACE("printInfo()")
/* print info about debug mode */
if (u_trace_fd == -1)
{
U_MESSAGE("TRACE%W<%Woff%W>%W", YELLOW, RED, YELLOW, RESET);
}
else
{
U_MESSAGE("TRACE%W<%Won%W>: Level<%W%d%W> MaxSize<%W%d%W> Test<%W%d%W>%W", YELLOW,
GREEN, YELLOW,
CYAN, level_active, YELLOW,
CYAN, file_size, YELLOW,
CYAN, u_flag_test, YELLOW,
RESET);
}
}
static char* restrict file_mem;
static char* restrict file_ptr;
static char* restrict file_limit;
@ -86,10 +65,9 @@ void u_trace_check_if_interrupt(void) /* check for context manage signal event -
void u_trace_lock(void)
{
U_INTERNAL_TRACE("u_trace_lock()")
#ifdef ENABLE_THREAD
uint32_t tid = u_gettid();
# ifdef _MSWINDOWS_
if (old_tid == 0) InitializeCriticalSection(&mutex);
@ -98,6 +76,8 @@ void u_trace_lock(void)
(void) pthread_mutex_lock(&mutex);
# endif
U_INTERNAL_TRACE("u_trace_lock()")
if (old_tid != tid)
{
char tid_buffer[32];
@ -205,8 +185,6 @@ void u_trace_close(void)
}
}
/* we can mask trace by hi-byte param 'level' */
static int flag_init;
static struct sigaction act;
@ -228,7 +206,7 @@ static void setHandlerSIGUSR2(void)
(void) sigaction(SIGUSR2, &act, 0);
}
void u_trace_init(int bsignal)
void u_trace_init(bool bsignal)
{
const char* env;
@ -252,8 +230,8 @@ void u_trace_init(int bsignal)
}
}
if (bsignal == 0 &&
( env == 0 ||
if (bsignal == false &&
( env == U_NULLPTR ||
*env == '\0'))
{
level_active = -1;
@ -289,7 +267,7 @@ void u_trace_init(int bsignal)
if (level_active >= 0)
{
u_trace_mask_level = 0; /* NB: check necessary for incoherent state... */
u_trace_mask_level = 0; /* NB: reset necessary for incoherent state... */
if (u_trace_fd == STDERR_FILENO) file_size = 0;
else
@ -326,7 +304,7 @@ void u_trace_init(int bsignal)
return;
}
/* NB: include also PROT_READ seem to avoid some strange SIGSEGV... */
/* NB: to include also PROT_READ seem to avoid some strange SIGSEGV... */
file_mem = (char* restrict) mmap(0, file_size, PROT_READ | PROT_WRITE, MAP_SHARED, u_trace_fd, 0);
@ -346,7 +324,9 @@ void u_trace_init(int bsignal)
if (u_trace_fd > STDERR_FILENO) u_atexit(&u_trace_close); /* register function of close trace at exit... */
}
# ifndef _MSWINDOWS_
setHandlerSIGUSR2(); /* on-off by signal SIGUSR2 */
# endif
}
void u_trace_handlerSignal(void)
@ -364,26 +344,50 @@ void u_trace_handlerSignal(void)
u_trace_close();
level_active = -1;
# ifndef _MSWINDOWS_
setHandlerSIGUSR2(); /* on-off by signal SIGUSR2 */
# endif
}
printInfo();
# ifndef _MSWINDOWS_
setHandlerSIGUSR2(); /* on-off by signal SIGUSR2 */
# endif
#endif
u_trace_signal = 0;
}
void u_print_status_trace(void)
{
U_INTERNAL_TRACE("u_print_status_trace()")
if (u_trace_fd == -1)
{
U_MESSAGE("TRACE%W<%Woff%W>%W", YELLOW, RED, YELLOW, RESET);
}
else
{
U_MESSAGE("TRACE%W<%Won%W>: Level<%W%d%W> MaxSize<%W%d%W> Test<%W%d%W>%W", YELLOW,
GREEN, YELLOW,
CYAN, level_active, YELLOW,
CYAN, file_size, YELLOW,
CYAN, u_flag_test, YELLOW,
RESET);
}
}
/* we can mask trace by hi-byte param 'level' */
int u_trace_check_if_active(int level)
{
U_INTERNAL_TRACE("u_trace_check_if_active(%d)", level)
int trace_active;
if (flag_init == 0) u_trace_init(0);
else if (u_trace_signal) u_trace_handlerSignal();
if (flag_init == 0) u_trace_init(false);
else if (u_trace_signal)
{
u_trace_signal = false;
u_trace_handlerSignal();
u_print_status_trace();
}
U_INTERNAL_PRINT("u_trace_fd = %d level_active = %d u_trace_mask_level = %p", u_trace_fd, level_active, u_trace_mask_level)
@ -414,22 +418,20 @@ void u_trace_check_init(void)
}
else
{
u_trace_init(0);
u_trace_init(false);
}
printInfo();
}
void u_trace_dump(const char* restrict format, uint32_t fmt_size, ...)
{
U_INTERNAL_TRACE("u_trace_dump(%.*s,%u)", fmt_size, format, fmt_size)
char buffer[8192];
uint32_t buffer_len;
va_list argp;
va_start(argp, fmt_size);
U_INTERNAL_TRACE("u_trace_dump(%.*s,%u)", fmt_size, format, fmt_size)
buffer_len = u__vsnprintf(buffer, sizeof(buffer), format, fmt_size, argp);
va_end(argp);
@ -446,10 +448,10 @@ void u_trace_dump(const char* restrict format, uint32_t fmt_size, ...)
void u_trace_initFork(void)
{
int bsignal = (u_trace_fd != -1);
U_INTERNAL_TRACE("u_trace_initFork()")
bool bsignal = (u_trace_fd != -1);
if (u_trace_fd > STDERR_FILENO)
{
if (file_size)
@ -463,8 +465,6 @@ void u_trace_initFork(void)
}
u_trace_init(bsignal);
printInfo();
}
/*

View File

@ -4832,7 +4832,6 @@ static struct mimeentry mimetab_r[] = {
};
static struct mimeentry mimetab_s[] = {
MIME_ENTRY( "svg", "image/svg+xml" ), /* (svg, svgz) */
MIME_ENTRY( "swf", "application/x-shockwave-flash" ),
MIME_ENTRY( "sgm", "text/sgml" ), /* (sgml) */
MIME_ENTRY( "sh", "application/x-sh" ),
@ -5023,6 +5022,7 @@ const char* u_get_mimetype(const char* restrict suffix, int* pmime_index)
case U_MULTICHAR_CONSTANT32('c','s','p',0):
case U_MULTICHAR_CONSTANT32('c','g','i',0):
case U_MULTICHAR_CONSTANT32('p','h','p',0):
case U_MULTICHAR_CONSTANT32('s','v','g',0):
{
if (pmime_index)
{
@ -5032,6 +5032,7 @@ const char* u_get_mimetype(const char* restrict suffix, int* pmime_index)
case U_MULTICHAR_CONSTANT32('u','s','p',0): *pmime_index = U_usp; break;
case U_MULTICHAR_CONSTANT32('c','s','p',0): *pmime_index = U_csp; break;
case U_MULTICHAR_CONSTANT32('c','g','i',0): *pmime_index = U_cgi; break;
case U_MULTICHAR_CONSTANT32('s','v','g',0): *pmime_index = U_svg; return "image/svg+xml";
case U_MULTICHAR_CONSTANT32('p','h','p',0): *pmime_index = U_php; return "application/x-httpd-php";
}
}
@ -5048,6 +5049,12 @@ const char* u_get_mimetype(const char* restrict suffix, int* pmime_index)
return "application/x-gzip";
}
case U_MULTICHAR_CONSTANT16('b','r'):
{
if (pmime_index) *pmime_index = U_br;
return "application/x-brotli";
}
case U_MULTICHAR_CONSTANT16('p','l'):
{
if (pmime_index) *pmime_index = U_perl;

View File

@ -91,8 +91,6 @@ void UCommand::setCommand()
{
U_TRACE_NO_PARAM(0, "UCommand::setCommand()")
U_INTERNAL_ASSERT(command)
command.duplicate();
freeCommand();
@ -158,7 +156,7 @@ int32_t UCommand::setEnvironment(const UString& env, char**& _envp)
U_RETURN(_nenv);
}
U_NO_EXPORT void UCommand::setEnvironment(const UString& env)
U_NO_EXPORT void UCommand::setEnvironment(UString& env)
{
U_TRACE(0, "UCommand::setEnvironment(%V)", env.rep)

View File

@ -286,9 +286,10 @@ void UDBI::bind(const UString& v, bool is_null)
else if (v.empty()) (void) escaped_query.append(U_CONSTANT_TO_PARAM("''"));
else
{
char* new_str;
U_INTERNAL_ASSERT(v.isNullTerminated())
const char* ptr = v.c_str();
char* new_str;
const char* ptr = v.data();
size_t sz = U_SYSCALL(dbi_conn_quote_string_copy, "%p,%S,%p", conn, ptr, &new_str);

View File

@ -88,13 +88,28 @@ extern "C" void U_EXPORT u_debug_at_exit(void)
}
}
static void print_info(void)
void U_EXPORT u_debug_print_info()
{
U_INTERNAL_TRACE("u_debug_print_info()")
// print program mode and info for ULib...
char* memusage = getenv("UMEMUSAGE");
U_MESSAGE("DEBUG MODE%W (pid %W%P%W) - " PACKAGE_STRING " " PLATFORM_VAR " (" __DATE__ ")%W", YELLOW, BRIGHTCYAN, YELLOW, RESET);
char* memusage = getenv("UMEMUSAGE");
u_print_status_trace();
#ifdef U_STDCPP_ENABLE
if (UObjectDB::fd == -1)
{
U_MESSAGE("OBJDUMP%W<%Woff%W>%W", YELLOW, RED, YELLOW, RESET);
}
else
{
U_MESSAGE("OBJDUMP%W<%Won%W>: Level<%W%d%W> MaxSize<%W%d%W>%W", YELLOW, GREEN, YELLOW, CYAN, UObjectDB::level_active, YELLOW, CYAN, UObjectDB::file_size, YELLOW, RESET);
}
#endif
U_MESSAGE("MEMUSAGE%W<%W%s%W>%W", YELLOW, (memusage ? GREEN : RED), (memusage ? "on" : "off"), YELLOW, RESET);
}
@ -103,18 +118,15 @@ extern "C" void U_EXPORT u_debug_init(void)
{
U_INTERNAL_TRACE("u_debug_init()")
print_info();
USimulationError::init();
#ifdef U_STDCPP_ENABLE
UObjectDB::init(true, true);
UObjectDB::init(true);
#endif
// we go to check if there are previous creation of global
// objects that can have forced the initialization of trace file...
u_trace_check_init(); // we go to check if there are previous creation of global objects that can have forced the initialization of trace file...
u_trace_check_init();
u_debug_print_info();
USimulationError::init();
}
// set_memlimit() uses setrlimit() to restrict dynamic memory allocation.
@ -160,13 +172,13 @@ pid_t U_EXPORT u_debug_fork(pid_t _pid, int trace_active)
{
u_setPid();
print_info(); // print program mode and info for ULib...
u_trace_initFork();
# ifdef U_STDCPP_ENABLE
if (UObjectDB::fd > 0) UObjectDB::initFork();
# endif
u_debug_print_info();
}
if (trace_active)

View File

@ -304,9 +304,9 @@ U_NO_EXPORT uint32_t UHashMapObjectDumpable::table_size;
UHashMapObjectDumpable* UHashMapObjectDumpable::node;
UHashMapObjectDumpable** UHashMapObjectDumpable::table;
void UObjectDB::init(bool flag, bool info)
void UObjectDB::init(bool flag)
{
U_INTERNAL_TRACE("UObjectDB::init(%d,%d)", flag, info)
U_INTERNAL_TRACE("UObjectDB::init(%b)", flag)
char* env = getenv("UOBJDUMP");
@ -374,18 +374,6 @@ void UObjectDB::init(bool flag, bool info)
}
}
}
if (info)
{
if (fd == -1)
{
U_MESSAGE("OBJDUMP%W<%Woff%W>%W", YELLOW, RED, YELLOW, RESET);
}
else
{
U_MESSAGE("OBJDUMP%W<%Won%W>: Level<%W%d%W> MaxSize<%W%d%W>%W", YELLOW, GREEN, YELLOW, CYAN, level_active, YELLOW, CYAN, file_size, YELLOW, RESET);
}
}
}
U_NO_EXPORT void UObjectDB::_write(const struct iovec* iov, int _n)
@ -455,7 +443,7 @@ void UObjectDB::initFork()
(void) ::close(fd);
init(false, true);
init(false);
}
void UObjectDB::registerObject(UObjectDumpable* dumper)

View File

@ -355,9 +355,9 @@ bool UFile::isNameDosMatch(const char* mask, uint32_t mask_len) const
UString basename = getName();
bool result = UServices::dosMatchWithOR(U_STRING_TO_PARAM(basename), mask, mask_len, 0);
if (UServices::dosMatchWithOR(U_STRING_TO_PARAM(basename), mask, mask_len, 0)) U_RETURN(true);
U_RETURN(result);
U_RETURN(false);
}
UString UFile::getDirName() const
@ -371,8 +371,6 @@ UString UFile::getDirName() const
UString result = UStringExt::dirname(path_relativ, path_relativ_len);
U_INTERNAL_ASSERT(result.isNullTerminated())
U_RETURN_STRING(result);
}
@ -686,6 +684,9 @@ try_from_file_system:
#endif
}
// A file is mapped in multiples of the page size. For a file that is not a multiple of the page size,
// the remaining memory is zeroed when mapped, and writes to that region are not written out to the file
bool UFile::memmap(int prot, UString* str, uint32_t offset, uint32_t length)
{
U_TRACE(0, "UFile::memmap(%d,%p,%u,%u)", prot, str, offset, length)
@ -721,7 +722,7 @@ bool UFile::memmap(int prot, UString* str, uint32_t offset, uint32_t length)
U_INTERNAL_ASSERT_MINOR_MSG(length, U_STRING_MAX_SIZE, "we can't manage file size bigger than 4G...") // limit of UString
#endif
U_INTERNAL_ASSERT_EQUALS((offset % PAGESIZE), 0) // offset should be a multiple of the page size as returned by getpagesize(2)
U_INTERNAL_ASSERT_EQUALS(offset % PAGESIZE, 0) // offset should be a multiple of the page size as returned by getpagesize(2)
if (map != (char*)MAP_FAILED)
{
@ -736,7 +737,7 @@ bool UFile::memmap(int prot, UString* str, uint32_t offset, uint32_t length)
if (prot == PROT_READ) flags |= MAP_POPULATE;
#endif
map = (char*) U_SYSCALL(mmap, "%p,%u,%d,%d,%d,%I", U_NULLPTR, length, prot, flags, fd, offset);
map = (char*) U_SYSCALL(mmap, "%p,%u,%d,%d,%d,%I", U_NULLPTR, length, prot, flags, fd, offset); // (str ? getMmapSize(length) : length)
if (map != (char*)MAP_FAILED)
{
@ -746,6 +747,7 @@ bool UFile::memmap(int prot, UString* str, uint32_t offset, uint32_t length)
{
str->mmap(map + resto, length - resto);
/*
# if defined(U_LINUX) && defined(MADV_SEQUENTIAL)
if (prot == PROT_READ &&
length > (32 * PAGESIZE))
@ -753,6 +755,7 @@ bool UFile::memmap(int prot, UString* str, uint32_t offset, uint32_t length)
(void) U_SYSCALL(madvise, "%p,%u,%d", (void*)map, length, MADV_SEQUENTIAL);
}
# endif
*/
}
U_RETURN(true);
@ -821,7 +824,7 @@ UString UFile::_getContent(bool bsize, bool brdonly, bool bmap)
if (st_size)
{
if (bmap ||
st_size > (off_t)(4L * PAGESIZE))
st_size >= (off_t)(4L * PAGESIZE))
{
int prot = PROT_READ;
if (brdonly == false) prot |= PROT_WRITE;

View File

@ -204,8 +204,8 @@
#define U_MAX_REDIRECTS 10 // HTTP 1.0 used to suggest 5
bool UHttpClient_Base::server_context_flag;
struct uhttpinfo UHttpClient_Base::u_http_info_save;
bool UHttpClient_Base::data_chunked;
bool UHttpClient_Base::server_context_flag;
UHttpClient_Base::UHttpClient_Base(UFileConfig* _cfg) : UClient_Base(_cfg)
{
@ -229,6 +229,8 @@ void UHttpClient_Base::reset()
body.clear();
data_chunked = false;
requestHeader->clear();
responseHeader->clear();
@ -874,14 +876,14 @@ bool UHttpClient_Base::sendRequestEngine()
if (U_http_info.clength == 0)
{
bool is_chunked = responseHeader->isChunked();
data_chunked = responseHeader->isChunked();
if (is_chunked) U_http_flag |= HTTP_IS_DATA_CHUNKED;
else U_http_flag &= ~HTTP_IS_DATA_CHUNKED;
if (data_chunked) U_http_flag |= HTTP_IS_DATA_CHUNKED;
else U_http_flag &= ~HTTP_IS_DATA_CHUNKED;
U_INTERNAL_DUMP("is_chunked = %b U_http_data_chunked = %b", is_chunked, U_http_data_chunked)
U_INTERNAL_DUMP("data_chunked = %b U_http_data_chunked = %b", data_chunked, U_http_data_chunked)
if (is_chunked == false) U_RETURN(true);
if (data_chunked == false) U_RETURN(true);
}
if (UHTTP::readBodyResponse(UClient_Base::socket, &response, body)) U_RETURN(true);
@ -916,11 +918,12 @@ bool UHttpClient_Base::sendRequest()
bool ok;
uint64_t flag_save = 0;
struct uhttpinfo http_info_save;
if (server_context_flag)
{
u_http_info_save = U_http_info;
flag_save = u_clientimage_info.flag.u;
flag_save = u_clientimage_info.flag.u;
http_info_save = u_clientimage_info.http_info;
}
if (UClient_Base::iovcnt == 0)
@ -944,10 +947,9 @@ bool UHttpClient_Base::sendRequest()
if (server_context_flag)
{
u_clientimage_info.flag.u = flag_save;
u_http_info_save.nResponseCode = U_http_info.nResponseCode;
U_http_info = u_http_info_save;
u_clientimage_info.flag.u = flag_save;
u_clientimage_info.http_info.nResponseCode = U_http_info.nResponseCode;
u_clientimage_info.http_info = http_info_save;
}
U_INTERNAL_DUMP("server_context_flag = %b U_ClientImage_close = %b", server_context_flag, U_ClientImage_close)

View File

@ -1285,7 +1285,6 @@ data_missing:
cls: if (U_ClientImage_parallelization == U_PARALLELIZATION_PARENT)
{
U_ASSERT(wbuffer->empty())
U_ASSERT_EQUALS(isRequestNeedProcessing(), false)
U_INTERNAL_ASSERT_EQUALS(U_ClientImage_data_missing, false)
endRequest();
@ -1786,10 +1785,10 @@ void UClientImage_Base::close()
{
U_TRACE_NO_PARAM(0, "UClientImage_Base::close()")
UServer_Base::csocket->close();
setRequestProcessed();
UServer_Base::csocket->close();
resetPipelineAndSetCloseConnection();
}

View File

@ -42,6 +42,7 @@ int UEchoPlugIn::handlerRequest()
UClientImage_Base::body->clear();
UClientImage_Base::setRequestProcessed();
UClientImage_Base::setNoHeaderForResponse();
#ifndef U_ECHO_RESPONSE_FOR_TEST

View File

@ -79,157 +79,184 @@ int UProxyPlugIn::handlerRequest()
{
U_TRACE_NO_PARAM(0, "UProxyPlugIn::handlerRequest()")
if (UHTTP::isProxyRequest())
if (UHTTP::isProxyRequest() == false) U_RETURN(U_PLUGIN_HANDLER_OK);
// NB: process the HTTP PROXY request with fork....
if (UServer_Base::startParallelization()) U_RETURN(U_PLUGIN_HANDLER_PROCESSED); // parent
bool output_to_client = false,
output_to_server = false;
if (UHTTP::service->command) // check if it is required an action...
{
bool output_to_client = false,
output_to_server = false;
U_ASSERT(UClientImage_Base::environment->empty())
if (UHTTP::service->command) // check if it is required an action...
if (UHTTP::getCGIEnvironment(*UClientImage_Base::environment, U_GENERIC))
{
U_ASSERT(UClientImage_Base::environment->empty())
if (UHTTP::service->environment) UClientImage_Base::environment->append(UHTTP::service->environment);
if (UHTTP::getCGIEnvironment(*UClientImage_Base::environment, U_GENERIC))
if (UHTTP::processCGIRequest(UHTTP::service->command) &&
UHTTP::processCGIOutput(false, false))
{
if (UHTTP::service->environment) UClientImage_Base::environment->append(UHTTP::service->environment);
if (UHTTP::processCGIRequest(UHTTP::service->command) &&
UHTTP::processCGIOutput(false, false))
{
if (UHTTP::service->isResponseForClient()) output_to_client = true; // send output as response to client...
else output_to_server = true; // send output as request to server...
}
UClientImage_Base::environment->setEmpty();
if (UHTTP::service->isResponseForClient()) output_to_client = true; // send output as response to client...
else output_to_server = true; // send output as request to server...
}
if (output_to_client == false &&
output_to_server == false)
{
if (U_http_info.nResponseCode == 0 ||
U_http_info.nResponseCode == HTTP_OK)
{
UHTTP::setInternalError();
}
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
}
UClientImage_Base::environment->setEmpty();
}
U_INTERNAL_DUMP("output_to_server = %b output_to_client = %b", output_to_server, output_to_client)
if (output_to_server) // check if the kind of request is like HTTP protocol (client/server)...
if (output_to_client == false &&
output_to_server == false)
{
U_INTERNAL_ASSERT(*UClientImage_Base::wbuffer)
if (UHTTP::scanfHeaderResponse(U_STRING_TO_PARAM(*UClientImage_Base::wbuffer)) == false)
if (U_http_info.nResponseCode == 0 ||
U_http_info.nResponseCode == HTTP_OK)
{
UModProxyService::setMsgError(UModProxyService::INTERNAL_ERROR);
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
UHTTP::setInternalError();
}
U_INTERNAL_DUMP("uri = %.*S", U_HTTP_URI_TO_TRACE)
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
}
if (output_to_client == false)
{
// before connect to server check if server and/or port to connect has changed...
if (client_http->setHostPort(UHTTP::service->getServer(), UHTTP::service->getPort()) &&
client_http->UClient_Base::isConnected())
{
client_http->UClient_Base::close();
}
// --------------------------------------------------------------------------------------------------------------------
// A WebSocket is a long-lived connection, lasting hours or days. If each WebSocket proxy holds the original thread,
// won't that consume all of the workers very quickly? It looks as if my server, with 16 workers, will be unable to
// handle either the 17th WebSocket proxy or any other HTTP request. That's not really practical in a production system.
// A WebSocket server could potentially handle hundreds or even thousands of simultaneous connections, which would mean
// the same number of proxies in server...
// --------------------------------------------------------------------------------------------------------------------
if (UHTTP::service->isWebSocket())
{
UWebSocket::checkForInitialData(); // check if we have read more data than necessary...
while (UWebSocket::handleDataFraming(UServer_Base::csocket) == STATUS_CODE_OK &&
(client_http->UClient_Base::prepareRequest(*UClientImage_Base::wbuffer), client_http->UClient_Base::sendRequestAndReadResponse()) &&
UWebSocket::sendData(UWebSocket::message_type, (const unsigned char*)U_STRING_TO_PARAM(client_http->UClient_Base::response)))
{
client_http->UClient_Base::clearData();
UClientImage_Base::wbuffer->setEmpty();
}
U_RETURN(U_PLUGIN_HANDLER_ERROR);
}
client_http->setFollowRedirects(UHTTP::service->isFollowRedirects(), true);
if (UHTTP::service->isAuthorization()) client_http->setRequestPasswordAuthentication(UHTTP::service->getUser(), UHTTP::service->getPassword());
// connect to server, send request and get response
if (output_to_server == false) *UClientImage_Base::wbuffer = *UClientImage_Base::request;
bool result = client_http->sendRequest(*UClientImage_Base::wbuffer);
*UClientImage_Base::wbuffer = client_http->getResponse();
if (result)
{
UClientImage_Base::setNoHeaderForResponse();
U_INTERNAL_DUMP("U_http_data_chunked = %b U_ClientImage_close = %b", U_http_data_chunked, U_ClientImage_close)
if (U_http_data_chunked == false)
{
if (UHTTP::service->isReplaceResponse()) *UClientImage_Base::wbuffer = UHTTP::service->replaceResponse(*UClientImage_Base::wbuffer);
}
else
{
U_http_flag &= ~HTTP_IS_DATA_CHUNKED;
U_INTERNAL_DUMP("U_http_data_chunked = %b", U_http_data_chunked)
// NB: in this case we broke the transparency of the response to avoid a duplication of effort to read chunked data...
UString body = client_http->getContent();
U_INTERNAL_ASSERT(body)
if (UHTTP::service->isReplaceResponse()) body = UHTTP::service->replaceResponse(body);
UString content_type = client_http->getResponseHeader()->getContentType();
uint32_t sz = content_type.size() + U_CONSTANT_SIZE(U_CRLF);
content_type.size_adjust_force(sz);
U_ASSERT(UStringExt::endsWith(content_type, U_CONSTANT_TO_PARAM(U_CRLF)))
# ifdef USE_LIBZ
if (U_http_is_accept_gzip_save &&
body.size() > U_MIN_SIZE_FOR_DEFLATE)
{
body = UStringExt::deflate(body, 1);
}
# endif
UHTTP::setResponse(true, content_type, &body);
}
}
# ifndef U_LOG_DISABLE
else if (UServer_Base::isLog()) UServer_Base::log->logResponse(*UClientImage_Base::wbuffer, U_CONSTANT_TO_PARAM(""), 0);
# endif
client_http->reset(); // reset reference to request...
}
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
}
U_RETURN(U_PLUGIN_HANDLER_OK);
U_INTERNAL_DUMP("output_to_server = %b output_to_client = %b", output_to_server, output_to_client)
if (output_to_server) // check if the kind of request is like HTTP protocol (client/server)...
{
U_INTERNAL_ASSERT(*UClientImage_Base::wbuffer)
if (UHTTP::scanfHeaderResponse(U_STRING_TO_PARAM(*UClientImage_Base::wbuffer)) == false)
{
UModProxyService::setMsgError(UModProxyService::INTERNAL_ERROR);
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
}
U_INTERNAL_DUMP("uri = %.*S", U_HTTP_URI_TO_TRACE)
}
if (output_to_client) UClientImage_Base::setRequestProcessed();
else
{
// before connect to server check if server and/or port to connect has changed...
if (client_http->setHostPort(UHTTP::service->getServer(), UHTTP::service->getPort()) &&
client_http->UClient_Base::isConnected())
{
client_http->UClient_Base::close();
}
// --------------------------------------------------------------------------------------------------------------------
// A WebSocket is a long-lived connection, lasting hours or days. If each WebSocket proxy holds the original thread,
// won't that consume all of the workers very quickly? It looks as if my server, with 16 workers, will be unable to
// handle either the 17th WebSocket proxy or any other HTTP request. That's not really practical in a production system.
// A WebSocket server could potentially handle hundreds or even thousands of simultaneous connections, which would mean
// the same number of proxies in server...
// --------------------------------------------------------------------------------------------------------------------
if (UHTTP::service->isWebSocket())
{
UWebSocket::checkForInitialData(); // check if we have read more data than necessary...
while (UWebSocket::handleDataFraming(UServer_Base::csocket) == STATUS_CODE_OK &&
(client_http->UClient_Base::prepareRequest(*UClientImage_Base::wbuffer), client_http->UClient_Base::sendRequestAndReadResponse()) &&
UWebSocket::sendData(UWebSocket::message_type, (const unsigned char*)U_STRING_TO_PARAM(client_http->UClient_Base::response)))
{
client_http->UClient_Base::clearData();
UClientImage_Base::wbuffer->setEmpty();
}
U_RETURN(U_PLUGIN_HANDLER_ERROR);
}
client_http->setFollowRedirects(UHTTP::service->isFollowRedirects(), true);
if (UHTTP::service->isAuthorization()) client_http->setRequestPasswordAuthentication(UHTTP::service->getUser(), UHTTP::service->getPassword());
// connect to server, send request and get response
if (output_to_server == false) *UClientImage_Base::wbuffer = *UClientImage_Base::request;
bool result = client_http->sendRequest(*UClientImage_Base::wbuffer);
*UClientImage_Base::wbuffer = client_http->getResponse();
if (result == false)
{
UClientImage_Base::setRequestProcessed();
# ifndef U_LOG_DISABLE
if (UServer_Base::isLog()) UServer_Base::log->logResponse(*UClientImage_Base::wbuffer, U_CONSTANT_TO_PARAM(""), 0);
# endif
}
else
{
UClientImage_Base::setNoHeaderForResponse();
U_INTERNAL_DUMP("U_http_data_chunked = %b U_ClientImage_close = %b client_http->data_chunked = %b", U_http_data_chunked, U_ClientImage_close, client_http->data_chunked)
if (client_http->data_chunked == false)
{
if (UHTTP::service->isReplaceResponse()) *UClientImage_Base::wbuffer = UHTTP::service->replaceResponse(*UClientImage_Base::wbuffer);
UClientImage_Base::setRequestProcessed();
}
else
{
// NB: in this case we broke the transparency of the response to avoid a duplication of effort to read chunked data...
uint32_t sz, csz, ratio;
UString body = client_http->getContent();
U_INTERNAL_ASSERT(body)
if (UHTTP::service->isReplaceResponse()) body = UHTTP::service->replaceResponse(body);
UString content_type = client_http->getResponseHeader()->getContentType();
content_type.rep->_length += 2; // NB: we add "\r\n"...
# if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
if ((sz = body.size()) > U_MIN_SIZE_FOR_DEFLATE)
{
UString compressed;
U_INTERNAL_DUMP("U_http_is_accept_gzip = %b U_http_is_accept_brotli = %b", U_http_is_accept_gzip, U_http_is_accept_brotli)
# ifdef USE_LIBBROTLI
if (U_http_is_accept_brotli &&
(compressed = UStringExt::brotli(body, 6)))
{
goto next;
}
# endif
# ifdef USE_LIBZ
if (U_http_is_accept_gzip) compressed = UStringExt::deflate(body, 1);
# endif
next: csz = compressed.size(), ratio = (csz * 100U) / sz;
U_INTERNAL_DUMP("ratio = %u (%u%%)", ratio, 100-ratio)
// NB: we accept new data only if ratio compression is better than 15%...
if (ratio < 85)
{
body = compressed;
U_SRV_LOG("proxy response: %u bytes - (%u%%) compression ratio", csz, 100-ratio);
}
}
# endif
UHTTP::setResponse(true, content_type, &body);
}
}
client_http->reset(); // reset reference to request...
}
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
}
// DEBUG

View File

@ -94,6 +94,8 @@ int URpcPlugIn::handlerRequest()
if (UServer_Base::isLog()) (void) UClientImage_Base::request_uri->assign(method);
# endif
UClientImage_Base::setRequestProcessed();
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
}

View File

@ -183,6 +183,10 @@ handle_data:
{
UClientImage_Base::close();
}
else
{
UClientImage_Base::setRequestProcessed();
}
U_RETURN(U_PLUGIN_HANDLER_PROCESSED);
}

View File

@ -1055,7 +1055,7 @@ int USSIPlugIn::handlerRequest()
U_INTERNAL_ASSERT_POINTER(UHTTP::file_data->array)
U_INTERNAL_ASSERT_EQUALS( UHTTP::file_data->array->size(), 2)
(void) header->append(UHTTP::getDataFromCache(1)); // NB: after now 'file_data' can change...
(void) header->append(UHTTP::getHeaderFromCache()); // NB: after now 'file_data' can change...
*body = (UHTTP::isGETorHEAD() &&
*UClientImage_Base::body
@ -1091,7 +1091,7 @@ int USSIPlugIn::handlerRequest()
*UHTTP::ext = *header;
if (bcache) (void) UHTTP::checkContentLength(size, U_NOT_FOUND); // NB: adjusting the size of response...
if (bcache) (void) UHTTP::checkContentLength(size); // NB: adjusting the size of response...
else
{
UHTTP::mime_index = U_unknow;

View File

@ -86,20 +86,19 @@ int UTsaPlugIn::handlerRequest()
if (UHTTP::isTSARequest())
{
// process TSA request
// NB: process the HTTP tsa request with fork....
if (UServer_Base::startParallelization()) U_RETURN(U_PLUGIN_HANDLER_PROCESSED); // parent
UString body;
if (command->execute(UClientImage_Base::body, &body))
if (command->execute(UClientImage_Base::body, &body) == false) UHTTP::setInternalError();
else
{
U_http_info.nResponseCode = HTTP_OK;
UHTTP::setResponse(true, *UString::str_ctype_tsa, &body);
}
else
{
UHTTP::setInternalError();
}
# ifndef U_LOG_DISABLE
UServer_Base::logCommandMsgError(command->getCommand(), true);

View File

@ -493,6 +493,8 @@ public:
U_INTERNAL_DUMP("krate = %u min_limit = %u max_limit = %u num_sending = %u bytes_since_avg = %llu", UServer_Base::throttling_rec->krate, UServer_Base::throttling_rec->min_limit,
UServer_Base::throttling_rec->max_limit, UServer_Base::throttling_rec->num_sending, UServer_Base::throttling_rec->bytes_since_avg)
U_INTERNAL_ASSERT_MAJOR(UServer_Base::throttling_rec->num_sending, 0)
uint32_t l = UServer_Base::throttling_rec->max_limit / UServer_Base::throttling_rec->num_sending;
UServer_Base::pClientImage->max_limit = (UServer_Base::pClientImage->max_limit == U_NOT_FOUND
@ -734,13 +736,17 @@ bool UServer_Base::checkThrottlingBeforeSend(bool bwrite)
kbytes_sent = pClientImage->bytes_sent / 1024ULL,
krate = (elapsed > 1 ? kbytes_sent / elapsed : kbytes_sent);
U_INTERNAL_DUMP("krate = %u", krate)
U_INTERNAL_DUMP("krate = %u elapsed = %u", krate, elapsed)
if (krate > pClientImage->max_limit)
{
// how long should we wait to get back on schedule? If less than a second (integer math rounding), use 1/2 second
time_t coast = kbytes_sent / pClientImage->max_limit - elapsed;
uint32_t div = pClientImage->max_limit - elapsed;
if (div == 0) div = 1;
time_t coast = kbytes_sent / div;
// set up the wakeup timer
@ -1036,9 +1042,17 @@ bool UServer_Base::checkHitUriStats()
u_get_unalignedp32(ptr+8) != U_MULTICHAR_CONSTANT32('.','i','c','o'))
{
char key[260];
uint32_t key_sz = (sz < 256 ? sz : 256);
uint32_t key_sz = (sz < 256 ? sz : 256),
addr = UServer_Base::csocket->remoteIPAddress().getInAddr();
u_put_unalignedp32(key, UServer_Base::csocket->remoteIPAddress().getInAddr());
union uukey {
char* k;
uint32_t* u;
};
union uukey ukey = { &key[0] };
u_put_unalignedp32(ukey.u, addr);
U_MEMCPY(key+4, ptr, key_sz);
@ -2366,7 +2380,11 @@ void UServer_Base::pluginsHandlerRequest()
U_INTERNAL_ASSERT_EQUALS(result, U_PLUGIN_HANDLER_PROCESSED)
UClientImage_Base::setRequestProcessed();
if (UClientImage_Base::isRequestAlreadyProcessed() ||
U_ClientImage_parallelization == U_PARALLELIZATION_PARENT)
{
return;
}
}
}
}
@ -2399,7 +2417,11 @@ void UServer_Base::pluginsHandlerRequest()
U_INTERNAL_ASSERT_EQUALS(result, U_PLUGIN_HANDLER_PROCESSED)
UClientImage_Base::setRequestProcessed();
if (UClientImage_Base::isRequestAlreadyProcessed() ||
U_ClientImage_parallelization == U_PARALLELIZATION_PARENT)
{
return;
}
}
continue;
@ -2426,12 +2448,11 @@ void UServer_Base::pluginsHandlerRequest()
U_INTERNAL_ASSERT_EQUALS(result, U_PLUGIN_HANDLER_PROCESSED)
if (U_ClientImage_parallelization != U_PARALLELIZATION_PARENT)
{
UClientImage_Base::setRequestProcessed();
if (U_ClientImage_parallelization == U_PARALLELIZATION_PARENT) return;
log->log(U_CONSTANT_TO_PARAM("Request phase of plugin %V success"), name.rep);
}
log->log(U_CONSTANT_TO_PARAM("Request phase of plugin %V success"), name.rep);
if (UClientImage_Base::isRequestAlreadyProcessed()) return;
}
}
}
@ -4248,7 +4269,9 @@ bool UServer_Base::startParallelization(uint32_t nclient)
{
// NB: from now it is responsability of the child to services the request from the client on the same connection...
pClientImage->close();
csocket->close();
UClientImage_Base::resetPipelineAndSetCloseConnection();
U_ClientImage_parallelization = U_PARALLELIZATION_PARENT;

View File

@ -154,6 +154,8 @@ void UNotifier::init()
U_TRACE(0, "UNotifier::init()")
#ifdef HAVE_EPOLL_WAIT
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
int old = epollfd;
U_INTERNAL_DUMP("old = %d", old)
@ -316,6 +318,8 @@ void UNotifier::resume(UEventFd* item)
U_INTERNAL_ASSERT_EQUALS(item->op_mask, EPOLLOUT)
#ifdef HAVE_EPOLL_WAIT
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
struct epoll_event _events = { EPOLLOUT, { item } };
(void) U_SYSCALL(epoll_ctl, "%d,%d,%d,%p", epollfd, EPOLL_CTL_ADD, item->fd, &_events);
@ -348,6 +352,8 @@ void UNotifier::suspend(UEventFd* item)
U_INTERNAL_ASSERT_EQUALS(item->op_mask, EPOLLOUT)
#ifdef HAVE_EPOLL_WAIT
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
(void) U_SYSCALL(epoll_ctl, "%d,%d,%d,%p", epollfd, EPOLL_CTL_DEL, item->fd, (struct epoll_event*)1);
#elif defined(HAVE_KQUEUE)
U_INTERNAL_ASSERT_MAJOR(kq, 0)
@ -379,6 +385,8 @@ int UNotifier::waitForEvent(int fd_max, fd_set* read_set, fd_set* write_set, UEv
int result;
#ifdef HAVE_EPOLL_WAIT
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
result = U_SYSCALL(epoll_wait, "%d,%p,%u,%d", epollfd, events, max_connection, UEventTime::getMilliSecond(ptimeout));
#elif defined(HAVE_KQUEUE)
result = U_SYSCALL(kevent, "%d,%p,%d,%p,%d,%p", kq, kqevents, nkqevents, kqrevents, max_connection, UEventTime::getTimeSpec(ptimeout));
@ -437,6 +445,7 @@ loop:
# endif
nkqevents = 0;
#else
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
loop:
nfd_ready = U_SYSCALL(epoll_wait, "%d,%p,%u,%d", epollfd, events, max_connection, UEventTime::getMilliSecond(ptimeout));
#endif
@ -529,6 +538,8 @@ loop0:
U_INTERNAL_DUMP("i = %d handler_event->fd = %d", i, handler_event->fd)
// U_INTERNAL_ASSERT_DIFFERS(handler_event->fd, -1)
if (handler_event->fd != -1)
{
U_INTERNAL_DUMP("bread = %b bwrite = %b events[%d].events = %d %B", ((pevents->events & (EPOLLIN | EPOLLRDHUP)) != 0),
@ -814,6 +825,7 @@ void UNotifier::insert(UEventFd* item, int op)
(void) UDispatcher::add(*(item->pevent));
#elif defined(HAVE_EPOLL_WAIT)
U_INTERNAL_ASSERT_MAJOR(epollfd, 0)
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
# ifdef DEBUG
if (op)
@ -894,6 +906,7 @@ bool UNotifier::modify(UEventFd* item)
(void) UDispatcher::add(*(item->pevent));
#elif defined(HAVE_EPOLL_WAIT)
U_INTERNAL_ASSERT_MAJOR(epollfd, 0)
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
struct epoll_event _events = { item->op_mask, { item } };

View File

@ -53,10 +53,15 @@
# define LIBZ_ENABLE "no"
#endif
#ifdef USE_LIBZOPFLI
# define LIBZOPFLI_ENABLE "yes ( " _LIBZOPFLI_VERSION " )"
# define LIBZOPFLI_ENABLE "yes ( " _LIBBROTLI_VERSION " )"
#else
# define LIBZOPFLI_ENABLE "no"
#endif
#ifdef USE_LIBBROTLI
# define LIBBROTLI_ENABLE "yes ( " _LIBBROTLI_VERSION " )"
#else
# define LIBBROTLI_ENABLE "no"
#endif
#ifdef USE_LIBTDB
# define LIBTDB_ENABLE "yes ( " _LIBTDB_VERSION " )"
#else
@ -715,6 +720,7 @@ PYTHON language support: yes ( 2.7 )
"memory pool support....:%W " MEMORY_POOL_ENABLE "%W\n\n" \
"LIBZ support...........:%W " LIBZ_ENABLE "%W\n" \
"LIBZOPFLI support......:%W " LIBZOPFLI_ENABLE "%W\n" \
"LIBBROTLI support......:%W " LIBBROTLI_ENABLE "%W\n" \
"LIBTDB support.........:%W " LIBTDB_ENABLE "%W\n" \
"PCRE support...........:%W " LIBPCRE_ENABLE "%W\n" \
"SSL support............:%W " LIBSSL_ENABLE "%W\n" \
@ -768,6 +774,7 @@ PYTHON language support: yes ( 2.7 )
BRIGHTGREEN, RESET,
BRIGHTGREEN, RESET,
BRIGHTGREEN, RESET,
BRIGHTGREEN, RESET,
// wrapping
BRIGHTYELLOW, RESET,
BRIGHTYELLOW, RESET,

View File

@ -60,23 +60,24 @@ void UOrmDriverMySql::handlerError()
U_ENTRY(CR_NAMEDPIPESETSTATE_ERROR),
U_ENTRY(CR_CANT_READ_CHARSET),
U_ENTRY(CR_NET_PACKET_TOO_LARGE),
U_ENTRY(CR_SSL_CONNECTION_ERROR),
U_ENTRY(CR_MALFORMED_PACKET),
U_ENTRY(CR_NO_PREPARE_STMT),
U_ENTRY(CR_PARAMS_NOT_BOUND),
U_ENTRY(CR_INVALID_PARAMETER_NO),
U_ENTRY(CR_INVALID_BUFFER_USE),
U_ENTRY(CR_UNSUPPORTED_PARAM_TYPE),
U_ENTRY(CR_SHARED_MEMORY_CONNECTION),
/*
U_ENTRY(CR_EMBEDDED_CONNECTION),
U_ENTRY(CR_PROBE_SLAVE_STATUS),
U_ENTRY(CR_PROBE_SLAVE_HOSTS),
U_ENTRY(CR_PROBE_SLAVE_CONNECT),
U_ENTRY(CR_PROBE_MASTER_CONNECT),
U_ENTRY(CR_SSL_CONNECTION_ERROR),
U_ENTRY(CR_MALFORMED_PACKET),
U_ENTRY(CR_WRONG_LICENSE),
U_ENTRY(CR_NULL_POINTER),
U_ENTRY(CR_NO_PREPARE_STMT),
U_ENTRY(CR_PARAMS_NOT_BOUND),
U_ENTRY(CR_DATA_TRUNCATED),
U_ENTRY(CR_NO_PARAMETERS_EXISTS),
U_ENTRY(CR_INVALID_PARAMETER_NO),
U_ENTRY(CR_INVALID_BUFFER_USE),
U_ENTRY(CR_UNSUPPORTED_PARAM_TYPE),
U_ENTRY(CR_SHARED_MEMORY_CONNECTION),
U_ENTRY(CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR),
U_ENTRY(CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR),
U_ENTRY(CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR),
@ -88,13 +89,14 @@ void UOrmDriverMySql::handlerError()
U_ENTRY(CR_SHARED_MEMORY_CONNECT_SET_ERROR),
U_ENTRY(CR_CONN_UNKNOW_PROTOCOL),
U_ENTRY(CR_INVALID_CONN_HANDLE),
U_ENTRY(CR_FETCH_CANCELED),
U_ENTRY(CR_NO_RESULT_SET),
*/
# ifdef CR_SECURE_AUTH
U_ENTRY(CR_SECURE_AUTH),
# endif
U_ENTRY(CR_FETCH_CANCELED),
U_ENTRY(CR_NO_DATA),
U_ENTRY(CR_NO_STMT_METADATA),
U_ENTRY(CR_NO_RESULT_SET),
U_ENTRY(CR_NOT_IMPLEMENTED),
U_ENTRY(CR_SERVER_LOST_EXTENDED),
U_ENTRY(CR_STMT_CLOSED),
@ -108,7 +110,7 @@ void UOrmDriverMySql::handlerError()
if (UOrmDriver::errmsg == U_NULLPTR) UOrmDriver::errmsg = U_SYSCALL(mysql_error, "%p", (MYSQL*)UOrmDriver::connection);
if (UOrmDriver::errcode >= CR_ERROR_FIRST) UOrmDriver::errcode -= CR_ERROR_FIRST; // 2000
if (UOrmDriver::errcode >= 2000) UOrmDriver::errcode -= 2000;
if (UOrmDriver::errcode >= 0 &&
UOrmDriver::errcode < (int)U_NUM_ELEMENTS(error_value_table) &&

View File

@ -257,7 +257,7 @@ unsigned UPKCS7::getSignerCertificates(UVector<UCertificate*>& vec, int flags) c
* flags is an optional set of flags (PKCS7_TEXT, PKCS7_NOCERTS, PKCS7_DETACHED, PKCS7_BINARY, ...)
*/
PKCS7* UPKCS7::sign(const UString& data, const UString& signcert, const UString& pkey, const UString& passwd, const UString& certs, int flags)
PKCS7* UPKCS7::sign(const UString& data, const UString& signcert, UString& pkey, const UString& passwd, const UString& certs, int flags)
{
U_TRACE(1, "UPKCS7::sign(%V,%V,%V,%V,%V,%d)", data.rep, signcert.rep, pkey.rep, passwd.rep, certs.rep, flags)

View File

@ -897,6 +897,7 @@ void UStringRep::_release()
str -= resto;
_length += resto;
}
// else _length += PAGESIZE;
(void) U_SYSCALL(munmap, "%p,%lu", (void*)str, _length);
}
@ -1275,6 +1276,7 @@ void UString::mmap(const char* map, uint32_t len)
}
U_INTERNAL_ASSERT(invariant())
// U_INTERNAL_ASSERT(isNullTerminated())
}
char* UString::__replace(uint32_t pos, uint32_t n1, uint32_t n2)
@ -1347,7 +1349,7 @@ void UString::unQuote()
uint32_t len = rep->_length;
if (len <= 2) clear();
if (len <= 2) _assign(UStringRep::string_rep_null);
else if (rep->_capacity == 0) rep->unQuote();
else
{
@ -1418,44 +1420,6 @@ UString& UString::append(uint32_t n, char c)
return *this;
}
void UString::duplicate() const
{
U_TRACE_NO_PARAM(0, "UString::duplicate()")
uint32_t sz = size();
if (sz) ((UString*)this)->_set(UStringRep::create(sz, sz, rep->str));
else
{
((UString*)this)->_set(UStringRep::create(0, 100U, U_NULLPTR));
*(((UString*)this)->UString::rep->data()) = '\0';
}
U_INTERNAL_ASSERT(invariant())
U_INTERNAL_ASSERT(isNullTerminated())
}
void UString::setNullTerminated() const
{
U_TRACE_NO_PARAM(0, "UString::setNullTerminated()")
// A file is mapped in multiples of the page size. For a file that is not a multiple of the page size,
// the remaining memory is zeroed when mapped, and writes to that region are not written out to the file
if (writeable() == false ||
(isMmap() && (rep->_length % PAGESIZE) == 0))
{
duplicate();
}
else
{
rep->setNullTerminated();
}
U_ASSERT_EQUALS(u__strlen(rep->str, __PRETTY_FUNCTION__), rep->_length)
}
void UString::resize(uint32_t n, unsigned char c)
{
U_TRACE(0, "UString::resize(%u,%C)", n, c)
@ -1848,7 +1812,11 @@ float UStringRep::strtof() const
{
char* eos = (char*)str + _length;
if (isNullTerminated() == false && writeable()) *eos = '\0';
if (isNullTerminated() == false &&
writeable())
{
*eos = '\0';
}
# ifndef DEBUG
float result = ::strtof(str, 0);
@ -1878,7 +1846,11 @@ long double UStringRep::strtold() const
{
char* eos = (char*)str + _length;
if (isNullTerminated() == false && writeable()) *eos = '\0';
if (isNullTerminated() == false &&
writeable())
{
*eos = '\0';
}
# ifndef DEBUG
long double result = ::strtold(str, U_NULLPTR);

View File

@ -1 +1 @@
0x1f,0x8b,0x08,0x08,0x54,0xa7,0xb1,0x52,0x00,0x03,0x64,0x69,0x72,0x5f,0x73,0x74,0x6f,0x72,0x65,0x2e,0x62,0x69,0x6e,0x00,0xc5,0x91,0x4d,0x73,0x9b,0x30,0x10,0x86,0xcf,0xf5,0xaf,0xd0,0xe4,0xd4,0x8e,0x9b,0x20,0xf1,0x61,0x6c,0x77,0x72,0x10,0x58,0x25,0xd8,0xc6,0x01,0x0c,0x84,0xba,0xed,0x01,0x1b,0x59,0xc8,0x21,0x02,0x83,0x53,0xec,0xe9,0xf4,0xbf,0x17,0xb5,0xe9,0x4c,0x0f,0xcd,0xb9,0x3b,0xab,0xd1,0xab,0x9d,0x77,0xa4,0xd5,0x3e,0x9f,0x07,0x7c,0x57,0x89,0x56,0xc9,0x79,0x73,0x53,0x0b,0xf6,0xe6,0x3b,0x40,0x48,0x05,0x68,0xa4,0x01,0xa4,0x8d,0x46,0x50,0x1b,0x19,0xa6,0x94,0x13,0xd3,0x30,0xd5,0xb1,0x0e,0xc1,0xdb,0x01,0x4f,0xac,0xfb,0xb0,0x83,0x0b,0x87,0x55,0xb8,0x8f,0xd5,0x3a,0x2e,0x48,0xcc,0x7a,0x65,0x05,0xf2,0x9c,0x58,0xd8,0xeb,0x37,0x1b,0x0e,0x27,0xf7,0x5b,0x59,0x98,0x21,0xcb,0x4b,0x48,0x2c,0x6b,0xa4,0x70,0x23,0xe7,0xdc,0x6e,0x15,0xa5,0x9b,0x29,0x7d,0x5c,0xb4,0xea,0x50,0x4a,0x4f,0x04,0x4b,0x12,0x24,0x81,0x8b,0x0c,0x6d,0x09,0x03,0xb5,0xbf,0x81,0x13,0x3d,0x6c,0xad,0x33,0x4e,0xbb,0x79,0x81,0x53,0xb8,0x3a,0x4c,0x36,0xc6,0x32,0x43,0x7c,0x17,0x11,0x73,0x28,0x7c,0x98,0x63,0x4a,0xb1,0x99,0xa4,0xc9,0x33,0x0d,0x0f,0xb5,0x9f,0xd3,0xc7,0x49,0xb0,0x6e,0x1c,0x8b,0xd8,0xf9,0x3e,0x2f,0xdd,0xcb,0x53,0xe7,0x8d,0x1f,0x26,0x46,0x49,0x23,0x27,0xd7,0xbe,0xe5,0x69,0x9d,0xe7,0xe1,0xac,0x75,0x6c,0x1d,0x99,0xdc,0xad,0x10,0x7b,0x38,0x76,0xf2,0x61,0x6c,0xcd,0xc3,0xd8,0x20,0xcd,0xe3,0x9c,0x31,0x76,0x7b,0x3b,0x18,0x5c,0xd9,0x95,0x38,0x51,0x71,0xba,0x8e,0x2e,0x35,0x9d,0x02,0xfe,0x94,0x31,0xaa,0xf4,0x83,0xf9,0x00,0x76,0x45,0xd6,0xb4,0xf4,0x74,0xbb,0xe5,0x22,0x6b,0x2e,0x5f,0x9a,0x2f,0x82,0x9c,0x6b,0xde,0xd0,0x76,0x0a,0xa2,0x67,0xfa,0x1e,0x20,0x03,0xe0,0xba,0x01,0x2a,0x44,0x3a,0x40,0xfa,0x54,0x87,0x7d,0x02,0xc7,0x8b,0xa4,0x73,0x99,0xb5,0xa7,0x6b,0xaf,0xca,0xf9,0x9e,0xd3,0x7c,0x0a,0xbc,0x4a,0xfc,0xed,0xd7,0xa4,0x5f,0x1b,0x4d,0x7b,0xf1,0xe2,0xff,0xd3,0xc4,0x92,0x0a,0x76,0x2a,0xa6,0x92,0x87,0x2c,0xcb,0x75,0xd5,0xf7,0x78,0x25,0xf3,0x1d,0xf8,0x31,0x78,0x81,0xc7,0xa8,0xa0,0x0d,0xdf,0xdd,0x30,0xbe,0x07,0x2f,0x00,0x35,0xf5,0x55,0x80,0x21,0x2c,0x9d,0xfb,0x59,0x59,0x7c,0xec,0x61,0x61,0xcf,0xfd,0x35,0x06,0xec,0xcd,0x70,0xe7,0x8f,0xb1,0xa2,0xdb,0x58,0xb2,0x64,0x7e,0x8f,0x07,0x2e,0xb2,0x5a,0x4e,0xc9,0xbe,0x33,0x2c,0x4c,0x7a,0xe1,0xe2,0xe5,0x6f,0x77,0x8c,0x2d,0x09,0x74,0x35,0x5f,0x90,0xe5,0xce,0xe7,0xf5,0x22,0x3e,0x1e,0x11,0xdb,0x15,0x06,0x1d,0xf3,0x6d,0x20,0x92,0x4f,0xf8,0x41,0x3f,0x64,0xc9,0x46,0x94,0x73,0xd7,0xb2,0x9a,0xf2,0xb8,0x89,0x18,0x4e,0xce,0xf9,0xcc,0x1f,0xae,0xa1,0xa0,0x4f,0x07,0x3b,0xa8,0x57,0x61,0x7e,0x17,0x3e,0x96,0x5d,0xbb,0x18,0xab,0xa9,0xe7,0x57,0x6d,0x3c,0x57,0xd2,0xcd,0x3e,0xd3,0x05,0x3d,0xc2,0x74,0x68,0x92,0x60,0xad,0x37,0x84,0x61,0xf3,0x15,0x28,0xfd,0x67,0xff,0x33,0x14,0x4d,0xfd,0x27,0x94,0xaf,0x83,0x9f,0xf8,0x34,0x0c,0xb2,0x55,0x03,0x00,0x00
0x1f,0x8b,0x08,0x08,0xff,0xac,0xc3,0x59,0x00,0x03,0x64,0x69,0x72,0x5f,0x73,0x74,0x6f,0x72,0x65,0x2e,0x62,0x69,0x6e,0x00,0x95,0x91,0x5d,0x6f,0x9b,0x30,0x14,0x86,0xaf,0x97,0x5f,0x61,0xf5,0x6a,0x53,0xda,0x62,0xbe,0x42,0x92,0xa9,0x17,0x86,0x78,0x94,0x24,0xa4,0x40,0x80,0xb0,0xac,0xbb,0x20,0xc1,0x31,0x4e,0xa9,0x21,0x90,0x8e,0x44,0xd3,0xfe,0xfb,0xf0,0x96,0x49,0xbb,0x58,0x35,0xf5,0xe8,0x58,0x7e,0x7d,0xf4,0xca,0x3e,0x3e,0xcf,0x97,0x1e,0xdb,0x96,0xbc,0x91,0x32,0x56,0xdf,0x56,0x9c,0xbe,0xfb,0x0e,0x64,0x59,0x01,0xf2,0x40,0x05,0xb2,0x3a,0x18,0x40,0x75,0xa0,0x1b,0x42,0x8e,0x0c,0xdd,0x50,0x86,0x1a,0x04,0xef,0x7b,0x2c,0x36,0x1f,0x82,0x16,0xce,0x6c,0x5a,0xa2,0x2e,0x16,0xcb,0x28,0xc7,0x11,0xed,0x94,0xe9,0x8b,0x73,0x6c,0x22,0xb7,0xdb,0x2c,0xd8,0x1f,0x3d,0x6c,0x44,0x61,0x22,0x9b,0x6e,0x8c,0x23,0x51,0xc3,0xb9,0x13,0xda,0xa7,0x66,0x23,0x49,0xed,0x44,0xea,0xe2,0xac,0x96,0xfb,0x42,0x78,0x42,0x58,0x60,0x3f,0xf6,0x1d,0x59,0x57,0xe7,0xd0,0x57,0xba,0x1b,0x18,0xd6,0x82,0xc6,0x3c,0xa1,0xa4,0x9d,0xe6,0x28,0x81,0x8b,0xfd,0x68,0xad,0xcf,0x53,0x99,0x6d,0x43,0x6c,0xf4,0xb9,0x07,0x33,0x44,0x08,0x32,0xe2,0x24,0x7e,0x21,0xc1,0xbe,0xf2,0x32,0xf2,0x34,0xf2,0x97,0xb5,0x6d,0x62,0x2b,0xdb,0x65,0x85,0x73,0x7e,0x6e,0xdd,0xe1,0x6a,0xa4,0x17,0x24,0xb4,0x33,0xf5,0x5b,0x96,0x54,0x59,0x16,0x4c,0x1a,0xdb,0xd2,0x64,0x83,0x39,0xa5,0x4c,0x57,0x87,0x56,0x3c,0x8c,0xcc,0x69,0x10,0xe9,0xb8,0x7e,0x9a,0x52,0x4a,0xef,0xee,0x7a,0xbd,0x2b,0xab,0xe4,0x47,0xc2,0x8f,0x37,0xe1,0xb9,0x22,0x63,0xc0,0x9e,0x53,0x4a,0xa4,0x6e,0x30,0x1f,0xc1,0x36,0x4f,0xeb,0x86,0x1c,0xef,0x36,0x8c,0xa7,0xf5,0xf9,0xb1,0x7e,0xe4,0xf8,0x54,0xb1,0x9a,0x34,0x63,0x10,0xbe,0x90,0x6b,0x20,0xeb,0x00,0x55,0x35,0x50,0xa0,0xac,0x01,0x59,0x1b,0x6b,0xb0,0x4b,0x60,0xbb,0xa1,0x70,0xce,0xd3,0xe6,0x78,0xe3,0x96,0x19,0xdb,0x31,0x92,0x8d,0x81,0x5b,0xf2,0xbf,0xfd,0xaa,0xf0,0xab,0x83,0x71,0x27,0x2e,0xfe,0x3f,0x4d,0xcc,0x09,0xa7,0xc7,0x7c,0x2c,0x78,0x88,0xb2,0x58,0x57,0x5d,0x8f,0x57,0x22,0x3f,0x80,0x1f,0xbd,0x0b,0x3c,0x4a,0x38,0xa9,0xd9,0xf6,0x96,0xb2,0x1d,0xb8,0x00,0x54,0x95,0x57,0x01,0x06,0xb0,0xb0,0x1f,0x26,0x45,0xfe,0xa9,0x83,0x85,0x5c,0xe7,0xd7,0x18,0x90,0x3b,0x41,0xad,0x37,0x44,0x92,0x66,0x21,0xc1,0x92,0x7a,0x1d,0x1e,0x38,0x4b,0x2b,0x31,0x25,0xeb,0x5e,0x37,0x11,0xee,0x84,0x83,0xe6,0xbf,0xdd,0x11,0x32,0x05,0xd0,0xc5,0x74,0x86,0xe7,0x5b,0x8f,0x55,0xb3,0xe8,0x70,0x90,0xe9,0x36,0xd7,0xc9,0x90,0x6d,0x7c,0x1e,0x7f,0x46,0x2b,0x6d,0x9f,0xc6,0x6b,0x5e,0x4c,0x1d,0xd3,0xac,0x8b,0xc3,0x3a,0xa4,0x28,0x3e,0x65,0x13,0xaf,0xbf,0x84,0x9c,0x3c,0xef,0x2d,0xbf,0x5a,0x04,0xd9,0x7d,0xf0,0x54,0xb4,0xcd,0x6c,0xa8,0x24,0xae,0x57,0x36,0xd1,0x54,0x4a,0xd6,0xbb,0x54,0xe3,0xe4,0x00,0x93,0xbe,0x81,0xfd,0xa5,0x56,0x63,0x8a,0x8c,0x57,0xa0,0x74,0x9f,0x7d,0x03,0x14,0x1d,0xbe,0x11,0x8a,0xf1,0x7f,0x28,0xaa,0xf2,0x4f,0x28,0x5f,0x7b,0x3f,0x01,0x5e,0xc5,0x7a,0x23,0x55,0x03,0x00,0x00

View File

@ -0,0 +1 @@
0x1f,0x8b,0x08,0x08,0x09,0xad,0xc3,0x59,0x00,0x03,0x66,0x61,0x76,0x69,0x63,0x6f,0x6e,0x5f,0x73,0x74,0x6f,0x72,0x65,0x2e,0x62,0x69,0x6e,0x00,0xad,0x52,0x41,0x4f,0xc2,0x30,0x14,0xbe,0xef,0x57,0xbc,0x70,0xd2,0x44,0xec,0xca,0xd8,0x86,0x33,0x1e,0xde,0x66,0x25,0x44,0x9a,0x28,0xd9,0x4d,0x3c,0x4c,0x28,0xa5,0x07,0xbb,0x65,0x4c,0x1d,0x18,0xff,0xbb,0x6d,0x17,0x08,0x12,0x8f,0x7c,0xed,0xd7,0x7e,0xef,0xbd,0xaf,0xc9,0x6b,0xda,0x17,0x6f,0x55,0x7c,0xaa,0x45,0xa9,0xaf,0xcd,0x02,0xdf,0x40,0xfd,0x10,0x02,0x3a,0x02,0x1a,0x44,0x91,0x1f,0x44,0x61,0x1c,0x18,0x79,0x13,0x87,0xf1,0x60,0x34,0xf4,0xe1,0xc2,0x43,0xc4,0x14,0x91,0x21,0x4b,0xf1,0x19,0x3b,0x94,0x56,0x3d,0x48,0xa3,0x32,0xbb,0x74,0xf9,0x89,0x2b,0x31,0x6b,0x76,0x90,0xf8,0x17,0xec,0xa0,0xee,0x89,0xdb,0x1e,0xdb,0x31,0x3e,0x11,0x42,0xbe,0xd2,0x8a,0x90,0x11,0x9e,0x11,0x72,0x92,0x19,0x4a,0xcc,0xdc,0xae,0x5c,0x8c,0x4e,0x77,0xb1,0xda,0x6b,0xb4,0x94,0xa8,0x4c,0xf5,0xb4,0xdd,0x0e,0x29,0x9b,0xfd,0x33,0x72,0xde,0xf2,0x1d,0xb3,0x9c,0xf1,0x9c,0xb5,0xcc,0x90,0xcf,0x0c,0x73,0x1b,0xf3,0x93,0xd8,0xd5,0x77,0xfc,0xf8,0xfc,0x39,0xef,0x7a,0x80,0xe7,0xf5,0xb2,0x52,0x37,0x42,0x37,0xfd,0x7c,0x5b,0x89,0x04,0xd4,0x7b,0x21,0x05,0x69,0xfb,0xf6,0xad,0x6f,0x61,0xb1,0x2e,0xea,0x8d,0x68,0xee,0xde,0x94,0x2e,0xea,0xed,0xbc,0x9e,0x6b,0xd6,0x56,0xaa,0x16,0x9b,0x04,0xf2,0x0f,0x71,0x05,0x34,0x04,0xac,0x6a,0x18,0xf8,0xa1,0x0f,0x74,0x98,0x0c,0x7d,0x33,0x61,0xcc,0x73,0xeb,0x9c,0x16,0x9b,0xa6,0xcf,0xcb,0xa5,0x5a,0x29,0xb1,0x4c,0x80,0x97,0xfa,0xc8,0x4f,0x63,0xeb,0x0f,0xa2,0x84,0x06,0x7b,0xff,0xbe,0x8f,0xa9,0xd0,0xb2,0x59,0x27,0xf6,0x7b,0xd9,0xb4,0x65,0xcf,0xb4,0xd9,0xb3,0xf3,0x12,0x7e,0xbc,0x57,0xef,0x17,0x2f,0x31,0xe8,0x6f,0x8d,0x02,0x00,0x00

View File

@ -2493,7 +2493,7 @@ unsigned char* UHTTP2::hpackEncodeHeader(unsigned char* dst, const UString& name
U_ASSERT(name == U_STRING_FROM_CONSTANT("Content-Style-Type") ||
name == U_STRING_FROM_CONSTANT("Content-Script-Type"))
U_ERROR("Content-Style-Type and Content-Script-Type are not supported");
U_WARNING("Content-Style-Type and Content-Script-Type are not supported");
}
# endif
}

File diff suppressed because one or more lines are too long

View File

@ -571,7 +571,7 @@ void UServices::releaseEngine(ENGINE* e, bool bkey)
}
}
EVP_PKEY* UServices::loadKey(const UString& x, const char* format, bool _private, const char* password, ENGINE* e)
EVP_PKEY* UServices::loadKey(UString& x, const char* format, bool _private, const char* password, ENGINE* e)
{
U_TRACE(0, "UServices::loadKey(%V,%S,%b,%S,%p)", x.rep, format, _private, password, e)
@ -629,7 +629,7 @@ done:
* passwd is the corresponding password for the private key
*/
UString UServices::getSignatureValue(int alg, const UString& data, const UString& pkey, const UString& passwd, int base64, ENGINE* e)
UString UServices::getSignatureValue(int alg, const UString& data, UString& pkey, UString& passwd, int base64, ENGINE* e)
{
U_TRACE(0,"UServices::getSignatureValue(%d,%V,%V,%V,%d,%p)", alg, data.rep, pkey.rep, passwd.rep, base64, e)
@ -668,7 +668,7 @@ UString UServices::getSignatureValue(int alg, const UString& data, const UString
U_RETURN_STRING(output);
}
bool UServices::verifySignature(int alg, const UString& data, const UString& signature, const UString& pkey, ENGINE* e)
bool UServices::verifySignature(int alg, const UString& data, const UString& signature, UString& pkey, ENGINE* e)
{
U_TRACE(0, "UServices::verifySignature(%d,%V,%V,%V,%p)", alg, data.rep, signature.rep, pkey.rep, e)

View File

@ -1222,7 +1222,8 @@ UString UStringExt::decompress(const char* s, uint32_t n)
#ifdef DEBUG
int r =
#endif
U_SYSCALL(mz_uncompress, "%p,%p,%p,%u", (unsigned char*)out.rep->data(), &out_len, (const unsigned char*)ptr + sizeof(uint32_t), n - U_CONSTANT_SIZE(U_MINIZ_COMPRESS) - sizeof(uint32_t));
U_SYSCALL(mz_uncompress, "%p,%p,%p,%u", (unsigned char*)out.rep->data(), &out_len,
(const unsigned char*)ptr + sizeof(uint32_t), n - U_CONSTANT_SIZE(U_MINIZ_COMPRESS) - sizeof(uint32_t));
U_INTERNAL_ASSERT_EQUALS(r, Z_OK)
@ -1233,6 +1234,83 @@ UString UStringExt::decompress(const char* s, uint32_t n)
U_RETURN_STRING(out);
}
#ifdef USE_LIBBROTLI
UString UStringExt::brotli(const char* s, uint32_t len, uint32_t quality, uint32_t mode, uint32_t lgwin) // .br compress
{
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... */
if (sz == 0) return UString::getStringNull();
if (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);
U_INTERNAL_DUMP("BrotliEncoderCompress() = %d (%u => %u)", rc, len, sz)
if (rc == 0) return UString::getStringNull();
len = UFile::getSizeAligned(sz);
UString result(sz, len, UFile::pfree);
UFile::pfree += len;
UFile::nfree -= len;
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());
U_INTERNAL_DUMP("BrotliEncoderCompress() = %d (%u => %u)", rc, len, sz)
if (rc == 0) return UString::getStringNull();
r.rep->_length = sz;
U_RETURN_STRING(r);
}
UString UStringExt::unbrotli(const char* ptr, uint32_t sz) // .br uncompress
{
U_TRACE(0, "UStringExt::unbrotli(%.*S,%u)", sz, ptr, sz)
UString r(sz);
const uint8_t* next_out;
BrotliDecoderResult result;
size_t input_len = sz, available_out;
const uint8_t* input = (const uint8_t*)ptr;
BrotliDecoderState* state = (BrotliDecoderState*) U_SYSCALL(BrotliDecoderCreateInstance, "%p,%p,%p", U_NULLPTR, U_NULLPTR, U_NULLPTR);
do {
available_out = 0;
result = (BrotliDecoderResult) U_SYSCALL(BrotliDecoderDecompressStream, "%p,%p,%p,%p,%p,%p", state, &input_len, &input, &available_out, U_NULLPTR, U_NULLPTR);
next_out = BrotliDecoderTakeOutput(state, &available_out);
if (available_out) (void) r.append((const char*)next_out, available_out);
}
while (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT);
if (result != BROTLI_DECODER_RESULT_SUCCESS)
{
BrotliDecoderErrorCode code = (BrotliDecoderErrorCode) U_SYSCALL(BrotliDecoderGetErrorCode, "%p", state);
U_WARNING("brotli decoder fail, error %S", BrotliDecoderErrorString(code));
}
U_SYSCALL_VOID(BrotliDecoderDestroyInstance, "%p", state);
U_RETURN_STRING(r);
}
#endif
UString UStringExt::deflate(const char* s, uint32_t len, int type) // .gz compress
{
U_TRACE(1, "UStringExt::deflate(%.*S,%u,%d)", len, s, len, type)

File diff suppressed because it is too large Load Diff

View File

@ -89,8 +89,6 @@ int U_EXPORT main(int argc, char** argv)
raise(SIGUSR2); // trace on/off
u_trace_handlerSignal();
U_TRACE(5, "main(%d)", argc)
U_SET_LOCATION_INFO;

View File

@ -70,12 +70,7 @@ int U_EXPORT main(int argc, char* argv[])
U_TRACE(5, "main(%d)", argc)
if (argc < 2)
{
raise(SIGUSR2); // trace on/off
u_trace_handlerSignal();
}
if (argc < 2) raise(SIGUSR2); // trace on/off
int c = routine1(2, 3);

View File

@ -22,9 +22,9 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
# PLAINTEXT
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
UMEMPOOL="58,0,0,41,16401,-14,-15,11,25"
sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 16384|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
#UMEMPOOL="58,0,0,41,16401,-14,-15,11,25"
#sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET 0|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
#sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 16384|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
#Running 15s test @ http://localhost:8080/plaintext
# 4 threads and 256 connections
@ -62,15 +62,15 @@ export ORM_DRIVER ORM_OPTION UMEMPOOL
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
# DB
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
#ORM_DRIVER="sqlite"
#ORM_OPTION="host=localhost dbname=../db/hello_world"
ORM_DRIVER="sqlite"
ORM_OPTION="host=localhost dbname=../db/hello_world"
#ORM_DRIVER="mysql"
#ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass character-set=utf8 dbname=hello_world"
#ORM_DRIVER="pgsql"
#ORM_OPTION="host=localhost user=benchmarkdbuser password=benchmarkdbpass dbname=hello_world"
#UMEMPOOL="545,0,0,49,275,-14,-13,-25,41"
#sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
#sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
UMEMPOOL="545,0,0,49,275,-14,-13,-25,41"
sed -i "s|TCP_LINGER_SET .*|TCP_LINGER_SET -2|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
sed -i "s|LISTEN_BACKLOG .*|LISTEN_BACKLOG 256|g" benchmark/FrameworkBenchmarks/fbenchmark.cfg
# ----------------------------------------------------------------------------------------------------------------------------------------------------------
#Running 15s test @ http://localhost:8080/fortune
# 4 threads and 256 connections

View File

@ -1,3 +1,2 @@
[ / /index.php
/fortunes /servlet/fortunes
[ /fortunes /servlet/fortunes
/plaintext /servlet/plaintext ]

View File

@ -2,14 +2,16 @@ userver {
PORT 8080
PREFORK_CHILD 4
TCP_LINGER_SET 0
LISTEN_BACKLOG 16384
TCP_LINGER_SET -2
LISTEN_BACKLOG 256
DOCUMENT_ROOT benchmark/FrameworkBenchmarks/ULib/www
PID_FILE ../userver_tcp.pid
# LOG_FILE ../../benchmark.log
# LOG_FILE_SZ 50M
# LOG_MSG_SIZE -1
ORM_DRIVER "sqlite"
LOG_FILE ../../benchmark.log
LOG_FILE_SZ 50M
LOG_MSG_SIZE -1
DOS_WHITE_LIST 127.0.0.1

View File

@ -1,3 +1,4 @@
GET ?mac=d0%3A51%3A62%3Aac%3A2a%3Afb&ip=172.16.176.76&redirect=http%3A//www.florence-tourisme.com/eglise-santa-croce.html&gateway=172.16.176.254%3A5280&timeout=0&token=958670840&ap=ap@10.8.0.176 HTTP/1.1
Host: 10.30.1.131
Connection: close

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
start_msg tsa_http
#UTRACE="0 75M 0"
UTRACE="0 75M 0"
#UOBJDUMP="0 10M 10"
#USIMERR="error.sim"
export UTRACE UOBJDUMP USIMERR

View File

@ -117,8 +117,8 @@ cat <<EOF >inp/webserver.cfg
userver {
PORT 8080
RUN_AS_USER nobody
#MIN_SIZE_FOR_SENDFILE 2k
REQ_TIMEOUT 30
#MIN_SIZE_FOR_SENDFILE 1k
REQ_TIMEOUT 5
DOS_WHITE_LIST 127.0.0.1,10.30.0.0/16
LOG_FILE webserver$1.log
LOG_FILE_SZ 1M
@ -128,8 +128,8 @@ userver {
PLUGIN_DIR ../../../src/ulib/net/server/plugin/.libs
ORM_DRIVER_DIR ../../../src/ulib/orm/driver/.libs
PREFORK_CHILD $N
CRASH_COUNT 1
CRASH_EMAIL_NOTIFY mail.unirel.com:stefano.casazza@unirel.com
#CRASH_COUNT 1
#CRASH_EMAIL_NOTIFY mail.unirel.com:stefano.casazza@unirel.com
}
http {
ENABLE_INOTIFY yes

View File

@ -6,7 +6,7 @@
start_msg file
#UTRACE="0 1M -1"
#UTRACE="0 10M -1"
#UOBJDUMP="-1 100k 10"
#USIMERR="error.sim"
export UTRACE UOBJDUMP USIMERR

1
tests/ulib/inp/16k.txt Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,15 +2,15 @@ name = Moshe
1 Moshe
2 Yossi
There are 2 users
Fri Feb 20 20:31:01 2015
Tue Sep 19 15:05:48 2017
ID: 1, Affected rows: 1
ID: 2, Affected rows: 1
Rows: 2
Cols: 5
1 10 3.14159 Hello 'World' Fri Feb 20 20:31:01 2015
1 10 3.14159 Hello 'World' Tue Sep 19 15:05:48 2017
has 5 columns
2 10 3.14159 Hello 'World' Fri Feb 20 20:31:01 2015
2 10 3.14159 Hello 'World' Tue Sep 19 15:05:48 2017
has 5 columns
Deleted 2 rows

View File

@ -13,16 +13,17 @@ plugin/product1.lo: plugin/product1.cpp /usr/include/stdc-predef.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/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
/usr/include/bits/stdio.h \
/usr/include/bits/stdio.h /usr/include/bits/stdio2.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdint.h \
/usr/include/stdint.h /usr/include/bits/wchar.h /usr/include/unistd.h \
/usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
/usr/include/bits/confname.h /usr/include/getopt.h \
/usr/include/sys/uio.h /usr/include/sys/types.h /usr/include/time.h \
/usr/include/endian.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/select.h \
/usr/include/bits/sigset.h /usr/include/bits/time.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/bits/endian.h /usr/include/bits/byteswap.h \
/usr/include/bits/byteswap-16.h /usr/include/sys/select.h \
/usr/include/bits/select.h /usr/include/bits/sigset.h \
/usr/include/bits/time.h /usr/include/bits/select2.h \
/usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \
/usr/include/bits/uio.h /usr/include/sys/stat.h /usr/include/bits/stat.h \
/usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
@ -40,12 +41,14 @@ plugin/product1.lo: plugin/product1.cpp /usr/include/stdc-predef.h \
/usr/include/stdlib.h /usr/include/bits/waitflags.h \
/usr/include/bits/waitstatus.h /usr/include/alloca.h \
/usr/include/bits/stdlib-bsearch.h /usr/include/bits/stdlib-float.h \
/usr/include/bits/stdlib.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/std_abs.h \
/usr/include/ctype.h ../../include/ulib/base/replace/replace.h \
/usr/src/linux/include/generated/uapi/linux/version.h \
/usr/include/openssl/opensslv.h /usr/include/string.h \
/usr/include/fcntl.h /usr/include/bits/fcntl.h \
/usr/include/bits/fcntl-linux.h /usr/include/errno.h \
/usr/include/bits/string3.h /usr/include/fcntl.h \
/usr/include/bits/fcntl.h /usr/include/bits/fcntl-linux.h \
/usr/include/bits/fcntl2.h /usr/include/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-generic/errno-base.h /usr/include/sys/time.h \
@ -65,6 +68,7 @@ plugin/product1.lo: plugin/product1.cpp /usr/include/stdc-predef.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/memoryfwd.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/postypes.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/cwchar \
/usr/include/bits/wchar2.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/exception \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/exception.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/exception_ptr.h \
@ -215,6 +219,8 @@ plugin/product.h:
/usr/include/bits/stdio.h:
/usr/include/bits/stdio2.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdint.h:
/usr/include/stdint.h:
@ -231,6 +237,8 @@ plugin/product.h:
/usr/include/getopt.h:
/usr/include/bits/unistd.h:
/usr/include/sys/uio.h:
/usr/include/sys/types.h:
@ -253,6 +261,8 @@ plugin/product.h:
/usr/include/bits/time.h:
/usr/include/bits/select2.h:
/usr/include/sys/sysmacros.h:
/usr/include/bits/pthreadtypes.h:
@ -313,6 +323,8 @@ plugin/product.h:
/usr/include/bits/stdlib-float.h:
/usr/include/bits/stdlib.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/std_abs.h:
/usr/include/ctype.h:
@ -325,12 +337,16 @@ plugin/product.h:
/usr/include/string.h:
/usr/include/bits/string3.h:
/usr/include/fcntl.h:
/usr/include/bits/fcntl.h:
/usr/include/bits/fcntl-linux.h:
/usr/include/bits/fcntl2.h:
/usr/include/errno.h:
/usr/include/bits/errno.h:
@ -387,6 +403,8 @@ plugin/product.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/cwchar:
/usr/include/bits/wchar2.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/exception:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/exception.h:

View File

@ -13,16 +13,17 @@ plugin/product2.lo: plugin/product2.cpp /usr/include/stdc-predef.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/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
/usr/include/bits/stdio.h \
/usr/include/bits/stdio.h /usr/include/bits/stdio2.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdint.h \
/usr/include/stdint.h /usr/include/bits/wchar.h /usr/include/unistd.h \
/usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
/usr/include/bits/confname.h /usr/include/getopt.h \
/usr/include/sys/uio.h /usr/include/sys/types.h /usr/include/time.h \
/usr/include/endian.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/select.h \
/usr/include/bits/sigset.h /usr/include/bits/time.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/bits/endian.h /usr/include/bits/byteswap.h \
/usr/include/bits/byteswap-16.h /usr/include/sys/select.h \
/usr/include/bits/select.h /usr/include/bits/sigset.h \
/usr/include/bits/time.h /usr/include/bits/select2.h \
/usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \
/usr/include/bits/uio.h /usr/include/sys/stat.h /usr/include/bits/stat.h \
/usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
@ -40,12 +41,14 @@ plugin/product2.lo: plugin/product2.cpp /usr/include/stdc-predef.h \
/usr/include/stdlib.h /usr/include/bits/waitflags.h \
/usr/include/bits/waitstatus.h /usr/include/alloca.h \
/usr/include/bits/stdlib-bsearch.h /usr/include/bits/stdlib-float.h \
/usr/include/bits/stdlib.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/std_abs.h \
/usr/include/ctype.h ../../include/ulib/base/replace/replace.h \
/usr/src/linux/include/generated/uapi/linux/version.h \
/usr/include/openssl/opensslv.h /usr/include/string.h \
/usr/include/fcntl.h /usr/include/bits/fcntl.h \
/usr/include/bits/fcntl-linux.h /usr/include/errno.h \
/usr/include/bits/string3.h /usr/include/fcntl.h \
/usr/include/bits/fcntl.h /usr/include/bits/fcntl-linux.h \
/usr/include/bits/fcntl2.h /usr/include/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-generic/errno-base.h /usr/include/sys/time.h \
@ -65,6 +68,7 @@ plugin/product2.lo: plugin/product2.cpp /usr/include/stdc-predef.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/memoryfwd.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/postypes.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/cwchar \
/usr/include/bits/wchar2.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/exception \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/exception.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/exception_ptr.h \
@ -215,6 +219,8 @@ plugin/product.h:
/usr/include/bits/stdio.h:
/usr/include/bits/stdio2.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/stdint.h:
/usr/include/stdint.h:
@ -231,6 +237,8 @@ plugin/product.h:
/usr/include/getopt.h:
/usr/include/bits/unistd.h:
/usr/include/sys/uio.h:
/usr/include/sys/types.h:
@ -253,6 +261,8 @@ plugin/product.h:
/usr/include/bits/time.h:
/usr/include/bits/select2.h:
/usr/include/sys/sysmacros.h:
/usr/include/bits/pthreadtypes.h:
@ -313,6 +323,8 @@ plugin/product.h:
/usr/include/bits/stdlib-float.h:
/usr/include/bits/stdlib.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/std_abs.h:
/usr/include/ctype.h:
@ -325,12 +337,16 @@ plugin/product.h:
/usr/include/string.h:
/usr/include/bits/string3.h:
/usr/include/fcntl.h:
/usr/include/bits/fcntl.h:
/usr/include/bits/fcntl-linux.h:
/usr/include/bits/fcntl2.h:
/usr/include/errno.h:
/usr/include/bits/errno.h:
@ -387,6 +403,8 @@ plugin/product.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/cwchar:
/usr/include/bits/wchar2.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/exception:
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/bits/exception.h:

View File

@ -9,7 +9,7 @@ start_msg server
rm -rf err/server.err \
trace.*server*.[0-9]* object.*server*.[0-9]* stack.*server*.[0-9]*
#UTRACE="0 20M 0"
#UTRACE="0 20M -1"
#UTRACE_SIGNAL="0 10M 0"
#UOBJDUMP="0 50M 1000"
#USIMERR="error.sim"

View File

@ -78,7 +78,10 @@ U_EXPORT main (int argc, char* argv[])
U_TRACE(5,"main(%d)",argc)
U_INTERNAL_DUMP("argv[0] = %S argv[1] = %S argv[2] = %S argv[3] = %S", argv[0], argv[1], argv[2], argv[3])
UString str = UFile::contentOf(U_STRING_FROM_CONSTANT("inp/16k.txt"));
// U_INTERNAL_DUMP("*(str.pend()) = %C", *(str.pend()))
// U_ASSERT( str.isNullTerminated() )
UFile x;
UString buffer(500U), tmp = U_STRING_FROM_CONSTANT("/mnt/source");
@ -88,6 +91,8 @@ U_EXPORT main (int argc, char* argv[])
UFile::close( UFile::mkTemp() );
U_INTERNAL_DUMP("argv[0] = %S argv[1] = %S argv[2] = %S argv[3] = %S", argv[0], argv[1], argv[2], argv[3])
#ifndef __MINGW32__
buffer.assign(argv[1]);
x.setPath(U_STRING_FROM_CONSTANT("~"));
@ -128,7 +133,8 @@ U_EXPORT main (int argc, char* argv[])
UString name;
name = U_STRING_FROM_CONSTANT("/tmp/test_rdb"); // evitare NFS lock...
if (y.creat(name) && y.lock())
if (y.creat(name) &&
y.lock())
{
y.ftruncate(6000);
y.memmap();
@ -167,9 +173,7 @@ U_EXPORT main (int argc, char* argv[])
tmp1.c_str();
#endif
#ifdef U_LINUX_BUG
// test CRESCIOLI
#ifdef U_LINUX_BUG // test CRESCIOLI
UString buffer1;
ofstream of("DA_BUTTARE");