8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-02 10:40:38 +01:00

Fixed CORE-5203: Single CPU core fully utilized with Trace session

This commit is contained in:
Alexander Peshkov 2016-04-21 20:34:51 +03:00
parent 5463e3cd77
commit 1184d3e263
2 changed files with 19 additions and 8 deletions

View File

@ -2129,9 +2129,14 @@ void Service::readFbLog()
svc_started = true;
TEXT buffer[100];
setDataMode(true);
int n;
while (fgets(buffer, sizeof(buffer), file))
outputData(buffer, fb_strlen(buffer));
while ((n = fread(buffer, sizeof(buffer[0]), FB_NELEM(buffer), file)) > 0)
{
outputData(buffer, n);
if (checkForShutdown())
break;
}
setDataMode(false);
}
@ -2186,9 +2191,9 @@ ULONG Service::add_val(ULONG i, ULONG val)
}
bool Service::empty() const
bool Service::empty(ULONG head) const
{
return svc_stdout_tail == svc_stdout_head;
return svc_stdout_tail == head;
}
@ -2264,12 +2269,12 @@ void Service::get(UCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, US
while (length)
{
if ((empty() && (svc_flags & SVC_finished)) || checkForShutdown())
if ((empty(head) && (svc_flags & SVC_finished)) || checkForShutdown())
{
break;
}
if (empty())
if (empty(head))
{
if (svc_stdin_size_requested && (!(flags & GET_BINARY)))
{
@ -2288,6 +2293,12 @@ void Service::get(UCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, US
break;
}
if (full())
{
// buffer is full but LF is not present in it
break;
}
UnlockGuard guard(this, FB_FUNCTION);
svc_sem_full.tryEnter(1, 0);
if (!guard.enter())
@ -2307,7 +2318,7 @@ void Service::get(UCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, US
break;
}
while (head != svc_stdout_tail && length > 0)
while ((!empty(head)) && length > 0)
{
flagFirst = true;
const UCHAR ch = svc_stdout[head];

View File

@ -215,7 +215,7 @@ private:
// Put data into stdout buffer
void enqueue(const UCHAR* s, ULONG len);
// true if there is no data in stdout buffer
bool empty() const;
bool empty(ULONG head) const;
// true if no more space in stdout buffer
bool full() const;
// start service thread