From e4cad798209faea92f83b832fbef71a5750175ca Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Thu, 27 Sep 2018 16:52:45 +0200 Subject: [PATCH] sync --- configure | 20 ++++++++++---------- configure.ac | 2 +- examples/userver/userver.cfg.default | 2 ++ include/ulib/container/vector.h | 16 +++++++++++----- include/ulib/event/event_db.h | 6 +----- include/ulib/serialize/flatbuffers.h | 3 +++ include/ulib/utility/uhttp.h | 3 ++- rpm.sh | 2 +- src/ulib/net/server/plugin/mod_http.cpp | 13 +++++++++++++ src/ulib/net/socket.cpp | 5 +---- src/ulib/utility/uhttp.cpp | 15 +++++++++++++-- tests/examples/TSA/tsaserial | 2 +- tests/examples/python/triangle.py | 8 ++++++++ tests/examples/wi-auth2.sh | 1 + 14 files changed, 68 insertions(+), 30 deletions(-) create mode 100644 tests/examples/python/triangle.py diff --git a/configure b/configure index 865b3176..649ad635 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ULib 1.4.2. +# Generated by GNU Autoconf 2.69 for ULib 2.4.2. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ULib' PACKAGE_TARNAME='ULib' -PACKAGE_VERSION='1.4.2' -PACKAGE_STRING='ULib 1.4.2' +PACKAGE_VERSION='2.4.2' +PACKAGE_STRING='ULib 2.4.2' PACKAGE_BUGREPORT='stefano.casazza@gmail.com' PACKAGE_URL='http://stefanocasazza.github.io/ULib/' @@ -1691,7 +1691,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ULib 1.4.2 to adapt to many kinds of systems. +\`configure' configures ULib 2.4.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1762,7 +1762,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ULib 1.4.2:";; + short | recursive ) echo "Configuration of ULib 2.4.2:";; esac cat <<\_ACEOF @@ -1985,7 +1985,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ULib configure 1.4.2 +ULib configure 2.4.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -3130,7 +3130,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ULib $as_me 1.4.2, which was +It was created by ULib $as_me 2.4.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4133,7 +4133,7 @@ fi # Define the identity of the package. PACKAGE='ULib' - VERSION='1.4.2' + VERSION='2.4.2' # Some tools Automake needs. @@ -36728,7 +36728,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ULib $as_me 1.4.2, which was +This file was extended by ULib $as_me 2.4.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -36795,7 +36795,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ULib config.status 1.4.2 +ULib config.status 2.4.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 0e0212e0..cc6786ca 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ # This macro must be the very first invoked AC_PREREQ([2.69]) -AC_INIT([ULib],[1.4.2],[stefano.casazza@gmail.com],[ULib],[http://stefanocasazza.github.io/ULib/]) +AC_INIT([ULib],[2.4.2],[stefano.casazza@gmail.com],[ULib],[http://stefanocasazza.github.io/ULib/]) AC_CONFIG_SRCDIR([src/ulib/string.cpp]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/examples/userver/userver.cfg.default b/examples/userver/userver.cfg.default index 01403a60..94295329 100644 --- a/examples/userver/userver.cfg.default +++ b/examples/userver/userver.cfg.default @@ -185,6 +185,8 @@ userver { # NOCACHE_FILE_MASK mask (DOS regexp) of pathfile that content NOT be cached in memory # CACHE_FILE_STORE pathfile of memory cache filesystem stored on a single file (may be compressed) # +# CACHE_FILE_AS_DYNAMIC_MASK mask (DOS regexp) of pathfile that content be cached as dynamic in memory (to avoid 'Last-Modified: ...' in header response) +# # CGI_TIMEOUT timeout for cgi execution # VIRTUAL_HOST flag to activate practice of maintaining more than one server on one machine, as differentiated by their apparent hostname # DIGEST_AUTHENTICATION flag authentication method (yes = digest, no = basic) diff --git a/include/ulib/container/vector.h b/include/ulib/container/vector.h index 4269a954..4761c495 100644 --- a/include/ulib/container/vector.h +++ b/include/ulib/container/vector.h @@ -915,6 +915,16 @@ private: }; #if defined(U_STDCPP_ENABLE) && defined(HAVE_CXX11) +/** + * for (decl : rng) { ... } is equivalent to: { + * auto && __range = rng; + * auto __begin = begin(__range); + * auto __end = end(__range) ; + * for ( ; __begin != __end; ++__begin ) { + * decl = *__begin; + * ... + * } } + */ class UVectorStringIter { // this class is to make work Range-based for loop: for ( UString x : UVector ) loop_statement public: explicit UVectorStringIter(const UVector* p_vec, uint32_t pos) : _pos(pos), _p_vec(p_vec) {} @@ -929,11 +939,7 @@ public: { ++_pos; - // although not strictly necessary for a range-based for loop - // following the normal convention of returning a value from - // operator++ is a good idea - - return *this; + return *this; // although not strictly necessary for a range-based for loop following the normal convention of returning a value from operator++ is a good idea } private: diff --git a/include/ulib/event/event_db.h b/include/ulib/event/event_db.h index 1ca2ec1c..c77b49ff 100644 --- a/include/ulib/event/event_db.h +++ b/include/ulib/event/event_db.h @@ -16,7 +16,7 @@ #include -#define U_QUERY_INFO_SZ 168 +#define U_QUERY_INFO_SZ 1024 class UServer_Base; class UClientImage_Base; @@ -27,10 +27,6 @@ public: // Check for memory error U_MEMORY_TEST - // Allocator e Deallocator - U_MEMORY_ALLOCATOR - U_MEMORY_DEALLOCATOR - UEventDB(); ~UEventDB(); diff --git a/include/ulib/serialize/flatbuffers.h b/include/ulib/serialize/flatbuffers.h index cde76577..a4692476 100644 --- a/include/ulib/serialize/flatbuffers.h +++ b/include/ulib/serialize/flatbuffers.h @@ -21,6 +21,9 @@ #endif /** + * Serialization is the process of translating data structures or object state into a format that can be stored (for example, in a file or + * memory buffer) or transmitted (for example, across a network connection link) and reconstructed later (possibly in a different computer environment) + * * @see http://google.github.io/flatbuffers/index.html * * All data is accessed over offsets, all scalars are aligned to their own size, and all data is always stored in little endian format. diff --git a/include/ulib/utility/uhttp.h b/include/ulib/utility/uhttp.h index a725feb0..8b60c5ee 100644 --- a/include/ulib/utility/uhttp.h +++ b/include/ulib/utility/uhttp.h @@ -1207,9 +1207,10 @@ private: static UString* cache_file_mask; static UString* cache_avoid_mask; static UString* cache_file_store; - static UString* nocache_file_mask; static UFileCacheData* file_data; + static UString* nocache_file_mask; static UFileCacheData* file_gzip_bomb; + static UString* cache_file_as_dynamic_mask; static UHashMap* cache_file; static UFileCacheData* file_not_in_cache_data; diff --git a/rpm.sh b/rpm.sh index 3e0cdb05..8ad52e45 100644 --- a/rpm.sh +++ b/rpm.sh @@ -3,7 +3,7 @@ PACKAGE=$HOME/rpmbuild # fedora #PACKAGE=/usr/src/packages # SUSE -VERSION=1.4.2 +VERSION=2.4.2 run_build() { diff --git a/src/ulib/net/server/plugin/mod_http.cpp b/src/ulib/net/server/plugin/mod_http.cpp index 181bed7c..befa17c8 100644 --- a/src/ulib/net/server/plugin/mod_http.cpp +++ b/src/ulib/net/server/plugin/mod_http.cpp @@ -78,6 +78,8 @@ int UHttpPlugIn::handlerConfig(UFileConfig& cfg) // NOCACHE_FILE_MASK mask (DOS regexp) of pathfile that content NOT be cached in memory // CACHE_FILE_STORE pathfile of memory cache stored on filesystem // + // CACHE_FILE_AS_DYNAMIC_MASK mask (DOS regexp) of pathfile that content be cached as dynamic in memory (to avoid 'Last-Modified: ...' in header response) + // // CGI_TIMEOUT timeout for cgi execution // VIRTUAL_HOST flag to activate practice of maintaining more than one server on one machine, as differentiated by their apparent hostname // DIGEST_AUTHENTICATION flag authentication method (yes = digest, no = basic) @@ -225,6 +227,17 @@ int UHttpPlugIn::handlerConfig(UFileConfig& cfg) U_NEW_STRING(UHTTP::nocache_file_mask, UString(x)); } + x = cfg.at(U_CONSTANT_TO_PARAM("CACHE_FILE_AS_DYNAMIC_MASK")); + + if (x) + { + U_INTERNAL_ASSERT_EQUALS(UHTTP::cache_file_as_dynamic_mask, U_NULLPTR) + + if (x.findWhiteSpace() != U_NOT_FOUND) x = UStringExt::removeWhiteSpace(x); + + U_NEW_STRING(UHTTP::cache_file_as_dynamic_mask, UString(x)); + } + # ifdef U_STDCPP_ENABLE x = cfg.at(U_CONSTANT_TO_PARAM("CACHE_FILE_STORE")); diff --git a/src/ulib/net/socket.cpp b/src/ulib/net/socket.cpp index e7fa7981..daec4cb3 100644 --- a/src/ulib/net/socket.cpp +++ b/src/ulib/net/socket.cpp @@ -448,10 +448,7 @@ bool USocket::enable_bpf() { BPF_RET | BPF_A, 0, 0, 0 } }; - struct sock_fprog p = { - .len = 2, - .filter = code, - }; + struct sock_fprog p = { 2, code }; /** * the kernel will call the specified filter to distribute the packets among the SO_REUSEPORT sockets group. diff --git a/src/ulib/utility/uhttp.cpp b/src/ulib/utility/uhttp.cpp index c11675da..cc6f7e6e 100644 --- a/src/ulib/utility/uhttp.cpp +++ b/src/ulib/utility/uhttp.cpp @@ -108,6 +108,7 @@ UString* UHTTP::cgi_cookie_option; UString* UHTTP::set_cookie_option; UString* UHTTP::user_authentication; UString* UHTTP::string_HTTP_Variables; +UString* UHTTP::cache_file_as_dynamic_mask; uint32_t UHTTP::old_path_len; uint32_t UHTTP::sid_counter_gen; uint32_t UHTTP::sid_counter_cur; @@ -9243,7 +9244,7 @@ manage: } else if (file->open()) { - UString content; + UString content, header; const char* ptr = U_NULLPTR; mime_index = file_data->mime_index; @@ -9262,7 +9263,17 @@ manage: ptr = content.data(); } - putDataInCache(lpathname, getHeaderMimeType(ptr, 0, ctype, U_TIME_FOR_EXPIRE), content); + if (cache_file_as_dynamic_mask && + UServices::dosMatchWithOR(basename_ptr, basename_len, U_STRING_TO_PARAM(*cache_file_as_dynamic_mask), 0)) + { + mime_index = '9'; // NB: '9' => we declare a dynamic page to avoid 'Last-Modified: ...' in header response... + } + + header = getHeaderMimeType(ptr, 0, ctype, U_TIME_FOR_EXPIRE); + + mime_index = file_data->mime_index; + + putDataInCache(lpathname, header, content); } } diff --git a/tests/examples/TSA/tsaserial b/tests/examples/TSA/tsaserial index cde5dce2..d09d57e1 100644 --- a/tests/examples/TSA/tsaserial +++ b/tests/examples/TSA/tsaserial @@ -1 +1 @@ -0400 +040E diff --git a/tests/examples/python/triangle.py b/tests/examples/python/triangle.py new file mode 100644 index 00000000..3cac3753 --- /dev/null +++ b/tests/examples/python/triangle.py @@ -0,0 +1,8 @@ +from math import sqrt +print('Entrer du triangle isocele du sommet A le 2 cotes a = BC et b = AC = AB:') +str = input('a = ') +a = float(str) +str = input('b = ') +b = float(str) +h = sqrt(a*a - (b*b /4)) +print("l'aire du triangle isocele, ayant base {0} et hauteur {1} il est: {2}".format(a, h, (a*h)/2)) diff --git a/tests/examples/wi-auth2.sh b/tests/examples/wi-auth2.sh index ba114edd..6f72b356 100755 --- a/tests/examples/wi-auth2.sh +++ b/tests/examples/wi-auth2.sh @@ -36,6 +36,7 @@ userver { http { CACHE_AVOID_MASK ap|immagini NOCACHE_FILE_MASK banner.html + CACHE_FILE_AS_DYNAMIC_MASK *.html URI_PROTECTED_MASK /get_config USP_AUTOMATIC_ALIASING servlet/wi_auth2