3737
3838#include < atomic>
3939#include < mutex>
40- #include < vector>
4140
4241#ifdef WIN_NT
4342#include < process.h>
@@ -184,7 +183,7 @@ class Jrd::ProfilerListener final
184183 listener->watcherThread ();
185184 }
186185
187- void processCommand (thread_db* tdbb, ProfilerIpc::Tag tag, std::vector<UCHAR> & buffer);
186+ void processCommand (thread_db* tdbb, ProfilerIpc::Tag tag, UCharBuffer & buffer);
188187
189188private:
190189 Attachment* const attachment;
@@ -1002,7 +1001,7 @@ void ProfilerListener::watcherThread()
10021001 {
10031002 ProfilerIpc::Tag tag;
10041003 unsigned seq;
1005- std::vector<UCHAR> buffer;
1004+ UCharBuffer buffer;
10061005
10071006 fb_assert (header->tag >= ProfilerIpc::Tag::FIRST_CLIENT_OP);
10081007
@@ -1021,8 +1020,7 @@ void ProfilerListener::watcherThread()
10211020
10221021 tag = header->tag ;
10231022 seq = header->seq ;
1024- buffer.resize (header->bufferSize );
1025- memcpy (buffer.data (), header->buffer , header->bufferSize );
1023+ memcpy (buffer.getBuffer (header->bufferSize , false ), header->buffer , header->bufferSize );
10261024 }
10271025
10281026 processCommand (tdbb, tag, buffer);
@@ -1051,7 +1049,7 @@ void ProfilerListener::watcherThread()
10511049 memcpy (header->buffer , errorMsg.c_str (), header->bufferSize );
10521050 }
10531051
1054- fb_assert (buffer.size () <= sizeof (header->buffer ));
1052+ fb_assert (buffer.getCount () <= sizeof (header->buffer ));
10551053
10561054 { // scope
10571055 std::unique_lock bufferMutexLock (header->bufferMutex , std::try_to_lock);
@@ -1062,8 +1060,8 @@ void ProfilerListener::watcherThread()
10621060 if (header->seq == seq)
10631061 {
10641062 header->tag = tag;
1065- header->bufferSize = buffer.size ();
1066- memcpy (header->buffer , buffer.data (), buffer.size ());
1063+ header->bufferSize = buffer.getCount ();
1064+ memcpy (header->buffer , buffer.begin (), buffer.getCount ());
10671065
10681066 sharedMemory->eventPost (&header->clientEvent );
10691067 }
@@ -1105,7 +1103,7 @@ void ProfilerListener::watcherThread()
11051103 }
11061104}
11071105
1108- void ProfilerListener::processCommand (thread_db* tdbb, ProfilerIpc::Tag tag, std::vector<UCHAR> & buffer)
1106+ void ProfilerListener::processCommand (thread_db* tdbb, ProfilerIpc::Tag tag, UCharBuffer & buffer)
11091107{
11101108 const auto profilerManager = attachment->getProfilerManager (tdbb);
11111109
@@ -1114,21 +1112,21 @@ void ProfilerListener::processCommand(thread_db* tdbb, ProfilerIpc::Tag tag, std
11141112 switch (tag)
11151113 {
11161114 case Tag::CANCEL_SESSION:
1117- fb_assert (buffer.empty ());
1115+ fb_assert (buffer.isEmpty ());
11181116 profilerManager->cancelSession ();
11191117 buffer.resize (0 );
11201118 break ;
11211119
11221120 case Tag::DISCARD:
1123- fb_assert (buffer.empty ());
1121+ fb_assert (buffer.isEmpty ());
11241122 profilerManager->discard ();
11251123 buffer.resize (0 );
11261124 break ;
11271125
11281126 case Tag::FINISH_SESSION:
11291127 {
1130- const auto in = reinterpret_cast <const ProfilerPackage::FinishSessionInput::Type*>(buffer.data ());
1131- fb_assert (sizeof (*in) == buffer.size ());
1128+ const auto in = reinterpret_cast <const ProfilerPackage::FinishSessionInput::Type*>(buffer.begin ());
1129+ fb_assert (sizeof (*in) == buffer.getCount ());
11321130
11331131 profilerManager->finishSession (tdbb, in->flush );
11341132
@@ -1137,15 +1135,15 @@ void ProfilerListener::processCommand(thread_db* tdbb, ProfilerIpc::Tag tag, std
11371135 }
11381136
11391137 case Tag::FLUSH:
1140- fb_assert (buffer.empty ());
1138+ fb_assert (buffer.isEmpty ());
11411139 profilerManager->flush ();
11421140 buffer.resize (0 );
11431141 break ;
11441142
11451143 case Tag::PAUSE_SESSION:
11461144 {
1147- const auto in = reinterpret_cast <const ProfilerPackage::PauseSessionInput::Type*>(buffer.data ());
1148- fb_assert (sizeof (*in) == buffer.size ());
1145+ const auto in = reinterpret_cast <const ProfilerPackage::PauseSessionInput::Type*>(buffer.begin ());
1146+ fb_assert (sizeof (*in) == buffer.getCount ());
11491147
11501148 profilerManager->pauseSession (in->flush );
11511149
@@ -1154,15 +1152,15 @@ void ProfilerListener::processCommand(thread_db* tdbb, ProfilerIpc::Tag tag, std
11541152 }
11551153
11561154 case Tag::RESUME_SESSION:
1157- fb_assert (buffer.empty ());
1155+ fb_assert (buffer.isEmpty ());
11581156 profilerManager->resumeSession ();
11591157 buffer.resize (0 );
11601158 break ;
11611159
11621160 case Tag::SET_FLUSH_INTERVAL:
11631161 {
1164- const auto in = reinterpret_cast <const ProfilerPackage::SetFlushIntervalInput::Type*>(buffer.data ());
1165- fb_assert (sizeof (*in) == buffer.size ());
1162+ const auto in = reinterpret_cast <const ProfilerPackage::SetFlushIntervalInput::Type*>(buffer.begin ());
1163+ fb_assert (sizeof (*in) == buffer.getCount ());
11661164
11671165 profilerManager->setFlushInterval (in->flushInterval );
11681166
@@ -1172,8 +1170,8 @@ void ProfilerListener::processCommand(thread_db* tdbb, ProfilerIpc::Tag tag, std
11721170
11731171 case Tag::START_SESSION:
11741172 {
1175- const auto in = reinterpret_cast <const ProfilerPackage::StartSessionInput::Type*>(buffer.data ());
1176- fb_assert (sizeof (*in) == buffer.size ());
1173+ const auto in = reinterpret_cast <const ProfilerPackage::StartSessionInput::Type*>(buffer.begin ());
1174+ fb_assert (sizeof (*in) == buffer.getCount ());
11771175
11781176 const string description (in->description .str ,
11791177 in->descriptionNull ? 0 : in->description .length );
@@ -1184,7 +1182,7 @@ void ProfilerListener::processCommand(thread_db* tdbb, ProfilerIpc::Tag tag, std
11841182 const string pluginOptions (in->pluginOptions .str ,
11851183 in->pluginOptionsNull ? 0 : in->pluginOptions .length );
11861184
1187- const auto out = reinterpret_cast <ProfilerPackage::StartSessionOutput::Type*>(buffer.data ());
1185+ const auto out = reinterpret_cast <ProfilerPackage::StartSessionOutput::Type*>(buffer.begin ());
11881186 buffer.resize (sizeof (*out));
11891187
11901188 out->sessionIdNull = FB_FALSE;
0 commit comments