Skip to content

Commit f59905f

Browse files
committed
Frontported PR #8186 : Fixed a few issues with IPC used by remote profiler
1 parent 85b18b8 commit f59905f

File tree

7 files changed

+208
-62
lines changed

7 files changed

+208
-62
lines changed

src/common/isc_s_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct mtx
7373
struct event_t
7474
{
7575
SLONG event_count;
76-
int pid;
76+
int event_pid;
7777
pthread_mutex_t event_mutex[1];
7878
pthread_cond_t event_cond[1];
7979
};

src/common/isc_sync.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ int SharedMemoryBase::eventInit(event_t* event)
611611
#else // pthread-based event
612612

613613
event->event_count = 0;
614-
event->pid = getpid();
614+
event->event_pid = getpid();
615615

616616
// Prepare an Inter-Process event block
617617
pthread_mutexattr_t mattr;
@@ -662,7 +662,7 @@ void SharedMemoryBase::eventFini(event_t* event)
662662

663663
#else // pthread-based event
664664

665-
if (event->pid == getpid())
665+
if (event->event_pid == getpid())
666666
{
667667
LOG_PTHREAD_ERROR(pthread_mutex_destroy(event->event_mutex));
668668
LOG_PTHREAD_ERROR(pthread_cond_destroy(event->event_cond));
@@ -691,6 +691,8 @@ SLONG SharedMemoryBase::eventClear(event_t* event)
691691
*
692692
**************************************/
693693

694+
fb_assert(event->event_pid == getpid());
695+
694696
#if defined(WIN_NT)
695697

696698
ResetEvent(event->event_handle);
@@ -722,6 +724,8 @@ int SharedMemoryBase::eventWait(event_t* event, const SLONG value, const SLONG m
722724
*
723725
**************************************/
724726

727+
fb_assert(event->event_pid == getpid());
728+
725729
// If we're not blocked, the rest is a gross waste of time
726730

727731
if (!event_blocked(event, value)) {
@@ -831,7 +835,7 @@ int SharedMemoryBase::eventPost(event_t* event)
831835
++event->event_count;
832836

833837
if (event->event_pid != process_id)
834-
return ISC_kill(event->event_pid, event->event_id, event->event_handle);
838+
return ISC_kill(event->event_pid, event->event_id, event->event_handle) == 0 ? FB_SUCCESS : FB_FAILURE;
835839

836840
return SetEvent(event->event_handle) ? FB_SUCCESS : FB_FAILURE;
837841

src/jrd/Attachment.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,16 @@ bool Attachment::isProfilerActive()
12071207
return att_profiler_manager && att_profiler_manager->isActive();
12081208
}
12091209

1210-
void Attachment::releaseProfilerManager()
1210+
void Attachment::releaseProfilerManager(thread_db* tdbb)
12111211
{
1212-
att_profiler_manager.reset();
1212+
if (!att_profiler_manager)
1213+
return;
1214+
1215+
if (att_profiler_manager->haveListener())
1216+
{
1217+
EngineCheckout cout(tdbb, FB_FUNCTION);
1218+
att_profiler_manager.reset();
1219+
}
1220+
else
1221+
att_profiler_manager.reset();
12131222
}

src/jrd/Attachment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ class Attachment : public pool_alloc<type_att>
847847
ProfilerManager* getProfilerManager(thread_db* tdbb);
848848
ProfilerManager* getActiveProfilerManagerForNonInternalStatement(thread_db* tdbb);
849849
bool isProfilerActive();
850-
void releaseProfilerManager();
850+
void releaseProfilerManager(thread_db* tdbb);
851851

852852
JProvider* getProvider()
853853
{

0 commit comments

Comments
 (0)