1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00
This commit is contained in:
stefanocasazza 2016-05-23 14:58:24 +02:00
parent 1880bffa24
commit 08e7f90afd
36 changed files with 3520 additions and 3410 deletions

30
configure vendored
View File

@ -1757,14 +1757,14 @@ Optional Features:
--enable-captive-portal enable server captive portal mode [default=no]
--enable-thread-approach enable server thread approach support [default=no]
--enable-HIS enable HTTP Inotify Support [default=no]
--enable-log enable client and server log support [default=no]
--enable-log enable client and server log support [default=yes]
--enable-GSDS enable GDB Stack Dump Support [default=no]
--enable-HCRS enable Cache Request Support [default=no]
--enable-HPRS enable Homogeneous Pipeline Request Support [default=yes]
--enable-HPRS enable Homogeneous Pipeline Request Support [default=no]
--enable-http2 enable HTTP/2 support [default=no]
--enable-classic enable server classic model support [default=no]
--enable-throttling enable server bandwidth throttling support [default=no]
--enable-alias enable alias URI support [default=no]
--enable-alias enable alias URI support [default=yes]
--enable-welcome enable welcome message support [default=no]
--enable-ACL enable ACL filtering support [default=no]
--enable-RFC1918 enable RFC1918 filtering support [default=no]
@ -24539,10 +24539,10 @@ if test "${enable_log+set}" = set; then :
fi
if test -z "$enable_log"; then
if test "$enable_debug" = "yes"; then
enable_log="yes"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_log="no"
else
enable_log="yes"
fi
fi
if test "$enable_log" != "yes"; then
@ -24583,10 +24583,10 @@ if test "${enable_HCRS+set}" = set; then :
fi
if test -z "$enable_HCRS"; then
if test "$enable_debug" = "yes"; then
enable_HCRS="no"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_HCRS="yes"
else
enable_HCRS="no"
fi
fi
if test "$enable_HCRS" != "yes"; then
@ -24605,10 +24605,10 @@ if test "${enable_HPRS+set}" = set; then :
fi
if test -z "$enable_HPRS"; then
if test "$enable_debug" = "yes"; then
enable_HPRS="no"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_HPRS="yes"
else
enable_HPRS="no"
fi
fi
if test "$enable_HPRS" != "yes"; then
@ -24681,10 +24681,10 @@ if test "${enable_alias+set}" = set; then :
fi
if test -z "$enable_alias"; then
if test "$enable_debug" = "yes"; then
enable_alias="yes"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_alias="no"
else
enable_alias="yes"
fi
fi
if test "$enable_alias" = "yes"; then

View File

@ -91,12 +91,14 @@ public:
is >> vec;
sz = vec.size();
# endif
last_access = u_now->tv_sec;
}
// STREAMS
#ifdef U_STDCPP_ENABLE
friend istream& operator>>(istream& is, IRDataSession& d) { d.fromStream(is); return is; }
friend ostream& operator<<(ostream& os, IRDataSession& d) { d.toStream(os); return os; }
#endif

View File

@ -46,7 +46,7 @@ public:
// COSTRUTTORE
UClientXAdES(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
explicit UClientXAdES(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
virtual ~UClientXAdES() {}
// OBJECT FOR METHOD REQUEST

View File

@ -425,7 +425,6 @@ public:
UString completeCertificateRef(U_CAPACITY), completeCertificateRefs(U_CAPACITY);
uint32_t i, n;
long CASerialNumber;
UVector<UString> vec_CACertificateValue;
UString item(U_CAPACITY), CACertificateValue(U_CAPACITY), CAIssuerName, CACertificate, DigestValue(U_CAPACITY);
@ -437,7 +436,6 @@ public:
CAIssuerName = ca->getIssuerForLDAP();
CACertificate = ca->getEncoded("DER");
CASerialNumber = ca->getSerialNumber();
DigestValue.setEmpty();
@ -447,7 +445,7 @@ public:
U_STRING_TO_TRACE(digest_algorithm),
U_STRING_TO_TRACE(DigestValue),
U_STRING_TO_TRACE(CAIssuerName),
CASerialNumber);
ca->getSerialNumber());
(void) completeCertificateRef.append(item);

View File

