mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
Setting for FrameworkBenchmarks participations
This commit is contained in:
parent
4b660eb6fa
commit
b3904af1be
|
@ -80,12 +80,14 @@ public:
|
|||
n = request.size();
|
||||
start = U_CONSTANT_SIZE("GET /info?");
|
||||
|
||||
# ifdef DEBUG
|
||||
u_printf_string_max_length_save = u_printf_string_max_length;
|
||||
u_printf_string_max_length = n;
|
||||
|
||||
U_INTERNAL_DUMP("request = %.*S", n, s)
|
||||
|
||||
u_printf_string_max_length = u_printf_string_max_length_save;
|
||||
# endif
|
||||
|
||||
while ((p = u_find(s + start, n - start, U_CONSTANT_TO_PARAM("traffic="))))
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <ulib/net/client/http.h>
|
||||
#include <ulib/ssl/certificate.h>
|
||||
#include <ulib/utility/dir_walk.h>
|
||||
#include <ulib/utility/services.h>
|
||||
#include <ulib/ssl/net/sslsocket.h>
|
||||
#include <ulib/net/server/server.h>
|
||||
|
||||
|
@ -18,6 +19,7 @@
|
|||
"option u upload 1 'path of file to upload to url' ''\n" \
|
||||
"option o output 1 'path of file to write output' ''\n" \
|
||||
"option q queue 1 'time polling of queue mode' ''\n" \
|
||||
"option s stdin 0 'read the request to send from standard input' ''\n" \
|
||||
"option i include 0 'include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version' ''\n"
|
||||
|
||||
#include <ulib/application.h>
|
||||
|
@ -48,14 +50,15 @@ public:
|
|||
|
||||
// manage options
|
||||
|
||||
bool include = false;
|
||||
time_t queue_time = 0;
|
||||
UString outpath, result;
|
||||
bool include = false, bstdin = false;
|
||||
|
||||
if (UApplication::isOptions())
|
||||
{
|
||||
cfg_str = opt['c'];
|
||||
upload = opt['u'];
|
||||
bstdin = (opt['s'] == U_STRING_FROM_CONSTANT("1"));
|
||||
include = (opt['i'] == U_STRING_FROM_CONSTANT("1"));
|
||||
outpath = opt['o'];
|
||||
queue_time = opt['q'].strtol();
|
||||
|
@ -114,10 +117,23 @@ loop: if (upload)
|
|||
|
||||
if (client->upload(url, file)) UApplication::exit_value = 0;
|
||||
}
|
||||
else if (client->connectServer(url) &&
|
||||
client->sendRequest())
|
||||
else if (client->connectServer(url))
|
||||
{
|
||||
UApplication::exit_value = 0;
|
||||
bool ok;
|
||||
|
||||
if (bstdin == false) ok = client->sendRequest();
|
||||
else
|
||||
{
|
||||
UString req(U_CAPACITY);
|
||||
|
||||
UServices::readEOF(STDIN_FILENO, req);
|
||||
|
||||
if (req.empty()) U_ERROR("cannot read data from <stdin>");
|
||||
|
||||
ok = client->sendRequest(req);
|
||||
}
|
||||
|
||||
if (ok) UApplication::exit_value = 0;
|
||||
}
|
||||
|
||||
result = (include ? client->getResponse()
|
||||
|
|
|
@ -405,9 +405,7 @@ public:
|
|||
U_TRACE(0, "USocket::setTcpDeferAccept()")
|
||||
|
||||
# if defined(TCP_DEFER_ACCEPT) && !defined(_MSWINDOWS_)
|
||||
uint32_t val = 1;
|
||||
|
||||
(void) setSockOpt(SOL_TCP, TCP_DEFER_ACCEPT, (const void*)&val, sizeof(uint32_t));
|
||||
(void) setSockOpt(SOL_TCP, TCP_DEFER_ACCEPT, (const int[]){ 1 }, sizeof(int));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -416,9 +414,8 @@ public:
|
|||
U_TRACE(0, "USocket::setTcpQuickAck()")
|
||||
|
||||
# if defined(TCP_QUICKACK) && !defined(_MSWINDOWS_)
|
||||
uint32_t val = 0;
|
||||
|
||||
(void) setSockOpt(SOL_TCP, TCP_QUICKACK, (const void*)&val, sizeof(uint32_t));
|
||||
(void) setSockOpt(SOL_TCP, TCP_QUICKACK, (const int[]){ 0 }, sizeof(int));
|
||||
(void) setSockOpt(SOL_TCP, TCP_DEFER_ACCEPT, (const int[]){ 0 }, sizeof(int));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -427,9 +424,7 @@ public:
|
|||
U_TRACE(0, "USocket::setTcpNoDelay()")
|
||||
|
||||
# ifdef TCP_NODELAY
|
||||
uint32_t val = 1;
|
||||
|
||||
(void) setSockOpt(SOL_TCP, TCP_NODELAY, (const void*)&val, sizeof(uint32_t));
|
||||
(void) setSockOpt(SOL_TCP, TCP_NODELAY, (const int[]){ 1 }, sizeof(int));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -452,9 +447,9 @@ public:
|
|||
{
|
||||
U_TRACE(0, "USocket::setTcpLingerOff()")
|
||||
|
||||
struct linger ling = { 0, 0 };
|
||||
const struct linger l = { 1, 1 };
|
||||
|
||||
(void) setSockOpt(SOL_SOCKET, SO_LINGER, &ling, sizeof(ling));
|
||||
(void) setSockOpt(SOL_SOCKET, SO_LINGER, &l, sizeof(struct linger));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -469,9 +464,9 @@ public:
|
|||
{
|
||||
U_TRACE(0, "USocket::setTcpKeepAlive()")
|
||||
|
||||
const int value = 1;
|
||||
|
||||
(void) setSockOpt(SOL_SOCKET, SO_KEEPALIVE, &value, sizeof(value));
|
||||
# ifdef SO_KEEPALIVE
|
||||
(void) setSockOpt(SOL_SOCKET, SO_KEEPALIVE, (const int[]){ 1 }, sizeof(int));
|
||||
# endif
|
||||
}
|
||||
|
||||
void setTcpFastOpen();
|
||||
|
|
|
@ -123,11 +123,15 @@ void UError::stackDump()
|
|||
if (pid == 0)
|
||||
{
|
||||
char buf[32];
|
||||
int fd_err = open("/tmp/gbd.err", O_CREAT | O_WRONLY, 0666);
|
||||
|
||||
(void) u__snprintf(buf, sizeof(buf), "--pid=%P", 0);
|
||||
|
||||
(void) dup2(fd, STDOUT_FILENO);
|
||||
(void) dup2(open("/tmp/gbd.err", O_CREAT | O_WRONLY, 0666), STDERR_FILENO);
|
||||
(void) dup2(fd, STDOUT_FILENO);
|
||||
# ifdef U_COVERITY_FALSE_POSITIVE
|
||||
if (fd > 0)
|
||||
# endif
|
||||
(void) dup2(fd_err, STDERR_FILENO);
|
||||
|
||||
(void) execlp("gdb", "gdb", "--nx", "--batch", "-ex", "thread apply all bt full", buf, name_buf, (char*)0); // thread apply all bt full 20
|
||||
|
||||
|
|
|
@ -456,8 +456,8 @@ static int yy_pop_parser_stack(yyParser *pParser){
|
|||
YYCODETYPE yymajor;
|
||||
yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
|
||||
|
||||
if( pParser->yyidx<0 ) return 0;
|
||||
#ifndef U_COVERITY_FALSE_POSITIVE
|
||||
if( pParser->yyidx<0 ) return 0;
|
||||
#ifndef NDEBUG
|
||||
if( yyTraceFILE && pParser->yyidx>=0 ){
|
||||
fprintf(yyTraceFILE,"%sPopping %s\n",
|
||||
|
|
|
@ -25,19 +25,19 @@ MODULE_LIBTOOL_OPTIONS = -export-dynamic -avoid-version
|
|||
if !CROSS_COMPILING
|
||||
AM_CPPFLAGS = @USP_FLAGS@
|
||||
|
||||
SUFFIXES = .cpp .usp .lo .la
|
||||
#SUFFIXES = .cpp .usp .lo .la
|
||||
|
||||
db.cpp: ./usp_translator$(EXEEXT)
|
||||
#db.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
json.cpp: ./usp_translator$(EXEEXT)
|
||||
#json.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
query.cpp: ./usp_translator$(EXEEXT)
|
||||
#query.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
update.cpp: ./usp_translator$(EXEEXT)
|
||||
#update.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
fortune.cpp: ./usp_translator$(EXEEXT)
|
||||
#fortune.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
plaintext.cpp: ./usp_translator$(EXEEXT)
|
||||
#plaintext.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
.usp.cpp: ./usp_translator$(EXEEXT)
|
||||
@$(WINELOADER) ./usp_translator$(EXEEXT) $<
|
||||
|
@ -45,6 +45,8 @@ plaintext.cpp: ./usp_translator$(EXEEXT)
|
|||
.lo.la:
|
||||
$(CXXLINK) @USP_LDFLAGS@ -rpath $(moduledir) -module $(MODULE_LIBTOOL_OPTIONS) $< $(ulib_la) @USP_LIBS@ @ULIB_LIBS@
|
||||
|
||||
all: usp_translator db.la fortune.la json.la plaintext.la query.la update.la
|
||||
#all: usp_translator db.la fortune.la json.la plaintext.la query.la update.la
|
||||
|
||||
all: usp_translator
|
||||
endif
|
||||
## ----------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -311,11 +311,10 @@ usp_translator_SOURCES = usp_translator.cpp
|
|||
usp_translator_LDFLAGS = $(PRG_LDFLAGS)
|
||||
moduledir = $(libexecdir)/ulib/usp
|
||||
@CROSS_COMPILING_FALSE@AM_CPPFLAGS = @USP_FLAGS@
|
||||
@CROSS_COMPILING_FALSE@SUFFIXES = .cpp .usp .lo .la
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .usp .lo .la .o .obj
|
||||
.SUFFIXES: .cpp .la .lo .o .obj .usp
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
|
@ -658,17 +657,19 @@ uninstall-am: uninstall-binPROGRAMS
|
|||
clean-local:
|
||||
-rm -rf core .libs *.bb* *.da *.gcov *.la *.exe trace.usp_translator* gmon.out usp_compile.sh
|
||||
|
||||
@CROSS_COMPILING_FALSE@db.cpp: ./usp_translator$(EXEEXT)
|
||||
#SUFFIXES = .cpp .usp .lo .la
|
||||
|
||||
@CROSS_COMPILING_FALSE@json.cpp: ./usp_translator$(EXEEXT)
|
||||
#db.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
@CROSS_COMPILING_FALSE@query.cpp: ./usp_translator$(EXEEXT)
|
||||
#json.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
@CROSS_COMPILING_FALSE@update.cpp: ./usp_translator$(EXEEXT)
|
||||
#query.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
@CROSS_COMPILING_FALSE@fortune.cpp: ./usp_translator$(EXEEXT)
|
||||
#update.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
@CROSS_COMPILING_FALSE@plaintext.cpp: ./usp_translator$(EXEEXT)
|
||||
#fortune.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
#plaintext.cpp: ./usp_translator$(EXEEXT)
|
||||
|
||||
@CROSS_COMPILING_FALSE@.usp.cpp: ./usp_translator$(EXEEXT)
|
||||
@CROSS_COMPILING_FALSE@ @$(WINELOADER) ./usp_translator$(EXEEXT) $<
|
||||
|
@ -676,7 +677,9 @@ clean-local:
|
|||
@CROSS_COMPILING_FALSE@.lo.la:
|
||||
@CROSS_COMPILING_FALSE@ $(CXXLINK) @USP_LDFLAGS@ -rpath $(moduledir) -module $(MODULE_LIBTOOL_OPTIONS) $< $(ulib_la) @USP_LIBS@ @ULIB_LIBS@
|
||||
|
||||
@CROSS_COMPILING_FALSE@all: usp_translator db.la fortune.la json.la plaintext.la query.la update.la
|
||||
#all: usp_translator db.la fortune.la json.la plaintext.la query.la update.la
|
||||
|
||||
@CROSS_COMPILING_FALSE@all: usp_translator
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
// db.cpp - dynamic page translation (db.usp => db.cpp)
|
||||
|
||||
#include <ulib/net/server/usp_macro.h>
|
||||
|
||||
#include "world.h"
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
#endif
|
||||
static World* pworld_db;
|
||||
static UOrmSession* psql_db;
|
||||
static UOrmStatement* pstmt_db;
|
||||
|
||||
static void usp_init_db()
|
||||
{
|
||||
U_TRACE(5, "::usp_init_db()")
|
||||
|
||||
pworld_db = U_NEW(World);
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
pvalue = U_NEW(UValue(OBJECT_VALUE));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void usp_fork_db()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_db()")
|
||||
|
||||
psql_db = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
|
||||
pstmt_db = U_NEW(UOrmStatement(*psql_db, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
|
||||
if (pstmt_db == 0) U_ERROR("usp_fork_db(): we cound't connect to db");
|
||||
|
||||
pstmt_db->use( pworld_db->id);
|
||||
pstmt_db->into(pworld_db->randomNumber);
|
||||
}
|
||||
|
||||
static void usp_end_db()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_db()")
|
||||
|
||||
delete pstmt_db;
|
||||
delete psql_db;
|
||||
delete pworld_db;
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern U_EXPORT int runDynamicPage_db(UClientImage_Base* client_image);
|
||||
U_EXPORT int runDynamicPage_db(UClientImage_Base* client_image)
|
||||
{
|
||||
U_TRACE(0, "::runDynamicPage_db(%p)", client_image)
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
// ------------------------------
|
||||
// 0 -> call it as service
|
||||
// -1 -> init
|
||||
// -2 -> reset
|
||||
// -3 -> destroy
|
||||
// -4 -> call it for sigHUP
|
||||
// -5 -> call it after fork
|
||||
// ------------------------------
|
||||
|
||||
if (client_image)
|
||||
{
|
||||
if (client_image == (void*)-1) { usp_init_db(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-3) { usp_end_db(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-5) { usp_fork_db(); U_RETURN(0); }
|
||||
|
||||
if (client_image >= (void*)-5) U_RETURN(0);
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("Content-Type: application/json; charset=UTF-8\r\n\r\n"));
|
||||
|
||||
u_http_info.endHeader = UClientImage_Base::wbuffer->size();
|
||||
}
|
||||
|
||||
pworld_db->id = u_get_num_random(10000);
|
||||
|
||||
pstmt_db->execute();
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF_ADD("{\"id\":%u,\"randomNumber\":%u}", pworld_db->id, pworld_db->randomNumber);
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, World, *pworld_db);
|
||||
#endif
|
||||
|
||||
U_http_content_type_len = 1;
|
||||
|
||||
UClientImage_Base::setRequestNoCache();
|
||||
|
||||
U_RETURN(200);
|
||||
} }
|
|
@ -36,6 +36,7 @@ static void usp_fork_db()
|
|||
pstmt_db->into(pworld_db->randomNumber);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_db()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_db()")
|
||||
|
@ -47,6 +48,7 @@ static void usp_end_db()
|
|||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
<!--#header
|
||||
Content-Type: application/json; charset=UTF-8
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
// fortune.cpp - dynamic page translation (fortune.usp => fortune.cpp)
|
||||
|
||||
#include <ulib/net/server/usp_macro.h>
|
||||
|
||||
#include "fortune.h"
|
||||
|
||||
static UOrmSession* psql_fortune;
|
||||
static UOrmStatement* pstmt_fortune;
|
||||
static Fortune* pfortune;
|
||||
static UString* pmessage;
|
||||
static UVector<Fortune*>* pvfortune;
|
||||
|
||||
static void usp_init_fortune()
|
||||
{
|
||||
U_TRACE(5, "::usp_init_fortune()")
|
||||
|
||||
pfortune = U_NEW(Fortune);
|
||||
pvfortune = U_NEW(UVector<Fortune*>);
|
||||
pmessage = U_NEW(U_STRING_FROM_CONSTANT("Additional fortune added at request time."));
|
||||
}
|
||||
|
||||
static void usp_fork_fortune()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_fortune()")
|
||||
|
||||
psql_fortune = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("fortune")));
|
||||
pstmt_fortune = U_NEW(UOrmStatement(*psql_fortune, U_CONSTANT_TO_PARAM("SELECT id, message FROM Fortune")));
|
||||
|
||||
if (pstmt_fortune == 0) U_ERROR("usp_fork_fortune(): we cound't connect to db");
|
||||
|
||||
pstmt_fortune->into(*pfortune);
|
||||
}
|
||||
|
||||
static void usp_end_fortune()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_fortune()")
|
||||
|
||||
delete pstmt_fortune;
|
||||
delete psql_fortune;
|
||||
delete pvfortune;
|
||||
delete pfortune;
|
||||
delete pmessage;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern U_EXPORT int runDynamicPage_fortune(UClientImage_Base* client_image);
|
||||
U_EXPORT int runDynamicPage_fortune(UClientImage_Base* client_image)
|
||||
{
|
||||
U_TRACE(0, "::runDynamicPage_fortune(%p)", client_image)
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
// ------------------------------
|
||||
// 0 -> call it as service
|
||||
// -1 -> init
|
||||
// -2 -> reset
|
||||
// -3 -> destroy
|
||||
// -4 -> call it for sigHUP
|
||||
// -5 -> call it after fork
|
||||
// ------------------------------
|
||||
|
||||
if (client_image)
|
||||
{
|
||||
if (client_image == (void*)-1) { usp_init_fortune(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-3) { usp_end_fortune(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-5) { usp_fork_fortune(); U_RETURN(0); }
|
||||
|
||||
if (client_image >= (void*)-5) U_RETURN(0);
|
||||
|
||||
UHTTP::mime_index = U_html;
|
||||
|
||||
u_http_info.endHeader = 0;
|
||||
}
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>")
|
||||
);
|
||||
|
||||
Fortune* elem;
|
||||
unsigned char encoded[1024];
|
||||
|
||||
pstmt_fortune->execute();
|
||||
|
||||
pvfortune->push_back(U_NEW(Fortune(0, *pmessage)));
|
||||
do { pvfortune->push_back(U_NEW(Fortune(*pfortune))); } while (pstmt_fortune->nextRow());
|
||||
|
||||
pvfortune->sort(Fortune::cmp_obj);
|
||||
|
||||
for (uint32_t i = 0, n = pvfortune->size(); i < n; ++i)
|
||||
{
|
||||
elem = (*pvfortune)[i];
|
||||
|
||||
USP_PRINTF_ADD(
|
||||
"<tr>"
|
||||
"<td>%u</td>"
|
||||
"<td>%.*s</td>"
|
||||
"</tr>",
|
||||
elem->id, u_xml_encode((const unsigned char*)U_STRING_TO_PARAM(elem->message), encoded), encoded);
|
||||
}
|
||||
|
||||
pvfortune->clear();
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("</table></body></html>")
|
||||
);
|
||||
|
||||
UClientImage_Base::setRequestNoCache();
|
||||
|
||||
U_RETURN(200);
|
||||
} }
|
|
@ -32,6 +32,7 @@ static void usp_fork_fortune()
|
|||
pstmt_fortune->into(*pfortune);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_fortune()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_fortune()")
|
||||
|
@ -42,6 +43,7 @@ static void usp_end_fortune()
|
|||
delete pfortune;
|
||||
delete pmessage;
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
<!doctype html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr><!--#code
|
||||
Fortune* elem;
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
// json.cpp - dynamic page translation (json.usp => json.cpp)
|
||||
|
||||
#include <ulib/net/server/usp_macro.h>
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
#undef AS_cpoll_cppsp_DO
|
||||
#endif
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
# include <json/json.h>
|
||||
#else
|
||||
static UString* pkey;
|
||||
static UString* pvalue;
|
||||
#endif
|
||||
|
||||
static void usp_init_json()
|
||||
{
|
||||
U_TRACE(5, "::usp_init_json()")
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
pkey = U_NEW(U_STRING_FROM_CONSTANT("message"));
|
||||
pvalue = U_NEW(U_STRING_FROM_CONSTANT("Hello, World!"));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void usp_end_json()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_json()")
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
delete pkey;
|
||||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern U_EXPORT int runDynamicPage_json(UClientImage_Base* client_image);
|
||||
U_EXPORT int runDynamicPage_json(UClientImage_Base* client_image)
|
||||
{
|
||||
U_TRACE(0, "::runDynamicPage_json(%p)", client_image)
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
// ------------------------------
|
||||
// 0 -> call it as service
|
||||
// -1 -> init
|
||||
// -2 -> reset
|
||||
// -3 -> destroy
|
||||
// -4 -> call it for sigHUP
|
||||
// -5 -> call it after fork
|
||||
// ------------------------------
|
||||
|
||||
if (client_image)
|
||||
{
|
||||
if (client_image == (void*)-1) { usp_init_json(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-3) { usp_end_json(); U_RETURN(0); }
|
||||
|
||||
if (client_image >= (void*)-5) U_RETURN(0);
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("Content-Type: application/json; charset=UTF-8\r\n\r\n"));
|
||||
|
||||
u_http_info.endHeader = UClientImage_Base::wbuffer->size();
|
||||
}
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
UValue json(*pkey, *pvalue);
|
||||
USP_JSON_PUTS(json);
|
||||
#else
|
||||
json_object* hello = json_object_new_object();
|
||||
json_object_object_add(hello, "message", json_object_new_string("Hello, World!"));
|
||||
const char* hello_str = json_object_to_json_string(hello);
|
||||
USP_PUTS_STRING(hello_str);
|
||||
json_object_put(hello);
|
||||
#endif
|
||||
|
||||
U_http_content_type_len = 1;
|
||||
|
||||
UClientImage_Base::setRequestNoCache();
|
||||
|
||||
U_RETURN(200);
|
||||
} }
|
|
@ -23,6 +23,7 @@ static void usp_init_json()
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_json()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_json()")
|
||||
|
@ -32,6 +33,7 @@ static void usp_end_json()
|
|||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
<!--#header
|
||||
Content-Type: application/json; charset=UTF-8
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<!--#code
|
||||
<!--#code
|
||||
if (UWebSocket::sendData(UWebSocket::message_type, (const unsigned char*)U_STRING_TO_PARAM(*UClientImage_Base::wbuffer))) return 0;
|
||||
return 1;
|
||||
-->
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
// plaintext.cpp - dynamic page translation (plaintext.usp => plaintext.cpp)
|
||||
|
||||
#include <ulib/net/server/usp_macro.h>
|
||||
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern U_EXPORT int runDynamicPage_plaintext(UClientImage_Base* client_image);
|
||||
U_EXPORT int runDynamicPage_plaintext(UClientImage_Base* client_image)
|
||||
{
|
||||
U_TRACE(0, "::runDynamicPage_plaintext(%p)", client_image)
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
// ------------------------------
|
||||
// 0 -> call it as service
|
||||
// -1 -> init
|
||||
// -2 -> reset
|
||||
// -3 -> destroy
|
||||
// -4 -> call it for sigHUP
|
||||
// -5 -> call it after fork
|
||||
// ------------------------------
|
||||
|
||||
if (client_image)
|
||||
{
|
||||
if (client_image >= (void*)-5) U_RETURN(0);
|
||||
|
||||
u_http_info.endHeader = 0;
|
||||
}
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("Hello, World!")
|
||||
);
|
||||
|
||||
U_RETURN(200);
|
||||
} }
|
|
@ -1,131 +0,0 @@
|
|||
// query.cpp - dynamic page translation (query.usp => query.cpp)
|
||||
|
||||
#include <ulib/net/server/usp_macro.h>
|
||||
|
||||
#include "world.h"
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
#endif
|
||||
static UOrmSession* psql_query;
|
||||
static UOrmStatement* pstmt_query;
|
||||
static World* pworld_query;
|
||||
static UVector<World*>* pvworld_query;
|
||||
|
||||
static void usp_init_query()
|
||||
{
|
||||
U_TRACE(5, "::usp_init_query()")
|
||||
|
||||
pworld_query = U_NEW(World);
|
||||
pvworld_query = U_NEW(UVector<World*>(500));
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
pvalue = U_NEW(UValue(ARRAY_VALUE));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void usp_fork_query()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_query()")
|
||||
|
||||
psql_query = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
|
||||
pstmt_query = U_NEW(UOrmStatement(*psql_query, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
|
||||
if (pstmt_query == 0) U_ERROR("usp_fork_query(): we cound't connect to db");
|
||||
|
||||
pstmt_query->use( pworld_query->id);
|
||||
pstmt_query->into(pworld_query->randomNumber);
|
||||
}
|
||||
|
||||
static void usp_end_query()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_query()")
|
||||
|
||||
delete pstmt_query;
|
||||
delete psql_query;
|
||||
delete pvworld_query;
|
||||
delete pworld_query;
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern U_EXPORT int runDynamicPage_query(UClientImage_Base* client_image);
|
||||
U_EXPORT int runDynamicPage_query(UClientImage_Base* client_image)
|
||||
{
|
||||
U_TRACE(0, "::runDynamicPage_query(%p)", client_image)
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
// ------------------------------
|
||||
// 0 -> call it as service
|
||||
// -1 -> init
|
||||
// -2 -> reset
|
||||
// -3 -> destroy
|
||||
// -4 -> call it for sigHUP
|
||||
// -5 -> call it after fork
|
||||
// ------------------------------
|
||||
|
||||
if (client_image)
|
||||
{
|
||||
if (client_image == (void*)-1) { usp_init_query(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-3) { usp_end_query(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-5) { usp_fork_query(); U_RETURN(0); }
|
||||
|
||||
if (client_image >= (void*)-5) U_RETURN(0);
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("Content-Type: application/json; charset=UTF-8\r\n\r\n"));
|
||||
|
||||
u_http_info.endHeader = UClientImage_Base::wbuffer->size();
|
||||
|
||||
(void) UHTTP::processForm();
|
||||
}
|
||||
|
||||
UString queries = USP_FORM_VALUE(0);
|
||||
|
||||
int i = 0, num_queries = queries.strtol();
|
||||
|
||||
if (num_queries < 1) num_queries = 1;
|
||||
else if (num_queries > 500) num_queries = 500;
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR('[');
|
||||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
pworld_query->id = u_get_num_random(10000);
|
||||
|
||||
pstmt_query->execute();
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_query->id, pworld_query->randomNumber);
|
||||
#endif
|
||||
|
||||
pvworld_query->push_back(U_NEW(World(*pworld_query)));
|
||||
|
||||
if (++i == num_queries) break;
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(',');
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(']');
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, UVector<World*>, *pvworld_query);
|
||||
#endif
|
||||
pvworld_query->clear();
|
||||
|
||||
U_http_content_type_len = 1;
|
||||
|
||||
UClientImage_Base::setRequestNoCache();
|
||||
|
||||
U_RETURN(200);
|
||||
} }
|
|
@ -38,6 +38,7 @@ static void usp_fork_query()
|
|||
pstmt_query->into(pworld_query->randomNumber);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_query()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_query()")
|
||||
|
@ -50,6 +51,7 @@ static void usp_end_query()
|
|||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
<!--#args
|
||||
queries;
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
// update.cpp - dynamic page translation (update.usp => update.cpp)
|
||||
|
||||
#include <ulib/net/server/usp_macro.h>
|
||||
|
||||
#include "world.h"
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
static UValue* pvalue;
|
||||
#endif
|
||||
static UOrmSession* psql_update;
|
||||
static UOrmStatement* pstmt1;
|
||||
static UOrmStatement* pstmt2;
|
||||
static World* pworld_update;
|
||||
static UVector<World*>* pvworld_update;
|
||||
|
||||
static void usp_init_update()
|
||||
{
|
||||
U_TRACE(5, "::usp_init_update()")
|
||||
|
||||
pworld_update = U_NEW(World);
|
||||
pvworld_update = U_NEW(UVector<World*>(500));
|
||||
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
pvalue = U_NEW(UValue(ARRAY_VALUE));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void usp_fork_update()
|
||||
{
|
||||
U_TRACE(5, "::usp_fork_update()")
|
||||
|
||||
psql_update = U_NEW(UOrmSession(U_CONSTANT_TO_PARAM("hello_world")));
|
||||
|
||||
pstmt1 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("SELECT randomNumber FROM World WHERE id = ?")));
|
||||
pstmt2 = U_NEW(UOrmStatement(*psql_update, U_CONSTANT_TO_PARAM("UPDATE World SET randomNumber = ? WHERE id = ?")));
|
||||
|
||||
if (pstmt1 == 0 ||
|
||||
pstmt2 == 0)
|
||||
{
|
||||
U_ERROR("usp_fork_update(): we cound't connect to db");
|
||||
}
|
||||
|
||||
pstmt1->use( pworld_update->id);
|
||||
pstmt1->into(pworld_update->randomNumber);
|
||||
pstmt2->use( pworld_update->randomNumber, pworld_update->id);
|
||||
}
|
||||
|
||||
static void usp_end_update()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_update()")
|
||||
|
||||
delete pstmt1;
|
||||
delete pstmt2;
|
||||
delete psql_update;
|
||||
delete pvworld_update;
|
||||
delete pworld_update;
|
||||
#ifndef AS_cpoll_cppsp_DO
|
||||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern U_EXPORT int runDynamicPage_update(UClientImage_Base* client_image);
|
||||
U_EXPORT int runDynamicPage_update(UClientImage_Base* client_image)
|
||||
{
|
||||
U_TRACE(0, "::runDynamicPage_update(%p)", client_image)
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
// ------------------------------
|
||||
// 0 -> call it as service
|
||||
// -1 -> init
|
||||
// -2 -> reset
|
||||
// -3 -> destroy
|
||||
// -4 -> call it for sigHUP
|
||||
// -5 -> call it after fork
|
||||
// ------------------------------
|
||||
|
||||
if (client_image)
|
||||
{
|
||||
if (client_image == (void*)-1) { usp_init_update(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-3) { usp_end_update(); U_RETURN(0); }
|
||||
|
||||
if (client_image == (void*)-5) { usp_fork_update(); U_RETURN(0); }
|
||||
|
||||
if (client_image >= (void*)-5) U_RETURN(0);
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("Content-Type: application/json; charset=UTF-8\r\n\r\n"));
|
||||
|
||||
u_http_info.endHeader = UClientImage_Base::wbuffer->size();
|
||||
|
||||
(void) UHTTP::processForm();
|
||||
}
|
||||
|
||||
UString queries = USP_FORM_VALUE(0);
|
||||
|
||||
int i = 0, num_queries = queries.strtol();
|
||||
|
||||
if (num_queries < 1) num_queries = 1;
|
||||
else if (num_queries > 500) num_queries = 500;
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR('[');
|
||||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
pworld_update->id = u_get_num_random(10000);
|
||||
|
||||
pstmt1->execute();
|
||||
|
||||
U_INTERNAL_DUMP("pworld_update->randomNumber = %u", pworld_update->randomNumber)
|
||||
|
||||
pworld_update->randomNumber = u_get_num_random(10000);
|
||||
|
||||
pstmt2->execute();
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PRINTF("{\"id\":%u,\"randomNumber\":%u}", pworld_update->id, pworld_update->randomNumber);
|
||||
#endif
|
||||
|
||||
pvworld_update->push_back(U_NEW(World(*pworld_update)));
|
||||
|
||||
if (++i == num_queries) break;
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(',');
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef AS_cpoll_cppsp_DO
|
||||
USP_PUTS_CHAR(']');
|
||||
#else
|
||||
USP_JSON_stringify(*pvalue, UVector<World*>, *pvworld_update);
|
||||
#endif
|
||||
|
||||
pvworld_update->clear();
|
||||
|
||||
U_http_content_type_len = 1;
|
||||
|
||||
UClientImage_Base::setRequestNoCache();
|
||||
|
||||
U_RETURN(200);
|
||||
} }
|
|
@ -46,6 +46,7 @@ static void usp_fork_update()
|
|||
pstmt2->use( pworld_update->randomNumber, pworld_update->id);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void usp_end_update()
|
||||
{
|
||||
U_TRACE(5, "::usp_end_update()")
|
||||
|
@ -59,6 +60,7 @@ static void usp_end_update()
|
|||
delete pvalue;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
-->
|
||||
<!--#args
|
||||
queries;
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
// upload_progress.cpp - dynamic page translation (upload_progress.usp => upload_progress.cpp)
|
||||
|
||||
#include <ulib/net/server/usp_macro.h>
|
||||
|
||||
static void usp_init_upload_progress()
|
||||
{
|
||||
U_TRACE(5, "::usp_init_upload_progress()")
|
||||
|
||||
if (UServer_Base::isPreForked())
|
||||
{
|
||||
UHTTP::ptr_upload_progress = (UHTTP::upload_progress*) UServer_Base::getPointerToDataShare(UHTTP::ptr_upload_progress);
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(UHTTP::ptr_upload_progress->byte_read, 0)
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern U_EXPORT int runDynamicPage_upload_progress(UClientImage_Base* client_image);
|
||||
U_EXPORT int runDynamicPage_upload_progress(UClientImage_Base* client_image)
|
||||
{
|
||||
U_TRACE(0, "::runDynamicPage_upload_progress(%p)", client_image)
|
||||
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
// ------------------------------
|
||||
// 0 -> call it as service
|
||||
// -1 -> init
|
||||
// -2 -> reset
|
||||
// -3 -> destroy
|
||||
// -4 -> call it for sigHUP
|
||||
// -5 -> call it after fork
|
||||
// ------------------------------
|
||||
|
||||
if (client_image)
|
||||
{
|
||||
if (client_image == (void*)-1) { usp_init_upload_progress(); U_RETURN(0); }
|
||||
|
||||
if (client_image >= (void*)-5) U_RETURN(0);
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(
|
||||
U_CONSTANT_TO_PARAM("Content-Type: application/json\r\nCache Control: max-age=0\r\nExpires: Thu, 19 Nov 1981 08:52:00 GMT\r\n\r\n"));
|
||||
|
||||
u_http_info.endHeader = UClientImage_Base::wbuffer->size();
|
||||
}
|
||||
|
||||
(void) UClientImage_Base::wbuffer->append(UHTTP::getUploadProgress());
|
||||
|
||||
U_http_content_type_len = 1;
|
||||
|
||||
UClientImage_Base::setRequestNoCache();
|
||||
|
||||
U_RETURN(200);
|
||||
} }
|
|
@ -11,9 +11,9 @@
|
|||
//
|
||||
// =======================================================================================
|
||||
|
||||
#include <ulib/file.h>
|
||||
#include <ulib/tokenizer.h>
|
||||
#include <ulib/net/socket.h>
|
||||
#include <ulib/file_config.h>
|
||||
#include <ulib/utility/escape.h>
|
||||
#include <ulib/utility/string_ext.h>
|
||||
|
||||
|
@ -113,6 +113,19 @@ public:
|
|||
|
||||
if (usp.empty()) U_ERROR("filename not valid");
|
||||
|
||||
if (usp.find(U_CONSTANT_TO_PARAM("\n#ifdef DEBUG")) != U_NOT_FOUND)
|
||||
{
|
||||
UString before = UStringExt::substitute(usp, U_CONSTANT_TO_PARAM("#include"), U_CONSTANT_TO_PARAM("//#include"));
|
||||
|
||||
UFileConfig cfg(before, true);
|
||||
|
||||
if (cfg.processData() == false) U_ERROR("preprocessing filename failed");
|
||||
|
||||
UString after = cfg.getData();
|
||||
|
||||
usp = UStringExt::substitute(after, U_CONSTANT_TO_PARAM("//#include"), U_CONSTANT_TO_PARAM("#include"));
|
||||
}
|
||||
|
||||
const char* ptr;
|
||||
const char* directive;
|
||||
uint32_t i, n, distance, pos, size;
|
||||
|
@ -503,14 +516,14 @@ public:
|
|||
|
||||
http_header = x;
|
||||
|
||||
char ptr1[100] = { '\0' };
|
||||
char ptr2[100] = { '\0' };
|
||||
char ptr3[100] = { '\0' };
|
||||
char ptr4[100] = { '\0' };
|
||||
char ptr5[100] = { '\0' };
|
||||
const char* ptr6 = "";
|
||||
const char* ptr7 = "";
|
||||
const char* ptr8 = (bcomment ? "\n\t\tUClientImage_Base::setRequestNoCache();\n\t\n" : "");
|
||||
char ptr1[100] = { '\0' };
|
||||
char ptr2[100] = { '\0' };
|
||||
char ptr3[100] = { '\0' };
|
||||
char ptr4[100] = { '\0' };
|
||||
char ptr5[100] = { '\0' };
|
||||
const char* ptr6 = "";
|
||||
const char* ptr7 = "";
|
||||
const char* ptr8 = (bcomment ? "\n\t\tUClientImage_Base::setRequestNoCache();\n\t\n" : "");
|
||||
|
||||
// ------------------------------
|
||||
// special argument value:
|
||||
|
|
|
@ -168,9 +168,7 @@ bool USocket::shutdown(int how)
|
|||
* Ref4: tcp_max_orphans [https://www.frozentux.net/ipsysctl-tutorial/chunkyhtml/tcpvariables.html#AEN388]
|
||||
*/
|
||||
|
||||
// const int value = 1;
|
||||
|
||||
// (void) setSockOpt(SOL_SOCKET, SO_KEEPALIVE, &value, sizeof(value));
|
||||
// (void) setSockOpt(SOL_SOCKET, SO_KEEPALIVE, (const int[]){ 1 }, sizeof(int));
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
@ -312,9 +310,7 @@ void USocket::setTcpFastOpen()
|
|||
# define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */
|
||||
# endif
|
||||
|
||||
uint32_t val = 1;
|
||||
|
||||
(void) setSockOpt(SOL_TCP, TCP_FASTOPEN, (const void*)&val, sizeof(uint32_t));
|
||||
(void) setSockOpt(SOL_TCP, TCP_FASTOPEN, (const int[]){ 5 }, sizeof(int));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -337,10 +333,8 @@ void USocket::setReusePort()
|
|||
# define SO_REUSEPORT 15
|
||||
# endif
|
||||
|
||||
uint32_t val = 1;
|
||||
|
||||
tcp_reuseport = (U_socket_Type(this) != SK_UNIX &&
|
||||
setSockOpt(SOL_SOCKET, SO_REUSEPORT, (const void*)&val, sizeof(uint32_t)) &&
|
||||
tcp_reuseport = (U_socket_Type(this) != SK_UNIX &&
|
||||
setSockOpt(SOL_SOCKET, SO_REUSEPORT, (const int[]){ 1 }, sizeof(int)) &&
|
||||
U_socket_Type(this) != SK_DGRAM);
|
||||
|
||||
U_INTERNAL_DUMP("tcp_reuseport = %b", tcp_reuseport)
|
||||
|
@ -358,9 +352,7 @@ void USocket::setReuseAddress()
|
|||
* the same port, by binding to a specific address as opposed to INADDR_ANY.
|
||||
*/
|
||||
|
||||
uint32_t value = 1;
|
||||
|
||||
(void) setSockOpt(SOL_SOCKET, SO_REUSEADDR, (const void*)&value, sizeof(uint32_t));
|
||||
(void) setSockOpt(SOL_SOCKET, SO_REUSEADDR, (const int[]){ 1 }, sizeof(int));
|
||||
}
|
||||
|
||||
void USocket::setAddress(void* address)
|
||||
|
|
|
@ -112,7 +112,7 @@ read:
|
|||
# ifdef USE_LIBSSL
|
||||
bssl == false &&
|
||||
# endif
|
||||
UNotifier::waitForRead(sk->iSockDesc, timeoutMS) != 1)
|
||||
(errno = 0, UNotifier::waitForRead(sk->iSockDesc, timeoutMS) != 1))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ int USocketExt::write(USocket* sk, const char* ptr, uint32_t count, int timeoutM
|
|||
write:
|
||||
if (blocking &&
|
||||
timeoutMS != 0 &&
|
||||
UNotifier::waitForWrite(sk->iSockDesc, timeoutMS) != 1)
|
||||
(errno = 0, UNotifier::waitForWrite(sk->iSockDesc, timeoutMS) != 1))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ int USocketExt::sendfile(USocket* sk, int in_fd, off_t* poffset, uint32_t count,
|
|||
loop:
|
||||
if (blocking &&
|
||||
timeoutMS != 0 &&
|
||||
UNotifier::waitForWrite(sk->iSockDesc, timeoutMS) != 1)
|
||||
(errno = 0, UNotifier::waitForWrite(sk->iSockDesc, timeoutMS) != 1))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ int USocketExt::_writev(USocket* sk, struct iovec* iov, int iovcnt, uint32_t cou
|
|||
loop:
|
||||
if (blocking &&
|
||||
timeoutMS != 0 &&
|
||||
UNotifier::waitForWrite(sk->iSockDesc, timeoutMS) != 1)
|
||||
(errno = 0, UNotifier::waitForWrite(sk->iSockDesc, timeoutMS) != 1))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ bool USOAPParser::parse(const UString& msg)
|
|||
# ifndef U_COVERITY_FALSE_POSITIVE // Explicit null dereferenced (FORWARD_NULL)
|
||||
method = body->childAt(0);
|
||||
envelope.methodName = method->elem()->getAccessorName();
|
||||
# endif
|
||||
|
||||
// load the parameters for the method to execute
|
||||
|
||||
|
@ -58,6 +57,7 @@ bool USOAPParser::parse(const UString& msg)
|
|||
|
||||
if (param) envelope.arg->push_back(param);
|
||||
}
|
||||
# endif
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user