Skip to content

Commit

Permalink
Fixed #7141: Services manager breaks long lines into 1023 bytes porti…
Browse files Browse the repository at this point in the history
…ons when using isc_info_svc_line in Service::query()
  • Loading branch information
AlexPeshkoff committed Mar 10, 2022
1 parent 7ee5c37 commit 462b824
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/jrd/svc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ THREAD_ENTRY_DECLARE Service::run(THREAD_ENTRY_PARAM arg)
Thread::Handle thrHandle = svc->svc_thread;
svc->svc_thread = 0;
svc->started();
svc->svc_sem_full.release();
svc->unblockQueryGet();
svc->finish(SVC_finished);

if (thrHandle)
Expand Down Expand Up @@ -2304,7 +2304,7 @@ void Service::enqueue(const UCHAR* s, ULONG len)
{
if (checkForShutdown() || (svc_flags & SVC_detached))
{
svc_sem_full.release();
unblockQueryGet();
return;
}

Expand All @@ -2316,13 +2316,13 @@ void Service::enqueue(const UCHAR* s, ULONG len)
{
if (flagFirst)
{
svc_sem_full.release();
unblockQueryGet(true);
flagFirst = false;
}
svc_sem_empty.tryEnter(1, 0);
if (checkForShutdown() || (svc_flags & SVC_detached))
{
svc_sem_full.release();
unblockQueryGet();
return;
}
}
Expand All @@ -2344,6 +2344,13 @@ void Service::enqueue(const UCHAR* s, ULONG len)
s += cnt;
len -= cnt;
}
unblockQueryGet();
}


void Service::unblockQueryGet(bool over)
{
svc_output_overflow = over;
svc_sem_full.release();
}

Expand Down Expand Up @@ -2434,8 +2441,11 @@ void Service::get(UCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, US
buffer[(*return_length)++] = ch;
}

if (!(flags & GET_LINE))
if (svc_output_overflow || !(flags & GET_LINE))
{
svc_output_overflow = false;
svc_stdout_head = head;
}
}

if (flags & GET_LINE)
Expand Down Expand Up @@ -2534,7 +2544,7 @@ ULONG Service::getBytes(UCHAR* buffer, ULONG size)
svc_stdin_size_requested = size;
svc_stdin_buffer = buffer;
// Wakeup Service::query() if it waits for data from service
svc_sem_full.release();
unblockQueryGet();
}

// Wait for data from client
Expand Down Expand Up @@ -2574,7 +2584,7 @@ void Service::finish(USHORT flag)

if (svc_flags & SVC_finished)
{
svc_sem_full.release();
unblockQueryGet();
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/jrd/svc.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ class Service : public Firebird::UtilSvc, public TypedHandle<type_svc>

private:
Firebird::Semaphore svc_sem_empty, svc_sem_full;
bool svc_output_overflow;

void unblockQueryGet(bool over = false);

class Validate
{
Expand Down

0 comments on commit 462b824

Please sign in to comment.