@ -479,7 +479,7 @@ public:
// COSTRUTTORI
UTranformInputURI(const char* uri);
explicit UTranformInputURI(const char* uri);
virtual ~UTranformInputURI()
{

View File

@ -19,7 +19,7 @@ public:
// COSTRUTTORE
UClientCSP(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
explicit UClientCSP(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
virtual ~UClientCSP() {}
// OBJECT FOR METHOD REQUEST

View File

@ -19,7 +19,7 @@ public:
// COSTRUTTORE
UClientCSP(UFileConfig* cfg) : URPCClient<T>(cfg) {}
explicit UClientCSP(UFileConfig* cfg) : URPCClient<T>(cfg) {}
virtual ~UClientCSP() {}
// OBJECT FOR METHOD REQUEST

View File

@ -84,7 +84,7 @@ int DocumentClassifier::verifyCallback(int ok, X509_STORE_CTX* ctx) // callback
if (flag_ricorsione || verify_result == false) U_RETURN(ok);
if (ok == false) U_RETURN(1);
if (ok == 0) U_RETURN(1);
flag_ricorsione = true;

View File

@ -36,7 +36,7 @@ public:
UTree<Element*>* node_to_delete;
UString description, content_type, filename;
Element(Type t) : type(t)
explicit Element(Type t) : type(t)
{
U_TRACE_REGISTER_OBJECT(5, Element, "%d", t)
@ -117,8 +117,8 @@ public:
// COSTRUTTORE
DocumentClassifier(const char* filename);
~DocumentClassifier();
explicit DocumentClassifier(const char* filename);
~DocumentClassifier();
// SERVICES

View File

@ -229,7 +229,7 @@ public:
U_APPEND_LITERAL(" ");
(void) sprintf(p, " ETA %02d:%02d", eta_min, eta_sec);
(void) sprintf(p, " ETA %02u:%02u", eta_min, eta_sec);
}
else
{
@ -237,7 +237,7 @@ public:
if (eta_hrs < 10) *p++ = ' ';
(void) sprintf(p, " ETA %d:%02d:%02d", eta_hrs, eta_min, eta_sec);
(void) sprintf(p, " ETA %u:%02u:%02u", eta_hrs, eta_min, eta_sec);
}
p += u__strlen(p, __PRETTY_FUNCTION__);
@ -616,8 +616,8 @@ public:
rcvsock.iSockDesc = rcvsock_fd;
sndsock.iSockDesc = sndsock_fd;
int code, lag;
unsigned must_continue = numhosts;
int code, startcount, hostcount, lag;
int seq = 0, endcount = 0, min_lag = 100;
if (rcvsock.setTimeoutRCV(50) == false) U_RETURN(false); /* transmit time must be <= min_lag / 2 */
@ -651,7 +651,8 @@ public:
*/
bool sent_one = false;
startcount = hostcount = endcount;
int startcount = endcount;
int hostcount = endcount;
must_continue = 0;
do {

View File

@ -118,21 +118,20 @@ HttpCookie::HttpCookie(const char* name_, unsigned name_len, const char* value_,
(void) cookie_split(tvec, buffer, "=");
const char* s;
const char* p;
const char* pc;
unsigned i, num;
const char* delim;
unsigned i, num, size;
for (i = 0; i < tvec.size(); i++)
{
s = tvec[i].data();
const char* s = tvec[i].data();
/* modifica stefano */
size = tvec[i].size();
unsigned size = tvec[i].size();
pc = (const char*) memrchr(s, ',', size);
p = (const char*) memrchr(s, ';', size);
const char* p = (const char*) memrchr(s, ';', size);
if (pc > p)
{

View File

@ -19,7 +19,7 @@ public:
// COSTRUTTORE
UClientLCSP(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
explicit UClientLCSP(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
virtual ~UClientLCSP() {}
// OBJECT FOR METHOD REQUEST

View File

@ -19,7 +19,7 @@ public:
// COSTRUTTORE
UClientLCSP(UFileConfig* cfg) : URPCClient<T>(cfg) {}
explicit UClientLCSP(UFileConfig* cfg) : URPCClient<T>(cfg) {}
virtual ~UClientLCSP() {}
// OBJECT FOR METHOD REQUEST

View File

@ -23,7 +23,7 @@ public:
// COSTRUTTORE
UClientRSIGN(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
explicit UClientRSIGN(UFileConfig* cfg) : USOAPClient<T>(cfg) {}
virtual ~UClientRSIGN() {}
// OBJECT FOR METHOD REQUEST

View File

@ -21,7 +21,7 @@ public:
// COSTRUTTORE
UClientRSIGN(UFileConfig* cfg) : URPCClient<T>(cfg) {}
explicit UClientRSIGN(UFileConfig* cfg) : URPCClient<T>(cfg) {}
virtual ~UClientRSIGN() {}
// OBJECT FOR METHOD REQUEST

View File

@ -4334,11 +4334,11 @@ static void GET_get_config()
U_INTERNAL_ASSERT(label)
U_INTERNAL_ASSERT(netmask)
uint32_t lbl = label.strtol();
_body = UStringExt::substitute(_body, U_CONSTANT_TO_PARAM("172.<CCC>.<DDD>.0/24"), U_STRING_TO_PARAM(netmask));
buffer.snprintf("LOCAL_NETWORK_LABEL %06x", lbl);
uint32_t lbl = label.strtol();
buffer.snprintf("LOCAL_NETWORK_LABEL %u", lbl);
_body = UStringExt::substitute(_body, U_CONSTANT_TO_PARAM("LOCAL_NETWORK_LABEL ap"), U_STRING_TO_PARAM(buffer));

View File

@ -319,7 +319,7 @@ enum HttpRequestType {
/**
* The hostname of your server from header's request.
* The difference between U_HTTP_HOST_.. and U_HTTP_VHOST_.. is that
* U_HTTP_HOST_.. can include the «:PORT» text, and U_HTTP_VHOST_.. only the name
* U_HTTP_HOST_.. can include the :PORT text, and U_HTTP_VHOST_.. only the name
*/
#define U_HTTP_HOST_TO_PARAM u_clientimage_info.http_info.host, U_http_host_len

View File

@ -14,7 +14,7 @@
#ifndef ULIB_INTERNAL_COMMON_H
#define ULIB_INTERNAL_COMMON_H 1
// Manage file to include
// Manage which file headers to include
#include <ulib/base/base.h>

View File

@ -25,6 +25,7 @@
#define USP_PRINTF_ADD(fmt,args...) UClientImage_Base::wbuffer->snprintf_add(fmt , ##args)
#define USP_JSON_PUTS(json) UValue::stringify(*UClientImage_Base::wbuffer, (json))
#define USP_JSON_REQUEST_PARSE(obj) JSON_parse(*UClientImage_Base::body, (obj))
#define USP_JSON_stringify(json,class_name,obj) ((json).toJSON(UJsonTypeHandler<class_name>(obj)), USP_JSON_PUTS(json))
#define USP_XML_PUTS(string) \

View File

@ -156,12 +156,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
AC_MSG_CHECKING(if you want to enable client and server log support)
AC_ARG_ENABLE(log,
[ --enable-log enable client and server log support [[default=no]]])
[ --enable-log enable client and server log support [[default=yes]]])
if test -z "$enable_log"; then
if test "$enable_debug" = "yes"; then
enable_log="yes"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_log="no"
else
enable_log="yes"
fi
fi
if test "$enable_log" != "yes"; then
@ -188,10 +188,10 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
AC_ARG_ENABLE(HCRS,
[ --enable-HCRS enable Cache Request Support [[default=no]]])
if test -z "$enable_HCRS"; then
if test "$enable_debug" = "yes"; then
enable_HCRS="no"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_HCRS="yes"
else
enable_HCRS="no"
fi
fi
if test "$enable_HCRS" != "yes"; then
@ -201,12 +201,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
AC_MSG_CHECKING(if you want to enable homogeneous pipeline request support)
AC_ARG_ENABLE(HPRS,
[ --enable-HPRS enable Homogeneous Pipeline Request Support [[default=yes]]])
[ --enable-HPRS enable Homogeneous Pipeline Request Support [[default=no]]])
if test -z "$enable_HPRS"; then
if test "$enable_debug" = "yes"; then
enable_HPRS="no"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_HPRS="yes"
else
enable_HPRS="no"
fi
fi
if test "$enable_HPRS" != "yes"; then
@ -249,12 +249,12 @@ AC_DEFUN([AC_COMPILATION_OPTIONS],[
AC_MSG_CHECKING(if you want to enable alias URI support)
AC_ARG_ENABLE(alias,
[ --enable-alias enable alias URI support [[default=no]]])
[ --enable-alias enable alias URI support [[default=yes]]])
if test -z "$enable_alias"; then
if test "$enable_debug" = "yes"; then
enable_alias="yes"
else
if test "$USP_FLAGS" = "-DAS_cpoll_cppsp_DO"; then
enable_alias="no"
else
enable_alias="yes"
fi
fi
if test "$enable_alias" = "yes"; then

View File

@ -1155,7 +1155,7 @@ void u_get_memusage(unsigned long* vsz, unsigned long* rss)
* -----------------------------------------------------------------------------------------------------------------------------
*/
(void) fscanf(fp, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu %ld", vsz, rss);
(void) fscanf(fp, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu %lu", vsz, rss);
(void) fclose(fp);
@ -1624,7 +1624,10 @@ __pure bool u_dosmatch(const char* restrict s, uint32_t n1, const char* restrict
c1 = u__tolower(*s);
if (c2 != c1 &&
c2 != '?') return (flags & FNM_INVERT ? true : false);
c2 != '?')
{
return ((flags & FNM_INVERT) != 0);
}
++s;
++mask;
@ -1642,14 +1645,14 @@ __pure bool u_dosmatch(const char* restrict s, uint32_t n1, const char* restrict
result = (mask >= end_mask);
return (flags & FNM_INVERT ? (result == false) : result);
return ((flags & FNM_INVERT) != 0 ? (result == false) : result);
}
c2 = (mask ? u__tolower(*mask) : 0);
if (c2 == '*')
{
if (++mask >= end_mask) return (flags & FNM_INVERT ? false : true);
if (++mask >= end_mask) return ((flags & FNM_INVERT) == 0);
cp = s+1;
mp = mask;
@ -1687,7 +1690,7 @@ __pure bool u_dosmatch(const char* restrict s, uint32_t n1, const char* restrict
if (c2 != c1 &&
c2 != '?')
{
return (flags & FNM_INVERT ? true : false);
return ((flags & FNM_INVERT) != 0);
}
++s;
@ -1704,14 +1707,14 @@ __pure bool u_dosmatch(const char* restrict s, uint32_t n1, const char* restrict
result = (mask >= end_mask);
return (flags & FNM_INVERT ? (result == false) : result);
return ((flags & FNM_INVERT) != 0 ? (result == false) : result);
}
c2 = *mask;
if (c2 == '*')
{
if (++mask >= end_mask) return (flags & FNM_INVERT ? false : true);
if (++mask >= end_mask) return ((flags & FNM_INVERT) == 0);
cp = s + 1;
mp = mask;
@ -1761,23 +1764,23 @@ __pure bool u_dosmatch_ext(const char* restrict s, uint32_t n1, const char* rest
--n2;
}
if (n2 == 1) return (flags & FNM_INVERT ? false : true); /* match */
if (n2 == 1) return ((flags & FNM_INVERT) == 0); /* match */
while (n1)
{
if (u_dosmatch_ext(s, n1, mask+1, n2-1, flags & ~FNM_INVERT)) return (flags & FNM_INVERT ? false : true); /* match */
if (u_dosmatch_ext(s, n1, mask+1, n2-1, flags & ~FNM_INVERT)) return ((flags & FNM_INVERT) == 0); /* match */
++s;
--n1;
}
return (flags & FNM_INVERT ? true : false); /* no match */
return ((flags & FNM_INVERT) != 0); /* no match */
}
break;
case '?':
{
if (n1 == 0) return (flags & FNM_INVERT ? true : false); /* no match */
if (n1 == 0) return ((flags & FNM_INVERT) != 0); /* no match */
++s;
--n1;
@ -1872,7 +1875,7 @@ __pure bool u_dosmatch_ext(const char* restrict s, uint32_t n1, const char* rest
U_INTERNAL_PRINT("match = %d bnot = %d", match, bnot)
if (match == false || bnot) return (flags & FNM_INVERT ? true : false); /* no match */
if (match == false || bnot) return ((flags & FNM_INVERT) != 0); /* no match */
U_INTERNAL_PRINT("s[0] = %c n1 = %u mask[0] = %c n2 = %u", s[0], n1, mask[0], n2)
@ -1898,11 +1901,11 @@ __pure bool u_dosmatch_ext(const char* restrict s, uint32_t n1, const char* rest
if ((flags & FNM_IGNORECASE) == 0)
{
if (mask[0] != s[0]) return (flags & FNM_INVERT ? true : false); /* no match */
if (mask[0] != s[0]) return ((flags & FNM_INVERT) != 0); /* no match */
}
else
{
if (u__tolower((unsigned char)mask[0]) != u__tolower((unsigned char)s[0])) return (flags & FNM_INVERT ? true : false); /* no match */
if (u__tolower((unsigned char)mask[0]) != u__tolower((unsigned char)s[0])) return ((flags & FNM_INVERT) != 0); /* no match */
}
++s;
@ -1931,10 +1934,10 @@ __pure bool u_dosmatch_ext(const char* restrict s, uint32_t n1, const char* rest
if (n2 == 0 &&
n1 == 0)
{
return (flags & FNM_INVERT ? false : true);
return ((flags & FNM_INVERT) == 0);
}
return (flags & FNM_INVERT ? true : false);
return ((flags & FNM_INVERT) != 0);
}
/**
@ -1959,7 +1962,7 @@ bool u_match_with_OR(const char* restrict s, uint32_t n1, const char* restrict m
if (p_or == 0) return u_pfn_match(s, n1, mask, n2, flags);
if (u_pfn_match(s, n1, mask, (p_or - mask), flags & ~FNM_INVERT)) return (flags & FNM_INVERT ? false : true);
if (u_pfn_match(s, n1, mask, (p_or - mask), (flags & ~FNM_INVERT))) return ((flags & FNM_INVERT) == 0);
mask = p_or + 1;
n2 = end - mask;
@ -2859,7 +2862,7 @@ bool u_fnmatch(const char* restrict string, uint32_t n1, const char* restrict pa
result = kfnmatch(pattern, string, flags, 0);
return (flags & FNM_INVERT ? (result != 0) : (result == 0));
return ((flags & FNM_INVERT) != 0 ? (result != 0) : (result == 0));
}
/* buffer type identification - Assumed an ISO-1 character set */

View File

@ -110,7 +110,7 @@ void UError::stackDump()
// does not append a null byte to buf. It will truncate the contents (to a length of bufsiz characters),
// in case the buffer is too small to hold all of the contents
char name_buf[1024] = { 0 };
char name_buf[1024];
#if defined(U_GDB_STACK_DUMP_ENABLE) && !defined(_MSWINDOWS_)
int n = readlink("/proc/self/exe", name_buf, sizeof(name_buf) - 1);
@ -159,6 +159,8 @@ void UError::stackDump()
return;
}
}
#else
name_buf[0] = 0;
#endif
#ifdef HAVE_EXECINFO_H

View File

@ -22,9 +22,11 @@ const char* UMemoryError::getErrorType(const void* pobj) const
// (ABW) Array Beyond Write | (FMR) Free Memory Read
#ifndef U_STDCPP_ENABLE
(void) sprintf(pbuffer, "[pobj = %p _this = %p - %s]", pobj, _this, (_this ? "ABW" : "FMR"));
#else
uint32_t n = sprintf(pbuffer, "[pobj = %p _this = %p - %s]", pobj, _this, (_this ? "ABW" : "FMR"));
#ifdef U_STDCPP_ENABLE
if (UObjectDB::fd > 0)
{
uint32_t l = UObjectDB::dumpObject(pbuffer+n+1, U_MAX_SIZE_PREALLOCATE-n-1, pobj);

View File

@ -475,9 +475,6 @@ char* UFile::mmap_anon_huge(uint32_t* plength, int flags)
#ifdef U_LINUX
if (nr_hugepages)
{
char* ptr;
uint32_t length;
U_INTERNAL_DUMP("nr_hugepages = %ld rlimit_memfree = %u", nr_hugepages, rlimit_memfree)
U_INTERNAL_ASSERT_EQUALS(rlimit_memfree, U_2M)
@ -485,13 +482,13 @@ char* UFile::mmap_anon_huge(uint32_t* plength, int flags)
# ifdef MAP_HUGE_1GB /* (since Linux 3.8) */
if (*plength >= U_1G)
{
length = (*plength + U_1G_MASK) & ~U_1G_MASK; // NB: munmap() length of MAP_HUGETLB memory must be hugepage aligned...
uint32_t length = (*plength + U_1G_MASK) & ~U_1G_MASK; // NB: munmap() length of MAP_HUGETLB memory must be hugepage aligned...
U_INTERNAL_ASSERT_EQUALS(length & U_1G_MASK, 0)
U_DEBUG("We are going to allocate (%u GB - %u bytes) MAP_HUGE_1GB - nfree = %u flags = %B", length / U_1G, length, nfree, flags | U_MAP_ANON_HUGE | MAP_HUGE_1GB)
ptr = (char*) U_SYSCALL(mmap, "%d,%u,%d,%d,%d,%u", U_MAP_ANON_HUGE_ADDR, length, PROT_READ | PROT_WRITE, flags | U_MAP_ANON_HUGE | MAP_HUGE_1GB, -1, 0);
char* ptr = (char*) U_SYSCALL(mmap, "%d,%u,%d,%d,%d,%u", U_MAP_ANON_HUGE_ADDR, length, PROT_READ | PROT_WRITE, flags | U_MAP_ANON_HUGE | MAP_HUGE_1GB, -1, 0);
if (ptr != (char*)MAP_FAILED)
{
@ -502,13 +499,13 @@ char* UFile::mmap_anon_huge(uint32_t* plength, int flags)
}
# endif
# ifdef MAP_HUGE_2MB /* (since Linux 3.8) */
length = (*plength + U_2M_MASK) & ~U_2M_MASK; // NB: munmap() length of MAP_HUGETLB memory must be hugepage aligned...
uint32_t length = (*plength + U_2M_MASK) & ~U_2M_MASK; // NB: munmap() length of MAP_HUGETLB memory must be hugepage aligned...
U_INTERNAL_ASSERT_EQUALS(length & U_2M_MASK, 0)
U_DEBUG("We are going to allocate (%u MB - %u bytes) MAP_HUGE_2MB - nfree = %u flags = %B", length / (1024U*1024U), length, nfree, flags | U_MAP_ANON_HUGE | MAP_HUGE_2MB)
ptr = (char*) U_SYSCALL(mmap, "%d,%u,%d,%d,%d,%u", U_MAP_ANON_HUGE_ADDR, length, PROT_READ | PROT_WRITE, flags | U_MAP_ANON_HUGE | MAP_HUGE_2MB, -1, 0);
char* ptr = (char*) U_SYSCALL(mmap, "%d,%u,%d,%d,%d,%u", U_MAP_ANON_HUGE_ADDR, length, PROT_READ | PROT_WRITE, flags | U_MAP_ANON_HUGE | MAP_HUGE_2MB, -1, 0);
if (ptr != (char*)MAP_FAILED)
{

View File

@ -369,7 +369,6 @@ bool UClient_Base::setUrl(const char* str, uint32_t len)
char* p;
char* ptr;
char* dest;
uint32_t sz;
char buf[U_PATH_MAX];
const char* src = uri.data();
@ -383,7 +382,7 @@ bool UClient_Base::setUrl(const char* str, uint32_t len)
if (p == 0) break;
sz = p - src + 1;
uint32_t sz = p - src + 1;
U_INTERNAL_DUMP("segment = %.*S", sz, src)

View File

@ -451,7 +451,6 @@ void UNoCatPlugIn::getTraffic()
#ifdef HAVE_LINUX_NETFILTER_IPV4_IPT_ACCOUNT_H
UString ip(17U);
uint32_t traffic;
const char* table;
UModNoCatPeer* _peer;
const unsigned char* bytep;
struct ipt_acc_handle_ip* entry;
@ -460,7 +459,7 @@ void UNoCatPlugIn::getTraffic()
{
U_INTERNAL_ASSERT((*vLocalNetworkMask)[i]->spec.isNullTerminated())
table = (*vLocalNetworkMask)[i]->spec.data();
const char* table = (*vLocalNetworkMask)[i]->spec.data();
if (ipt->readEntries(table, true))
{

View File

@ -254,7 +254,7 @@ static void usp_end_businesses()
Content-Type: application/json
-->
<!--#code
if (JSON_parse(*UClientImage_Base::body, *prequest))
if (USP_JSON_REQUEST_PARSE(*prequest))
{
uint32_t i, n;

View File

@ -1,3 +1,97 @@
<!--#declaration
#include <ulib/json/value.h>
/**
* {
* "user": "doctoravatar@penzance.com",
* "forecast": 7,
* "t": "vlIj",
* "zip": 94089
* }
*/
class Request {
public:
// Check for memory error
U_MEMORY_TEST
// Allocator e Deallocator
U_MEMORY_ALLOCATOR
U_MEMORY_DEALLOCATOR
UString user, t;
uint32_t forecast, zip;
Request()
{
U_TRACE_REGISTER_OBJECT(5, Request, "")
}
Request(const Request& r) : user(r.user), t(r.t)
{
U_TRACE_REGISTER_OBJECT(5, Request, "%p", &r)
U_MEMORY_TEST_COPY(r)
forecast = r.forecast;
zip = r.zip;
}
~Request()
{
U_TRACE_UNREGISTER_OBJECT(5, Request)
}
#ifdef DEBUG
const char* dump(bool breset) const
{
*UObjectIO::os << "zip " << zip << '\n'
<< "forecast " << forecast << '\n'
<< "t (UString " << (void*)&t << ")\n"
<< "user (UString " << (void*)&user << ')';
if (breset)
{
UObjectIO::output();
return UObjectIO::buffer_output;
}
return 0;
}
#endif
private:
Request& operator=(const Request&) { return *this; }
};
// JSON TEMPLATE SPECIALIZATIONS
template <> class U_EXPORT UJsonTypeHandler<Request> : public UJsonTypeHandler_Base {
public:
explicit UJsonTypeHandler(Request& val) : UJsonTypeHandler_Base(&val) {}
void toJSON(UValue& json)
{
U_TRACE(0, "UJsonTypeHandler<Request>::toJSON(%p)", &json)
json.toJSON(U_JSON_TYPE_HANDLER(Request, user, UString));
json.toJSON(U_JSON_TYPE_HANDLER(Request, t, UString));
json.toJSON(U_JSON_TYPE_HANDLER(Request, forecast, uint32_t));
json.toJSON(U_JSON_TYPE_HANDLER(Request, zip, uint32_t));
}
void fromJSON(UValue& json)
{
U_TRACE(0, "UJsonTypeHandler<Request>::fromJSON(%p)", &json)
json.fromJSON(U_JSON_TYPE_HANDLER(Request, user, UString));
json.fromJSON(U_JSON_TYPE_HANDLER(Request, t, UString));
json.fromJSON(U_JSON_TYPE_HANDLER(Request, forecast, uint32_t));
json.fromJSON(U_JSON_TYPE_HANDLER(Request, zip, uint32_t));
}
};
-->
<!--#header
Content-Type: application/jsonrequest
-->
@ -7,8 +101,9 @@ U_INTERNAL_DUMP("U_HTTP_CTYPE = %.*S", U_HTTP_CTYPE_TO_TRACE)
if (U_HTTP_CTYPE_STREQ("application/jsonrequest"))
{
UValue json;
Request request;
if (json.parse(*UClientImage_Base::body)) USP_PUTS_STRING(json.output());
else USP_PUTS_CONSTANT("{}");
if (USP_JSON_REQUEST_PARSE(request)) USP_JSON_stringify(json, Request, request);
else USP_PUTS_CONSTANT("{}");
}
-->

View File

@ -3095,12 +3095,17 @@ retry: pid = UProcess::waitpid(-1, &status, WNOHANG); // NB: to avoid too much
if (pid > 0)
{
char buffer[128];
--UNotifier::num_connection;
U_SRV_LOG("Child (pid %d) exited with value %d (%s), down to %u children",
pid, status, UProcess::exitInfo(buffer, status), UNotifier::num_connection - UNotifier::min_connection);
# ifndef U_LOG_DISABLE
if (isLog())
{
char buffer[128];
ULog::log("%sChild (pid %d) exited with value %d (%s), down to %u children",
UServer_Base::mod_name[0], pid, status, UProcess::exitInfo(buffer, status), UNotifier::num_connection - UNotifier::min_connection);
}
# endif
goto retry;
}
@ -3586,25 +3591,30 @@ void UServer_Base::run()
u_bind2cpu(&cpuset, rkids % u_num_cpu); // Pin the process to a particular cpu...
# if !defined(U_LOG_DISABLE) || defined(HAVE_SCHED_GETCPU)
char buffer[64];
uint32_t sz = 0;
int cpu = U_SYSCALL_NO_PARAM(sched_getcpu);
# endif
# ifdef SO_INCOMING_CPU
USocket::incoming_cpu = rkids % u_num_cpu;
# endif
# ifdef HAVE_SCHED_GETCPU
if (USocket::incoming_cpu != cpu &&
USocket::incoming_cpu != -1)
# ifndef U_LOG_DISABLE
if (isLog())
{
sz = u__snprintf(buffer, sizeof(buffer), " (EXPECTED CPU %d)", USocket::incoming_cpu);
}
# endif
uint32_t sz;
char buffer[64];
int cpu = U_SYSCALL_NO_PARAM(sched_getcpu);
U_SRV_LOG("New child started, affinity mask: %x, cpu: %d%.*s", CPUSET_BITS(&cpuset)[0], cpu, sz, buffer);
# ifdef HAVE_SCHED_GETCPU
if (USocket::incoming_cpu != cpu &&
USocket::incoming_cpu != -1)
{
sz = u__snprintf(buffer, sizeof(buffer), " (EXPECTED CPU %d)", USocket::incoming_cpu);
}
else
# endif
sz = 0;
ULog::log("%sNew child started, affinity mask: %x, cpu: %d%.*s", mod_name[0], CPUSET_BITS(&cpuset)[0], cpu, sz, buffer);
}
# endif
}
# ifdef HAVE_LIBNUMA

View File

@ -100,7 +100,7 @@ bool UNotifier::bepollet;
int UNotifier::ctl_cmd_cnt;
struct epoll_ctl_cmd UNotifier::ctl_cmd[U_EPOLL_CTL_CMD_SIZE];
void UNotifier::batch((UEventFd* item)
void UNotifier::batch(UEventFd* item)
{
U_TRACE(0, "UNotifier::batch(%p)", item)

View File

@ -267,7 +267,6 @@ long USSLSocket::getOptions(const UVector<UString>& vec)
uint32_t j;
UString key;
const char* ptr;
long options = SSL_OP_NO_SSLv2 |
# ifdef SSL_OP_NO_COMPRESSION
@ -277,9 +276,8 @@ long USSLSocket::getOptions(const UVector<UString>& vec)
for (uint32_t i = 0, n = vec.size(); i < n; ++i)
{
uint32_t len = key.size();
ptr = key.data();
uint32_t len = key.size();
const char* ptr = key.data();
char positive = 1;

View File

@ -417,14 +417,14 @@ void UThread::setCancel(int mode)
{
U_TRACE(1, "UThread::setCancel(%d)", mode)
int old;
switch (mode)
{
case cancelDeferred:
case cancelImmediate:
{
# ifdef HAVE_PTHREAD_CANCEL
int old;
(void) U_SYSCALL(pthread_setcancelstate, "%d,%p", PTHREAD_CANCEL_ENABLE, &old);
(void) U_SYSCALL(pthread_setcanceltype, "%d,%p", (mode == cancelDeferred ? PTHREAD_CANCEL_DEFERRED
: PTHREAD_CANCEL_ASYNCHRONOUS), &old);
@ -436,6 +436,8 @@ void UThread::setCancel(int mode)
case cancelDisabled:
{
# ifdef HAVE_PTHREAD_CANCEL
int old;
(void) U_SYSCALL(pthread_setcancelstate, "%d,%p", PTHREAD_CANCEL_DISABLE, &old);
# endif
}

View File

@ -2336,14 +2336,14 @@ void UHTTP2::handlerResponse()
if (sz2)
{
uint32_t pos;
UString row, key;
UVector<UString> vext(20);
for (uint32_t i = 0, n = vext.split(*UHTTP::ext, U_CRLF); i < n; ++i)
{
row = vext[i];
pos = row.find_first_of(':');
uint32_t pos = row.find_first_of(':');
key = row.substr(0U, pos);
dst = hpackEncodeHeader(dst, dyntbl, key, row.substr(pos+2), bfirst ? 0 : &vdyntbl);

View File

@ -1408,7 +1408,9 @@ UString USocketExt::getGatewayAddress(const char* network, uint32_t network_len)
do {
// Receive response from the kernel
if ((readLen = U_SYSCALL(recv, "%d,%p,%u,%d", sock, CAST(bufPtr), 4096 - msgLen, 0)) < 0) break;
readLen = U_SYSCALL(recv, "%d,%p,%u,%d", sock, CAST(bufPtr), 4096 - msgLen, 0);
if (readLen < 0) break;
nlHdr.p = bufPtr;
@ -1443,14 +1445,13 @@ UString USocketExt::getGatewayAddress(const char* network, uint32_t network_len)
int rtLen;
char* dst;
char dstMask[32];
struct rtmsg* rtMsg;
struct rtattr* rtAttr;
char ifName[IF_NAMESIZE];
struct in_addr dstAddr, srcAddr, gateWay;
for (; NLMSG_OK(nlMsg.h,msgLen); nlMsg.h = NLMSG_NEXT(nlMsg.h,msgLen))
{
rtMsg = (struct rtmsg*) NLMSG_DATA(nlMsg.h);
struct rtmsg* rtMsg = (struct rtmsg*) NLMSG_DATA(nlMsg.h);
U_INTERNAL_DUMP("rtMsg = %p msgLen = %u rtm_family = %u rtm_table = %u", rtMsg, msgLen, rtMsg->rtm_family, rtMsg->rtm_table)

View File

@ -8330,9 +8330,9 @@ bool UHTTP::getCGIEnvironment(UString& environment, int mask)
if ((mask & U_RAKE) == 0)
{
# ifdef U_ALIAS
bool brequest = false;
# ifdef U_ALIAS
if (*UClientImage_Base::request_uri)
{
// The interpreted pathname of the original requested document (relative to the document root)
@ -8348,9 +8348,10 @@ bool UHTTP::getCGIEnvironment(UString& environment, int mask)
buffer.snprintf_add("REQUEST_URI=%.*s?%.*s\n", sz, ptr, U_HTTP_QUERY_TO_TRACE);
}
}
# endif
if (brequest == false) buffer.snprintf_add("REQUEST_URI=%.*s\n", sz, ptr);
if (brequest == false)
# endif
buffer.snprintf_add("REQUEST_URI=%.*s\n", sz, ptr);
}
if ((mask & U_PHP) != 0)

File diff suppressed because it is too large Load Diff