Skip to content

Commit

Permalink
some fix plus prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocasazza committed Apr 21, 2016
1 parent 3a30c77 commit 8900560
Show file tree
Hide file tree
Showing 79 changed files with 1,672 additions and 891 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It include as application example a powerful search engine with relative [web in

The current version offers the following features :

* HTTP/1.0 and 1.1 protocols supported and initial implementations of HTTP/2.
* HTTP/1.0 and 1.1 protocols supported and experimental implementations of HTTP/2.
* Persistent connections for HTTP/1.1 and Keep-Alive support for HTTP/1.0.
* Browser cache management (headers: If-Modified-Since/Last-modified).
* Chunk-encoding transfers support.
Expand Down
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This file is licensed to you under the license specified in the included file `COPYING'. Look there for further details.
This file is licensed to you under the license specified in the included file `LICENSE'. Look there for further details.

SPECIFIC TASKS:

Expand Down
14 changes: 8 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -33787,12 +33787,14 @@ $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi


awk -f configure_log.awk config.log > include/ulib/internal/config1.h
awk -f configure_h.awk include/ulib/internal/config.h > include/ulib/internal/config2.h
cd include/ulib/internal
cat config2.h config1.h >> config.h
rm -f config2.h config1.h
cd ../../..
if test -n "$AWK"; then
$AWK -f configure_log.awk config.log > include/ulib/internal/config1.h
$AWK -f configure_h.awk include/ulib/internal/config.h > include/ulib/internal/config2.h
cd include/ulib/internal
cat config2.h config1.h >> config.h
rm -f config2.h config1.h
cd ../../..
fi

# Verify the integrity of the current configuration

Expand Down
14 changes: 8 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2605,12 +2605,14 @@ AC_CONFIG_FILES([

AC_OUTPUT

awk -f configure_log.awk config.log > include/ulib/internal/config1.h
awk -f configure_h.awk include/ulib/internal/config.h > include/ulib/internal/config2.h
cd include/ulib/internal
cat config2.h config1.h >> config.h
rm -f config2.h config1.h
cd ../../..
if test -n "$AWK"; then
$AWK -f configure_log.awk config.log > include/ulib/internal/config1.h
$AWK -f configure_h.awk include/ulib/internal/config.h > include/ulib/internal/config2.h
cd include/ulib/internal
cat config2.h config1.h >> config.h
rm -f config2.h config1.h
cd ../../..
fi

# Verify the integrity of the current configuration

Expand Down
4 changes: 2 additions & 2 deletions examples/WiAuth/rdbgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Application : public UApplication {
{
UString key(argv[optind]), value = x[key];

(void) UFile::writeToTmp(U_STRING_TO_PARAM(value), false, U_FILE_OUTPUT, 0);
(void) UFile::writeToTmp(U_STRING_TO_PARAM(value), O_RDWR | O_TRUNC, U_FILE_OUTPUT, 0);
}
break;

Expand Down Expand Up @@ -119,7 +119,7 @@ class Application : public UApplication {
UString value = x.print();

if (value.empty()) (void) UFile::_unlink(U_DIR_OUTPUT U_FILE_OUTPUT);
else (void) UFile::writeToTmp(U_STRING_TO_PARAM(value), false, U_FILE_OUTPUT, 0);
else (void) UFile::writeToTmp(U_STRING_TO_PARAM(value), O_RDWR | O_TRUNC, U_FILE_OUTPUT, 0);
}
break;

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_client_server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class UClientImageExample : public UClientImage<UTCPSocket> {

if (U_ClientImage_state == U_PLUGIN_HANDLER_GO_ON)
{
# ifdef U_LOG_ENABLE
# ifndef U_LOG_DISABLE
if (UClientImage_Base::logbuf)
{
*UClientImage_Base::request = *UClientImage_Base::rbuffer;
Expand Down
6 changes: 3 additions & 3 deletions include/ulib/base/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
# define U_INTERNAL_ASSERT_RANGE_MSG(a,x,b,info) \
{ U_ASSERT_MACRO((x)>=(a)&&(x)<=(b),"VALUE OUT OF RANGE",info) }

# define U_DEBUG(fmt,args...) u__printf(STDERR_FILENO, "%W%N%W: %WDEBUG: %9D (pid %P) " fmt "%W", BRIGHTCYAN, RESET, YELLOW, ##args, RESET)
# define U_DEBUG(fmt,args...) u__printf(STDERR_FILENO, "%W%N%W: %WDEBUG: %9D (pid %P) " fmt "%W", BRIGHTCYAN, RESET, YELLOW, ##args, RESET);
#else
# define U_INTERNAL_ASSERT(expr)
# define U_INTERNAL_ASSERT_MINOR(a,b)
Expand Down Expand Up @@ -465,9 +465,9 @@ static inline void u_put_unalignedp64( void* p, uint64_t val) { s
/* Optimization if it is enough a resolution of one second */

#ifdef ENABLE_THREAD
# define U_gettimeofday { if (u_pthread_time == 0) (void) gettimeofday(u_now, 0); }
# define U_gettimeofday { if (u_pthread_time == 0) (void) gettimeofday(u_now, 0); }
#else
# define U_gettimeofday (void) gettimeofday(u_now, 0);
# define U_gettimeofday (void) gettimeofday(u_now, 0);
#endif

/* To print size of class */
Expand Down
19 changes: 14 additions & 5 deletions include/ulib/debug/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,21 @@ if (envp) \

# define U_TRACE_UNREGISTER_OBJECT(level,CLASS) U_UNREGISTER_OBJECT(level,this); UTrace utr(level, #CLASS"::~"#CLASS"()");

# define U_DUMP_OBJECT(msg,obj) \
# define U_DUMP_OBJECT(obj) { u_trace_dump(#obj" = %S", (obj).dump(true)); }
# define U_DUMP_CONTAINER(obj) { if (utr.active[0]) u_trace_dump(#obj" = %O", U_OBJECT_TO_TRACE((obj))); }

# define U_DUMP_OBJECT_TO_TMP(obj,fname) \
{ char _buffer[2 * 1024 * 1024]; \
uint32_t _n = UObject2String((obj), _buffer, sizeof(_buffer)); \
U_INTERNAL_ASSERT_MINOR(_n, sizeof(_buffer)) \
(void) UFile::writeToTmp(_buffer, _n, O_RDWR | O_TRUNC, #fname"%P", 0); }

# define U_DUMP_OBJECT_WITH_CHECK(msg,check_object) \
if (UObjectDB::fd > 0) { \
char _buffer[4096]; \
uint32_t _n = UObjectDB::dumpObject(_buffer, sizeof(_buffer), obj); \
uint32_t _n = UObjectDB::dumpObject(_buffer, sizeof(_buffer), (check_object)); \
if (utr.active[0]) u_trace_dump(msg " = \n%.*s\n", U_min(_n,4000), _buffer); }

# define U_DUMP_CONTAINER(obj) { if (utr.active[0]) u_trace_dump(#obj" = %O", U_OBJECT_TO_TRACE((obj))); }

# define U_WRITE_MEM_POOL_INFO_TO(fmt,args...) UMemoryPool::writeInfoTo(fmt,args)

// Manage location info for object allocation
Expand All @@ -246,8 +253,10 @@ if (envp) \
# define U_UNREGISTER_OBJECT(level,pointer)
# define U_TRACE_UNREGISTER_OBJECT(level,CLASS)

# define U_DUMP_OBJECT(obj)
# define U_DUMP_CONTAINER(obj)
# define U_DUMP_OBJECT(msg,obj)
# define U_DUMP_OBJECT_TO_TMP(obj,fname)
# define U_DUMP_OBJECT_WITH_CHECK(msg,check_object)
# define U_WRITE_MEM_POOL_INFO_TO(fmt,args...)

# define U_NEW(args...) new args
Expand Down
4 changes: 2 additions & 2 deletions include/ulib/event/event_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class U_EXPORT UEventTime : public UTimeVal {

if ((ms1 - ms2) <= 1) U_RETURN(true);

U_DEBUG("ms1 = %ld ms2 = %ld", ms1, ms2);
U_DEBUG("ms1 = %ld ms2 = %ld", ms1, ms2)

U_RETURN(false);
}
Expand Down Expand Up @@ -190,7 +190,7 @@ class U_EXPORT UEventTime : public UTimeVal {

if ((tolerance - tolerance_calculated) <= 1) U_RETURN(true);

U_DEBUG("tolerance = %ld tolerance_calculated = %ld", tolerance, tolerance_calculated);
U_DEBUG("tolerance = %ld tolerance_calculated = %ld", tolerance, tolerance_calculated)

U_RETURN(false);
}
Expand Down
6 changes: 3 additions & 3 deletions include/ulib/examples/wi_auth_declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1979,15 +1979,15 @@ static void db_open()
{
UString x = db_nodog->print();
(void) UFile::writeToTmp(U_STRING_TO_PARAM(x), false, "WiAuthAccessPoint.init", 0);
(void) UFile::writeToTmp(U_STRING_TO_PARAM(x), O_RDWR | O_TRUNC, "WiAuthAccessPoint.init", 0);
x = db_user->print();
(void) UFile::writeToTmp(U_STRING_TO_PARAM(x), false, "WiAuthUser.init", 0);
(void) UFile::writeToTmp(U_STRING_TO_PARAM(x), O_RDWR | O_TRUNC, "WiAuthUser.init", 0);
x = db_ap->print();
(void) UFile::writeToTmp(U_STRING_TO_PARAM(x), false, "WiAuthVirtualAccessPoint.init", 0);
(void) UFile::writeToTmp(U_STRING_TO_PARAM(x), O_RDWR | O_TRUNC, "WiAuthVirtualAccessPoint.init", 0);
(void) UFile::_unlink("/tmp/WiAuthUser.end");
(void) UFile::_unlink("/tmp/WiAuthAccessPoint.end");
Expand Down
20 changes: 10 additions & 10 deletions include/ulib/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -848,22 +848,22 @@ class U_EXPORT UFile : public stat {
U_RETURN(result);
}

bool write(const char* data, uint32_t sz, bool append = false, bool bmkdirs = false);
bool write(const struct iovec* iov, int n, bool append = false, bool bmkdirs = false);
bool write(const UString& data, bool append = false, bool bmkdirs = false) { return write(U_STRING_TO_PARAM(data), append, bmkdirs); }
bool write(const char* data, uint32_t sz, int flags = O_RDWR | O_TRUNC, bool bmkdirs = false);
bool write(const struct iovec* iov, int n, int flags = O_RDWR | O_TRUNC, bool bmkdirs = false);
bool write(const UString& data, int flags = O_RDWR | O_TRUNC, bool bmkdirs = false) { return write(U_STRING_TO_PARAM(data), flags, bmkdirs); }

static long setSysParam( const char* name, long value, bool force = false);
static long getSysParam( const char* name);
static UString getSysContent(const char* name);

static bool writeToTmp(const char* data, uint32_t sz, bool append, const char* fmt, ...);
static bool writeToTmp(const struct iovec* iov, int n, bool append, const char* fmt, ...);
static bool writeToTmp(const char* data, uint32_t sz, int flags, const char* fmt, ...);
static bool writeToTmp(const struct iovec* iov, int n, int flags, const char* fmt, ...);

static bool writeTo(const UString& path, const char* data, uint32_t sz, bool append = false, bool bmkdirs = false);
static bool writeTo(const UString& path, const struct iovec* iov, int n, bool append = false, bool bmkdirs = false);
static bool writeTo(const UString& path, const char* data, uint32_t sz, int flags = O_RDWR | O_TRUNC, bool bmkdirs = false);
static bool writeTo(const UString& path, const struct iovec* iov, int n, int flags = O_RDWR | O_TRUNC, bool bmkdirs = false);

static bool writeTo(const UString& path, const UString& data, bool append = false, bool bmkdirs = false)
{ return writeTo(path, U_STRING_TO_PARAM(data), append, bmkdirs); }
static bool writeTo(const UString& path, const UString& data, int flags = O_RDWR | O_TRUNC, bool bmkdirs = false)
{ return writeTo(path, U_STRING_TO_PARAM(data), flags, bmkdirs); }

// symlink creates a symbolic link named newpath which contains the string oldpath (make one pathname be an alias for another)

Expand Down Expand Up @@ -1072,7 +1072,7 @@ class U_EXPORT UFile : public stat {
static uint32_t nfree, rlimit_memfree, rlimit_memalloc;

void substitute(UFile& file);
bool creatForWrite(bool append, bool bmkdirs);
bool creatForWrite(int flags, bool bmkdirs);
void setPathRelativ(const UString* environment = 0);
void setPath(const UFile& file, char* buffer_path, const char* suffix, uint32_t len);

Expand Down
17 changes: 3 additions & 14 deletions include/ulib/json/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,21 +878,10 @@ template <> class U_EXPORT UJsonTypeHandler<UStringRep> : public UJsonTypeHandle

template <> class U_EXPORT UJsonTypeHandler<UString> : public UJsonTypeHandler_Base {
public:
explicit UJsonTypeHandler(UString& val) : UJsonTypeHandler_Base(val.rep) {}
explicit UJsonTypeHandler(UString& val) : UJsonTypeHandler_Base(&val) {}

void toJSON(UValue& json)
{
U_TRACE(0, "UJsonTypeHandler<UString>::toJSON(%p)", &json)

((UJsonTypeHandler<UStringRep>*)this)->toJSON(json);
}

void fromJSON(UValue& json)
{
U_TRACE(0, "UJsonTypeHandler<UString>::fromJSON(%p)", &json)

((UJsonTypeHandler<UStringRep>*)this)->fromJSON(json);
}
void toJSON(UValue& json);
void fromJSON(UValue& json);
};

// TEMPLATE SPECIALIZATIONS FOR CONTAINERS
Expand Down
19 changes: 10 additions & 9 deletions include/ulib/net/server/client_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ class U_EXPORT UClientImage_Base : public UEventFd {
uucflag flag;
time_t last_event;

#ifndef U_LOG_DISABLE
static int log_request_partial;

void logRequest();
#endif

void set();
void reset()
{
Expand Down Expand Up @@ -430,29 +436,24 @@ class U_EXPORT UClientImage_Base : public UEventFd {
U_RETURN(U_SINGLE_READ);
}

static void setSendfile(int _sfd, uint32_t _start, uint32_t _count);

#ifndef U_LOG_DISABLE
void logRequest();
#endif
bool writeResponse();
bool logCertificate(); // append on log the peer certicate of client ("issuer","serial")
bool askForClientCertificate();

static struct iovec* piov;
static int csfd, idx, iovcnt;
static UTimeVal* chronometer;
static bool log_request_partial;
static long time_between_request, time_run;
static uint32_t ncount, nrequest, resto, uri_offset;

static void endRequest();
static bool startRequest();

static void resetReadBuffer();
static void resetWriteBuffer();
static void saveRequestResponse();
static void manageReadBufferResize(uint32_t n);

static void endRequest();
static bool startRequest();
static void setSendfile(int _sfd, uint32_t _start, uint32_t _count);

static void do_nothing() {}

Expand Down
6 changes: 4 additions & 2 deletions include/ulib/net/server/plugin/mod_nocat.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,13 @@ class U_EXPORT UNoCatPlugIn : public UServerPlugIn, UEventTime {

peer->fw.setArgument(3, (type == UModNoCatPeer::PEER_PERMIT ? "permit" : "deny"));

if (peer->fw.executeAndWait(0, -1, fd_stderr)) U_peer_status = type;
(void) peer->fw.executeAndWait(0, -1, fd_stderr);

# ifdef U_LOG_ENABLE
# ifndef U_LOG_DISABLE
UServer_Base::logCommandMsgError(peer->fw.getCommand(), false);
# endif

U_peer_status = type;
}

static UString getUrlForSendMsgToPortal(uint32_t index_AUTH, const char* msg, uint32_t msg_len)
Expand Down
3 changes: 1 addition & 2 deletions include/ulib/net/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ vClientImage = new client_type[UNotifier::max_connection]; } }
# define U_SRV_LOG( fmt,args...) {}
# define U_SRV_LOG_WITH_ADDR(fmt,args...) {}
#else
# define U_LOG_ENABLE
# define U_RESET_MODULE_NAME { if (UServer_Base::isLog()) (void) strcpy(UServer_Base::mod_name[0], UServer_Base::mod_name[1]); }
# define U_SET_MODULE_NAME(name) { if (UServer_Base::isLog()) { (void) strcpy(UServer_Base::mod_name[1], UServer_Base::mod_name[0]); \
(void) strcpy(UServer_Base::mod_name[0], "["#name"] "); } }
Expand Down Expand Up @@ -618,7 +617,7 @@ class U_EXPORT UServer_Base : public UEventFd {

// VARIE

#ifdef U_LOG_ENABLE
#ifndef U_LOG_DISABLE
static uint32_t getNumConnection(char* buffer);
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/ulib/notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#endif

#if defined(HAVE_EPOLL_WAIT) && !defined(USE_LIBEVENT) && !defined(U_SERVER_CAPTIVE_PORTAL) && \
(!defined(U_LINUX) || !defined(ENABLE_THREAD) || defined(U_LOG_ENABLE) || defined(USE_LIBZ))
(!defined(U_LINUX) || !defined(ENABLE_THREAD) || !defined(U_LOG_DISABLE) || defined(USE_LIBZ))
# define U_EPOLLET_POSTPONE_STRATEGY
#endif

Expand Down
Loading

0 comments on commit 8900560

Please sign in to comment.