mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
add snprintf_pos
This commit is contained in:
parent
bb6141d4fc
commit
af7ea4e027
|
@ -2290,6 +2290,25 @@ public:
|
|||
va_end(argp);
|
||||
}
|
||||
|
||||
void snprintf_pos(uint32_t pos, const char* format, uint32_t fmt_size, ...)
|
||||
{
|
||||
U_TRACE(0, "UString::snprintf_pos(%u,%.*S,%u)", pos, fmt_size, format, fmt_size)
|
||||
|
||||
U_INTERNAL_ASSERT_POINTER(format)
|
||||
U_INTERNAL_ASSERT(pos <= rep->_length)
|
||||
|
||||
va_list argp;
|
||||
va_start(argp, fmt_size);
|
||||
|
||||
rep->_length = pos + u__vsnprintf(c_pointer(pos), rep->_capacity+1-pos, format, fmt_size, argp); // NB: +1 because we want space for null-terminator...
|
||||
|
||||
U_INTERNAL_DUMP("ret = %u buffer_size = %u", rep->_length, rep->_capacity+1-pos)
|
||||
|
||||
U_INTERNAL_ASSERT(invariant())
|
||||
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
void size_adjust() { rep->size_adjust(); }
|
||||
void size_adjust(uint32_t value) { rep->size_adjust(value); }
|
||||
void size_adjust(const char* ptr) { rep->size_adjust(ptr); }
|
||||
|
|
|
@ -458,6 +458,8 @@ void UClientImage_Base::handlerDelete()
|
|||
|
||||
bool bsocket_open = isOpen();
|
||||
|
||||
U_INTERNAL_DUMP("bsocket_open = %b", bsocket_open)
|
||||
|
||||
#if !defined(USE_LIBEVENT) && defined(HAVE_EPOLL_WAIT) && defined(DEBUG)
|
||||
if (UNLIKELY(UNotifier::num_connection <= UNotifier::min_connection))
|
||||
{
|
||||
|
@ -475,15 +477,7 @@ void UClientImage_Base::handlerDelete()
|
|||
|
||||
bool bdelete = (U_ClientImage_state == U_NOTIFY_DELETE);
|
||||
|
||||
U_INTERNAL_DUMP("U_ClientImage_state = %d %B bdelete = %b bsocket_open = %b", U_ClientImage_state, U_ClientImage_state, bdelete, bsocket_open)
|
||||
|
||||
if (bdelete &&
|
||||
bsocket_open)
|
||||
{
|
||||
socket->close();
|
||||
|
||||
bsocket_open = false;
|
||||
}
|
||||
U_INTERNAL_DUMP("U_ClientImage_state = %d %B bdelete = %b", U_ClientImage_state, U_ClientImage_state, bdelete)
|
||||
|
||||
#ifndef U_LOG_DISABLE
|
||||
if (UServer_Base::isLog())
|
||||
|
@ -526,6 +520,14 @@ void UClientImage_Base::handlerDelete()
|
|||
if (UServer_Base::isClassic()) U_EXIT(0);
|
||||
#endif
|
||||
|
||||
if (bdelete &&
|
||||
bsocket_open)
|
||||
{
|
||||
socket->close();
|
||||
|
||||
bsocket_open = false;
|
||||
}
|
||||
|
||||
U_INTERNAL_DUMP("U_ClientImage_http = %C U_http_version = %C", U_ClientImage_http(this), U_http_version)
|
||||
|
||||
#ifndef U_HTTP2_DISABLE
|
||||
|
@ -535,12 +537,16 @@ void UClientImage_Base::handlerDelete()
|
|||
#ifndef U_WEBSOCKET_PARALLELIZATION
|
||||
if (U_ClientImage_http(this) == '0')
|
||||
{
|
||||
if (bsocket_open) (void) UWebSocket::sendClose(socket);
|
||||
if (bsocket_open &&
|
||||
UWebSocket::sendClose(socket))
|
||||
{
|
||||
socket->close();
|
||||
}
|
||||
|
||||
UWebSocket::on_message_param(U_DPAGE_CLOSE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
if (bsocket_open) socket->close();
|
||||
|
||||
--UNotifier::num_connection;
|
||||
|
|
|
@ -1 +1 @@
|
|||
0470
|
||||
048A
|
||||
|
|
Loading…
Reference in New Issue
Block a user