mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
various fix
This commit is contained in:
parent
78fb96cf41
commit
3d96832bcf
|
@ -199,6 +199,9 @@ extern U_EXPORT uclientimage_info u_clientimage_info;
|
|||
}
|
||||
#endif
|
||||
|
||||
#define U_PARALLELIZATION_CHILD 1
|
||||
#define U_PARALLELIZATION_PARENT 2
|
||||
|
||||
#define U_http_info u_clientimage_info.http_info
|
||||
#define U_clientimage_flag u_clientimage_info.flag
|
||||
#define U_http_method_list u_clientimage_info.http_method_list
|
||||
|
|
|
@ -452,7 +452,7 @@ public:
|
|||
U_INTERNAL_DUMP("U_ClientImage_parallelization = %d proc->child() = %b",
|
||||
U_ClientImage_parallelization, proc->child())
|
||||
|
||||
if (U_ClientImage_parallelization == 1) U_RETURN(true); // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ public:
|
|||
U_INTERNAL_DUMP("U_ClientImage_parallelization = %d proc->parent() = %b",
|
||||
U_ClientImage_parallelization, proc->parent())
|
||||
|
||||
if (U_ClientImage_parallelization == 2) U_RETURN(true); // 2 => parent of parallelization
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_PARENT) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
|
|
@ -1077,7 +1077,7 @@ void u_bind2cpu(cpu_set_t* cpuset, int n)
|
|||
#endif
|
||||
}
|
||||
|
||||
void u_switch_to_realtime_priority()
|
||||
void u_switch_to_realtime_priority(void)
|
||||
{
|
||||
#if !defined(U_SERVER_CAPTIVE_PORTAL) && defined(_POSIX_PRIORITY_SCHEDULING) && (_POSIX_PRIORITY_SCHEDULING > 0) && (defined(HAVE_SCHED_H) || defined(HAVE_SYS_SCHED_H))
|
||||
struct sched_param sp;
|
||||
|
|
|
@ -485,7 +485,7 @@ void UClientImage_Base::handlerDelete()
|
|||
"UEventFd::fd = %d socket->iSockDesc = %d "
|
||||
"UNotifier::num_connection = %d UNotifier::min_connection = %d "
|
||||
"U_ClientImage_parallelization = %d sfd = %d UEventFd::op_mask = %B",
|
||||
UEventFd::fd, socket->iSockDesc, UNotifier::num_connection, UNotifier::min_connection,
|
||||
UEventFd::fd, socket->iSockDesc, UNotifier::num_connection, UNotifier::min_connection,
|
||||
U_ClientImage_parallelization, sfd, UEventFd::op_mask);
|
||||
}
|
||||
# endif
|
||||
|
@ -681,10 +681,7 @@ void UClientImage_Base::endRequest()
|
|||
|
||||
// NB: URI requested can be URL encoded (ex: vuoto%2Etxt) so we cannot use snprintf()...
|
||||
|
||||
char buffer1[256],
|
||||
buffer2[64];
|
||||
|
||||
uint32_t sz2 = 0;
|
||||
char buffer1[256];
|
||||
char* ptr1 = buffer1;
|
||||
|
||||
u__memcpy(ptr1, "request \"", U_CONSTANT_SIZE("request \""), __PRETTY_FUNCTION__);
|
||||
|
@ -703,20 +700,26 @@ void UClientImage_Base::endRequest()
|
|||
u__memcpy(ptr1, "\" run in ", U_CONSTANT_SIZE("\" run in "), __PRETTY_FUNCTION__);
|
||||
ptr1 += U_CONSTANT_SIZE("\" run in ");
|
||||
|
||||
int cpu = U_SYSCALL_NO_PARAM(sched_getcpu);
|
||||
if (time_run > 0L) ptr1 += u__snprintf(ptr1, sizeof(buffer1)-(ptr1-buffer1), "%ld ms", time_run);
|
||||
else ptr1 += u__snprintf(ptr1, sizeof(buffer1)-(ptr1-buffer1), "%g ms", chronometer->getTimeElapsed());
|
||||
|
||||
U_INTERNAL_DUMP("cpu = %d USocket::incoming_cpu = %d", cpu, USocket::incoming_cpu)
|
||||
|
||||
# ifdef SO_INCOMING_CPU
|
||||
if (USocket::incoming_cpu != cpu &&
|
||||
USocket::incoming_cpu != -1)
|
||||
if (UServer_Base::csocket->isOpen())
|
||||
{
|
||||
sz2 = u__snprintf(buffer2, sizeof(buffer2), " (EXPECTED CPU %d)", USocket::incoming_cpu);
|
||||
}
|
||||
# endif
|
||||
uint32_t len = 0;
|
||||
int cpu = U_SYSCALL_NO_PARAM(sched_getcpu), scpu = -1;
|
||||
|
||||
if (time_run > 0L) ptr1 += u__snprintf(ptr1, sizeof(buffer1)-(ptr1-buffer1), "%ld ms on cpu %d%.*s", time_run, cpu, sz2, buffer2);
|
||||
else ptr1 += u__snprintf(ptr1, sizeof(buffer1)-(ptr1-buffer1), "%g ms on cpu %d%.*s", chronometer->getTimeElapsed(), cpu, sz2, buffer2);
|
||||
# ifdef SO_INCOMING_CPU
|
||||
len = sizeof(socklen_t);
|
||||
|
||||
(void) UServer_Base::csocket->getSockOpt(SOL_SOCKET, SO_INCOMING_CPU, (void*)&scpu, len);
|
||||
|
||||
len = ((USocket::incoming_cpu == scpu || USocket::incoming_cpu == -1) ? 0 : U_CONSTANT_SIZE(" [DIFFER]"));
|
||||
# endif
|
||||
|
||||
U_INTERNAL_DUMP("USocket::incoming_cpu = %d sched cpu = %d socket cpu = %d", USocket::incoming_cpu, cpu, scpu)
|
||||
|
||||
if (len) ptr1 += u__snprintf(ptr1, sizeof(buffer1)-(ptr1-buffer1), ", CPU: %d sched(%d) socket(%d)%.*s", USocket::incoming_cpu, cpu, scpu, len, " [DIFFER]");
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_MINOR((ptrdiff_t)(ptr1-buffer1), (ptrdiff_t)sizeof(buffer1))
|
||||
|
||||
|
@ -862,7 +865,7 @@ void UClientImage_Base::prepareForRead()
|
|||
{
|
||||
U_ASSERT(UServer_Base::proc->child())
|
||||
|
||||
U_ClientImage_parallelization = 1; // 1 => child of parallelization
|
||||
U_ClientImage_parallelization = U_PARALLELIZATION_CHILD;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1011,7 +1014,7 @@ start:
|
|||
if (genericRead() == false)
|
||||
{
|
||||
if (U_ClientImage_state == U_PLUGIN_HANDLER_AGAIN &&
|
||||
U_ClientImage_parallelization != 1) // 1 => child of parallelization
|
||||
U_ClientImage_parallelization != U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
|
||||
|
@ -1076,7 +1079,7 @@ pipeline:
|
|||
dmiss:
|
||||
U_INTERNAL_DUMP("U_ClientImage_parallelization = %d", U_ClientImage_parallelization)
|
||||
|
||||
if (U_ClientImage_parallelization == 1) // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
if (UNotifier::waitForRead(UServer_Base::csocket->iSockDesc, U_TIMEOUT_MS) != 1 ||
|
||||
(resetReadBuffer(), USocketExt::read(UServer_Base::csocket, *rbuffer, getCountToRead(), 0)) == false)
|
||||
|
@ -1111,7 +1114,7 @@ dmiss:
|
|||
U_INTERNAL_DUMP("data_pending(%u) = %V", data_pending->size(), data_pending->rep)
|
||||
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
|
||||
|
||||
U_RETURN(U_NOTIFIER_OK);
|
||||
}
|
||||
|
@ -1272,7 +1275,7 @@ processing:
|
|||
if (isRequestNeedProcessing())
|
||||
{
|
||||
U_INTERNAL_ASSERT_POINTER(callerHandlerRequest)
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 2) // 2 => parent of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_PARENT)
|
||||
U_INTERNAL_ASSERT_EQUALS(U_ClientImage_state & (U_PLUGIN_HANDLER_AGAIN | U_PLUGIN_HANDLER_ERROR), 0)
|
||||
|
||||
U_ClientImage_state = callerHandlerRequest();
|
||||
|
@ -1291,7 +1294,7 @@ processing:
|
|||
U_INTERNAL_DUMP("U_http_info.nResponseCode = %u count = %u UEventFd::op_mask = %d %B",
|
||||
U_http_info.nResponseCode, count, UEventFd::op_mask, UEventFd::op_mask)
|
||||
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 2) // 2 => parent of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_PARENT)
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
|
@ -1377,14 +1380,14 @@ error:
|
|||
|
||||
if (U_ClientImage_close)
|
||||
{
|
||||
end: if (U_ClientImage_parallelization == 1) goto death; // 1 => child of parallelization
|
||||
end: if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD) goto death;
|
||||
|
||||
U_RETURN(U_NOTIFIER_DELETE);
|
||||
}
|
||||
|
||||
// NB: maybe we have some more request to services on the same connection...
|
||||
|
||||
if (U_ClientImage_parallelization == 1)
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
U_INTERNAL_ASSERT_DIFFERS(socket->iSockDesc, -1)
|
||||
|
||||
|
@ -1397,7 +1400,7 @@ death:
|
|||
last_event = u_now->tv_sec;
|
||||
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
|
||||
|
||||
U_INTERNAL_DUMP("request(%u) = %V", request->size(), request->rep);
|
||||
|
||||
|
@ -1412,7 +1415,7 @@ bool UClientImage_Base::writeResponse()
|
|||
|
||||
U_INTERNAL_ASSERT(*wbuffer)
|
||||
U_INTERNAL_ASSERT(socket->isOpen())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 2) // 2 => parent of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_PARENT)
|
||||
|
||||
int iBytesWrite;
|
||||
uint32_t sz1 = wbuffer->size(),
|
||||
|
@ -1567,7 +1570,7 @@ loop:
|
|||
#endif
|
||||
{
|
||||
#ifdef U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT
|
||||
if (U_ClientImage_parallelization != 1) goto end; // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization != U_PARALLELIZATION_CHILD) goto end;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1589,7 +1592,7 @@ loop:
|
|||
if (iBytesWrite > 0)
|
||||
{
|
||||
if (UServer_Base::bssl ||
|
||||
U_ClientImage_parallelization == 1) // NB: we must not have pending write...
|
||||
U_ClientImage_parallelization == U_PARALLELIZATION_CHILD) // NB: we must not have pending write...
|
||||
{
|
||||
if (bflag == false)
|
||||
{
|
||||
|
@ -1701,7 +1704,7 @@ int UClientImage_Base::handlerResponse()
|
|||
if (socket->isOpen())
|
||||
{
|
||||
U_INTERNAL_ASSERT_EQUALS(UServer_Base::bssl, false)
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // NB: we must not have pending write...
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD) // NB: we must not have pending write...
|
||||
U_INTERNAL_ASSERT_EQUALS(UEventFd::op_mask, EPOLLIN | EPOLLRDHUP | EPOLLET)
|
||||
|
||||
# ifndef U_CLIENT_RESPONSE_PARTIAL_WRITE_SUPPORT
|
||||
|
@ -1802,8 +1805,8 @@ write:
|
|||
# ifdef DEBUG
|
||||
else
|
||||
{
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 2) // 2 => parent of parallelization
|
||||
U_INTERNAL_ASSERT_EQUALS(UEventFd::op_mask, EPOLLIN | EPOLLRDHUP | EPOLLET)
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_PARENT)
|
||||
}
|
||||
# endif
|
||||
|
||||
|
@ -1829,7 +1832,7 @@ write:
|
|||
|
||||
if (bwrite) U_RETURN(U_NOTIFIER_OK);
|
||||
|
||||
if (U_ClientImage_parallelization == 1) // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
wait: if (UNotifier::waitForWrite(socket->iSockDesc, U_TIMEOUT_MS) == 1) goto write;
|
||||
|
||||
|
@ -1845,7 +1848,7 @@ wait: if (UNotifier::waitForWrite(socket->iSockDesc, U_TIMEOUT_MS) == 1) goto
|
|||
U_RETURN(U_NOTIFIER_DELETE);
|
||||
}
|
||||
|
||||
if (U_ClientImage_parallelization == 1) goto wait; // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD) goto wait;
|
||||
|
||||
prepareForSendfile();
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ U_NO_EXPORT bool USSIPlugIn::callService(const UString& name, const UString& val
|
|||
|
||||
if (result == false ||
|
||||
alternative_response ||
|
||||
U_ClientImage_parallelization == 2) // 2 => parent of parallelization
|
||||
U_ClientImage_parallelization == U_PARALLELIZATION_PARENT)
|
||||
{
|
||||
alternative_response = 1; // 1 => response already complete (nothing to do)
|
||||
|
||||
|
|
|
@ -1841,59 +1841,59 @@ int UServer_Base::pluginsHandler##xxx() \
|
|||
U_RETURN(U_PLUGIN_HANDLER_FINISHED); \
|
||||
}
|
||||
#else
|
||||
# define U_PLUGIN_HANDLER(xxx) \
|
||||
int UServer_Base::pluginsHandler##xxx() \
|
||||
{ \
|
||||
U_TRACE_NO_PARAM(0, "UServer_Base::pluginsHandler"#xxx"()") \
|
||||
\
|
||||
U_INTERNAL_ASSERT_POINTER(vplugin) \
|
||||
U_INTERNAL_ASSERT_MAJOR(vplugin_size, 0) \
|
||||
\
|
||||
int result; \
|
||||
uint32_t i = 0; \
|
||||
const char* fmt; \
|
||||
UServerPlugIn* _plugin; \
|
||||
\
|
||||
do { \
|
||||
_plugin = vplugin->at(i); \
|
||||
\
|
||||
if (isLog() == false) result = _plugin->handler##xxx(); \
|
||||
else \
|
||||
{ \
|
||||
UString name = vplugin_name->at(i); \
|
||||
\
|
||||
(void)u__snprintf(mod_name[0],sizeof(mod_name[0]),"[%v] ",name.rep); \
|
||||
\
|
||||
result = _plugin->handler##xxx(); \
|
||||
\
|
||||
if ((result & (U_PLUGIN_HANDLER_ERROR | \
|
||||
U_PLUGIN_HANDLER_PROCESSED)) != 0) \
|
||||
{ \
|
||||
if ((result & U_PLUGIN_HANDLER_ERROR) != 0) \
|
||||
{ \
|
||||
fmt = ((result & U_PLUGIN_HANDLER_FINISHED) != 0 \
|
||||
? 0 \
|
||||
: "%sWARNING: "#xxx" phase of plugin %v failed"); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
fmt = (U_ClientImage_parallelization == 2 || \
|
||||
(result & U_PLUGIN_HANDLER_PROCESSED) == 0 \
|
||||
? 0 \
|
||||
: "%s"#xxx" phase of plugin %v success"); \
|
||||
} \
|
||||
\
|
||||
if (fmt) ULog::log(fmt, mod_name[0], name.rep); \
|
||||
} \
|
||||
\
|
||||
mod_name[0][0] = '\0'; \
|
||||
} \
|
||||
\
|
||||
if ((result & U_PLUGIN_HANDLER_GO_ON) == 0) U_RETURN(result); \
|
||||
} \
|
||||
while (++i < vplugin_size); \
|
||||
\
|
||||
U_RETURN(U_PLUGIN_HANDLER_FINISHED); \
|
||||
# define U_PLUGIN_HANDLER(xxx) \
|
||||
int UServer_Base::pluginsHandler##xxx() \
|
||||
{ \
|
||||
U_TRACE_NO_PARAM(0, "UServer_Base::pluginsHandler"#xxx"()") \
|
||||
\
|
||||
U_INTERNAL_ASSERT_POINTER(vplugin) \
|
||||
U_INTERNAL_ASSERT_MAJOR(vplugin_size, 0) \
|
||||
\
|
||||
int result; \
|
||||
uint32_t i = 0; \
|
||||
const char* fmt; \
|
||||
UServerPlugIn* _plugin; \
|
||||
\
|
||||
do { \
|
||||
_plugin = vplugin->at(i); \
|
||||
\
|
||||
if (isLog() == false) result = _plugin->handler##xxx(); \
|
||||
else \
|
||||
{ \
|
||||
UString name = vplugin_name->at(i); \
|
||||
\
|
||||
(void)u__snprintf(mod_name[0],sizeof(mod_name[0]),"[%v] ",name.rep); \
|
||||
\
|
||||
result = _plugin->handler##xxx(); \
|
||||
\
|
||||
if ((result & (U_PLUGIN_HANDLER_ERROR | \
|
||||
U_PLUGIN_HANDLER_PROCESSED)) != 0) \
|
||||
{ \
|
||||
if ((result & U_PLUGIN_HANDLER_ERROR) != 0) \
|
||||
{ \
|
||||
fmt = ((result & U_PLUGIN_HANDLER_FINISHED) != 0 \
|
||||
? 0 \
|
||||
: "%sWARNING: "#xxx" phase of plugin %v failed"); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
fmt = (U_ClientImage_parallelization == U_PARALLELIZATION_PARENT || \
|
||||
(result & U_PLUGIN_HANDLER_PROCESSED) == 0 \
|
||||
? 0 \
|
||||
: "%s"#xxx" phase of plugin %v success"); \
|
||||
} \
|
||||
\
|
||||
if (fmt) ULog::log(fmt, mod_name[0], name.rep); \
|
||||
} \
|
||||
\
|
||||
mod_name[0][0] = '\0'; \
|
||||
} \
|
||||
\
|
||||
if ((result & U_PLUGIN_HANDLER_GO_ON) == 0) U_RETURN(result); \
|
||||
} \
|
||||
while (++i < vplugin_size); \
|
||||
\
|
||||
U_RETURN(U_PLUGIN_HANDLER_FINISHED); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1924,59 +1924,59 @@ int UServer_Base::pluginsHandler##xxx() \
|
|||
while (true); \
|
||||
}
|
||||
#else
|
||||
# define U_PLUGIN_HANDLER_REVERSE(xxx) \
|
||||
int UServer_Base::pluginsHandler##xxx() \
|
||||
{ \
|
||||
U_TRACE_NO_PARAM(0, "UServer_Base::pluginsHandler"#xxx"()") \
|
||||
\
|
||||
U_INTERNAL_ASSERT_POINTER(vplugin) \
|
||||
U_INTERNAL_ASSERT_MAJOR(vplugin_size, 0) \
|
||||
\
|
||||
int result; \
|
||||
const char* fmt; \
|
||||
UServerPlugIn* _plugin; \
|
||||
uint32_t i = vplugin_size; \
|
||||
\
|
||||
do { \
|
||||
_plugin = vplugin->at(--i); \
|
||||
\
|
||||
if (isLog() == false) result = _plugin->handler##xxx(); \
|
||||
else \
|
||||
{ \
|
||||
UString name = vplugin_name->at(i); \
|
||||
\
|
||||
(void)u__snprintf(mod_name[0],sizeof(mod_name[0]),"[%v] ",name.rep); \
|
||||
\
|
||||
result = _plugin->handler##xxx(); \
|
||||
\
|
||||
if ((result & (U_PLUGIN_HANDLER_ERROR | \
|
||||
U_PLUGIN_HANDLER_PROCESSED)) != 0) \
|
||||
{ \
|
||||
if ((result & U_PLUGIN_HANDLER_ERROR) != 0) \
|
||||
{ \
|
||||
fmt = ((result & U_PLUGIN_HANDLER_FINISHED) != 0 \
|
||||
? 0 \
|
||||
: "%sWARNING: "#xxx" phase of plugin %v failed"); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
fmt = (U_ClientImage_parallelization == 2 || \
|
||||
(result & U_PLUGIN_HANDLER_PROCESSED) == 0 \
|
||||
? 0 \
|
||||
: "%s"#xxx" phase of plugin %v success"); \
|
||||
} \
|
||||
\
|
||||
if (fmt) ULog::log(fmt, mod_name[0], name.rep); \
|
||||
} \
|
||||
\
|
||||
mod_name[0][0] = '\0'; \
|
||||
} \
|
||||
\
|
||||
if ((result & U_PLUGIN_HANDLER_GO_ON) == 0) U_RETURN(result); \
|
||||
\
|
||||
if (i == 0) U_RETURN(U_PLUGIN_HANDLER_FINISHED); \
|
||||
} \
|
||||
while (true); \
|
||||
# define U_PLUGIN_HANDLER_REVERSE(xxx) \
|
||||
int UServer_Base::pluginsHandler##xxx() \
|
||||
{ \
|
||||
U_TRACE_NO_PARAM(0, "UServer_Base::pluginsHandler"#xxx"()") \
|
||||
\
|
||||
U_INTERNAL_ASSERT_POINTER(vplugin) \
|
||||
U_INTERNAL_ASSERT_MAJOR(vplugin_size, 0) \
|
||||
\
|
||||
int result; \
|
||||
const char* fmt; \
|
||||
UServerPlugIn* _plugin; \
|
||||
uint32_t i = vplugin_size; \
|
||||
\
|
||||
do { \
|
||||
_plugin = vplugin->at(--i); \
|
||||
\
|
||||
if (isLog() == false) result = _plugin->handler##xxx(); \
|
||||
else \
|
||||
{ \
|
||||
UString name = vplugin_name->at(i); \
|
||||
\
|
||||
(void)u__snprintf(mod_name[0],sizeof(mod_name[0]),"[%v] ",name.rep); \
|
||||
\
|
||||
result = _plugin->handler##xxx(); \
|
||||
\
|
||||
if ((result & (U_PLUGIN_HANDLER_ERROR | \
|
||||
U_PLUGIN_HANDLER_PROCESSED)) != 0) \
|
||||
{ \
|
||||
if ((result & U_PLUGIN_HANDLER_ERROR) != 0) \
|
||||
{ \
|
||||
fmt = ((result & U_PLUGIN_HANDLER_FINISHED) != 0 \
|
||||
? 0 \
|
||||
: "%sWARNING: "#xxx" phase of plugin %v failed"); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
fmt = (U_ClientImage_parallelization == U_PARALLELIZATION_PARENT || \
|
||||
(result & U_PLUGIN_HANDLER_PROCESSED) == 0 \
|
||||
? 0 \
|
||||
: "%s"#xxx" phase of plugin %v success"); \
|
||||
} \
|
||||
\
|
||||
if (fmt) ULog::log(fmt, mod_name[0], name.rep); \
|
||||
} \
|
||||
\
|
||||
mod_name[0][0] = '\0'; \
|
||||
} \
|
||||
\
|
||||
if ((result & U_PLUGIN_HANDLER_GO_ON) == 0) U_RETURN(result); \
|
||||
\
|
||||
if (i == 0) U_RETURN(U_PLUGIN_HANDLER_FINISHED); \
|
||||
} \
|
||||
while (true); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2749,7 +2749,7 @@ int UServer_Base::handlerRead() // This method is called to accept a new connect
|
|||
|
||||
loop:
|
||||
U_INTERNAL_ASSERT_MINOR(CLIENT_INDEX, eClientImage)
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
|
||||
|
||||
CSOCKET = CLIENT_INDEX->socket;
|
||||
|
||||
|
@ -2847,7 +2847,7 @@ try_next:
|
|||
|
||||
try_accept:
|
||||
U_INTERNAL_ASSERT(CSOCKET->isClosed())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
|
||||
|
||||
if (socket->acceptClient(CSOCKET) == false)
|
||||
{
|
||||
|
@ -3064,20 +3064,28 @@ retry: pid = UProcess::waitpid(-1, &status, WNOHANG); // NB: to avoid too much
|
|||
else
|
||||
#endif
|
||||
{
|
||||
#if defined(SO_INCOMING_CPU) && defined(DEBUG)
|
||||
int cpu;
|
||||
uint32_t len = sizeof(socklen_t);
|
||||
#ifdef DEBUG
|
||||
uint32_t len = 0;
|
||||
int cpu = U_SYSCALL_NO_PARAM(sched_getcpu), scpu = -1;
|
||||
|
||||
(void) CSOCKET->getSockOpt(SOL_SOCKET, SO_INCOMING_CPU, (void*)&cpu, len);
|
||||
# ifdef SO_INCOMING_CPU
|
||||
len = sizeof(socklen_t);
|
||||
|
||||
U_INTERNAL_DUMP("cpu = %d USocket::incoming_cpu = %d", cpu, USocket::incoming_cpu)
|
||||
(void) CSOCKET->getSockOpt(SOL_SOCKET, SO_INCOMING_CPU, (void*)&scpu, len);
|
||||
|
||||
len = ((USocket::incoming_cpu == scpu || USocket::incoming_cpu == -1) ? 0 : U_CONSTANT_SIZE(" [DIFFER]"));
|
||||
# endif
|
||||
|
||||
U_INTERNAL_DUMP("USocket::incoming_cpu = %d sched cpu = %d socket cpu = %d", USocket::incoming_cpu, cpu, scpu)
|
||||
|
||||
if (len) U_DEBUG("UServer_Base::handlerRead(): CPU: %d sched(%d) socket(%d)%.*s", USocket::incoming_cpu, cpu, scpu, len, " [DIFFER]");
|
||||
#endif
|
||||
|
||||
if (CLIENT_IMAGE_HANDLER_READ == false) goto next;
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT(CSOCKET->isOpen())
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, 1) // 1 => child of parallelization
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_ClientImage_parallelization, U_PARALLELIZATION_CHILD)
|
||||
|
||||
#if defined(HAVE_EPOLL_CTL_BATCH) && !defined(USE_LIBEVENT)
|
||||
UNotifier::batch((UEventFd*)CLIENT_INDEX);
|
||||
|
@ -3415,12 +3423,12 @@ no_monitoring_process:
|
|||
UTimeVal to_sleep(0L, 500L * 1000L);
|
||||
|
||||
# if defined(HAVE_SCHED_GETAFFINITY) && !defined(U_SERVER_CAPTIVE_PORTAL)
|
||||
if (preforked_num_kids <= u_get_num_cpu() &&
|
||||
u_num_cpu > 1)
|
||||
if (u_get_num_cpu() > 1 &&
|
||||
(preforked_num_kids % u_num_cpu) == 0)
|
||||
{
|
||||
baffinity = true;
|
||||
|
||||
U_SRV_LOG("cpu affinity is to be set; thread count (%d) <= cpu count (%d)", preforked_num_kids, u_num_cpu);
|
||||
U_SRV_LOG("cpu affinity is to be set; thread count (%u) multiple of cpu count (%u)", preforked_num_kids, u_num_cpu);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
@ -3428,7 +3436,7 @@ no_monitoring_process:
|
|||
|
||||
nkids = (preforked_num_kids <= 0 ? 1 : (pid_to_wait = -1, preforked_num_kids));
|
||||
|
||||
U_INTERNAL_DUMP("nkids = %d", nkids)
|
||||
U_INTERNAL_DUMP("nkids = %u", nkids)
|
||||
|
||||
while (flag_loop)
|
||||
{
|
||||
|
@ -3455,23 +3463,27 @@ no_monitoring_process:
|
|||
# ifndef U_SERVER_CAPTIVE_PORTAL
|
||||
if (baffinity)
|
||||
{
|
||||
int cpu;
|
||||
char buffer[64];
|
||||
uint32_t sz = 0;
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
|
||||
u_bind2cpu(&cpuset, rkids); // Pin the process to a particular cpu...
|
||||
u_bind2cpu(&cpuset, rkids % u_num_cpu); // Pin the process to a particular cpu...
|
||||
|
||||
# ifdef SO_INCOMING_CPU
|
||||
USocket::incoming_cpu = rkids;
|
||||
# if !defined(U_LOG_DISABLE) || defined(HAVE_SCHED_GETCPU)
|
||||
uint32_t sz;
|
||||
char buffer[64];
|
||||
int cpu = U_SYSCALL_NO_PARAM(sched_getcpu);
|
||||
# endif
|
||||
|
||||
cpu = U_SYSCALL_NO_PARAM(sched_getcpu);
|
||||
# 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)
|
||||
if (USocket::incoming_cpu == cpu ||
|
||||
USocket::incoming_cpu == -1)
|
||||
{
|
||||
sz = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sz = u__snprintf(buffer, sizeof(buffer), " (EXPECTED CPU %d)", USocket::incoming_cpu);
|
||||
}
|
||||
|
@ -3688,7 +3700,7 @@ __pure bool UServer_Base::isParallelizationGoingToStart(uint32_t nclient)
|
|||
U_ClientImage_pipeline, U_ClientImage_parallelization, UNotifier::num_connection - UNotifier::min_connection)
|
||||
|
||||
#ifndef U_SERVER_CAPTIVE_PORTAL
|
||||
if (U_ClientImage_parallelization != 1 && // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization != U_PARALLELIZATION_CHILD &&
|
||||
(UNotifier::num_connection - UNotifier::min_connection) > nclient)
|
||||
{
|
||||
U_INTERNAL_DUMP("U_ClientImage_close = %b", U_ClientImage_close)
|
||||
|
@ -3713,7 +3725,7 @@ bool UServer_Base::startParallelization(uint32_t nclient)
|
|||
// NB: from now it is responsability of the child to services the request from the client on the same connection...
|
||||
|
||||
U_ClientImage_close = true;
|
||||
U_ClientImage_parallelization = 2; // 2 => parent of parallelization
|
||||
U_ClientImage_parallelization = U_PARALLELIZATION_PARENT;
|
||||
|
||||
UClientImage_Base::setRequestProcessed();
|
||||
|
||||
|
@ -3726,7 +3738,7 @@ bool UServer_Base::startParallelization(uint32_t nclient)
|
|||
|
||||
if (pid == 0)
|
||||
{
|
||||
U_ClientImage_parallelization = 1; // 1 => child of parallelization
|
||||
U_ClientImage_parallelization = U_PARALLELIZATION_CHILD;
|
||||
|
||||
U_ASSERT(isParallelizationChild())
|
||||
}
|
||||
|
|
|
@ -599,7 +599,9 @@ void USocket::reusePort(int _flags)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef U_COVERITY_FALSE_POSITIVE // USE_AFTER_FREE
|
||||
setFlags(_flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
void USocket::setRemote()
|
||||
|
@ -940,7 +942,7 @@ void USocket::closesocket()
|
|||
|
||||
U_INTERNAL_DUMP("U_ClientImage_parallelization = %u", U_ClientImage_parallelization)
|
||||
|
||||
if (U_ClientImage_parallelization == 1) // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization == U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
iSockDesc = -1;
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ error: U_INTERNAL_DUMP("errno = %d", errno)
|
|||
|
||||
if (errno != EAGAIN)
|
||||
{
|
||||
if (U_ClientImage_parallelization != 1) // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization != U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
if (errno != ECONNRESET &&
|
||||
sk == UServer_Base::csocket)
|
||||
|
@ -143,7 +143,7 @@ error: U_INTERNAL_DUMP("errno = %d", errno)
|
|||
{
|
||||
U_INTERNAL_DUMP("byte_read = %d errno = %d", byte_read, errno)
|
||||
|
||||
if (U_ClientImage_parallelization != 1) sk->abortive_close(); // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization != U_PARALLELIZATION_CHILD) sk->abortive_close();
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
|
|
@ -3024,8 +3024,8 @@ next: U_DUMP("UServer_Base::isParallelizationChild() = %b UServer_Base::isParall
|
|||
U_INTERNAL_DUMP("U_http_info.nResponseCode = %d UClientImage_Base::wbuffer(%u) = %V UClientImage_Base::body(%u) = %V",
|
||||
U_http_info.nResponseCode, UClientImage_Base::wbuffer->size(), UClientImage_Base::wbuffer->rep, UClientImage_Base::body->size(), UClientImage_Base::body->rep)
|
||||
|
||||
if (set_environment == false ||
|
||||
(U_ClientImage_parallelization != 2 && // 2 => parent of parallelization
|
||||
if (set_environment == false ||
|
||||
(U_ClientImage_parallelization != U_PARALLELIZATION_PARENT &&
|
||||
processCGIOutput(cgi->environment_type == U_SHELL, false)))
|
||||
{
|
||||
U_RETURN(true);
|
||||
|
@ -3101,7 +3101,7 @@ next:
|
|||
U_DUMP("UServer_Base::isParallelizationChild() = %b UServer_Base::isParallelizationParent() = %b",
|
||||
UServer_Base::isParallelizationChild(), UServer_Base::isParallelizationParent())
|
||||
|
||||
if (U_ClientImage_parallelization != 2) // 2 => parent of parallelization
|
||||
if (U_ClientImage_parallelization != U_PARALLELIZATION_PARENT)
|
||||
{
|
||||
U_INTERNAL_DUMP("U_http_info.nResponseCode = %d UClientImage_Base::wbuffer(%u) = %V UClientImage_Base::body(%u) = %V",
|
||||
U_http_info.nResponseCode, UClientImage_Base::wbuffer->size(), UClientImage_Base::wbuffer->rep, UClientImage_Base::body->size(), UClientImage_Base::body->rep)
|
||||
|
@ -3779,7 +3779,7 @@ file_in_cache:
|
|||
|
||||
usp_page->runDynamicPage(0);
|
||||
|
||||
if (U_ClientImage_parallelization != 2) setDynamicResponse(); // 2 => parent of parallelization
|
||||
if (U_ClientImage_parallelization != U_PARALLELIZATION_PARENT) setDynamicResponse();
|
||||
|
||||
U_RESET_MODULE_NAME;
|
||||
|
||||
|
@ -4226,7 +4226,7 @@ void UHTTP::setEndRequestProcessing()
|
|||
|
||||
U_INTERNAL_DUMP("U_ClientImage_parallelization = %d", U_ClientImage_parallelization)
|
||||
|
||||
if (U_ClientImage_parallelization <= 1) // 1 => child of parallelization
|
||||
if (U_ClientImage_parallelization <= U_PARALLELIZATION_CHILD)
|
||||
{
|
||||
(void) UFile::rmdir(*tmpdir, true);
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ fi
|
|||
# We need to install mongo-c-driver (we don't have a ubuntu package)
|
||||
#RETCODE=$(fw_exists ${IROOT}/mongo-c-driver.installed)
|
||||
#if [ "$RETCODE" != 0 ]; then
|
||||
fw_get -O https://github.com/mongodb/mongo-c-driver/releases/download/1.1.10/mongo-c-driver-1.1.10.tar.gz
|
||||
fw_get --ignore-content-length -O https://github.com/mongodb/mongo-c-driver/releases/download/1.1.10/mongo-c-driver-1.1.10.tar.gz
|
||||
fw_untar mongo-c-driver-1.1.10.tar.gz
|
||||
cd mongo-c-driver-1.1.10/
|
||||
./configure --prefix=$IROOT --libdir=$IROOT
|
||||
|
|
Loading…
Reference in New Issue
Block a user