Skip to content

Commit bc5f036

Browse files
cpowerscpowers
cpowers
authored and
cpowers
committed
WL#4896 "Performance Schema Net IO"
Miscellaneous crash-proofing
1 parent 5e875ff commit bc5f036

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

storage/perfschema/pfs.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4727,8 +4727,11 @@ static void set_socket_info_v1(PSI_socket *socket,
47274727

47284728
/** Set socket thread owner */
47294729
PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
4730+
47304731
if (thread)
47314732
pfs->m_thread_owner= thread;
4733+
else
4734+
pfs->m_thread_owner= NULL;
47324735

47334736
/** Set socket descriptor */
47344737
if (fd != NULL)

storage/perfschema/pfs_instr.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,7 @@ PFS_socket* create_socket(PFS_socket_class *klass, const void *identity)
14031403
pfs->m_idle= false;
14041404
pfs->m_socket_stat.reset();
14051405
pfs->m_lock.dirty_to_allocated();
1406+
pfs->m_thread_owner= NULL;
14061407
if (klass->is_singleton())
14071408
klass->m_singleton= pfs;
14081409
return pfs;
@@ -1435,11 +1436,14 @@ void destroy_socket(PFS_socket *pfs)
14351436

14361437
/* Aggregate to SOCKET_SUMMARY_BY_INSTANCE and BY_EVENT_NAME */
14371438
klass->m_socket_stat.m_io_stat.aggregate(&pfs->m_socket_stat.m_io_stat);
1438-
pfs->m_socket_stat.m_io_stat.reset();
1439+
pfs->m_socket_stat.reset();
14391440

14401441
if (klass->is_singleton())
14411442
klass->m_singleton= NULL;
14421443

1444+
pfs->m_thread_owner= NULL;
1445+
pfs->m_fd= 0;
1446+
pfs->m_addr_len= 0;
14431447
pfs->m_lock.allocated_to_free();
14441448
}
14451449

storage/perfschema/pfs_visitor.cc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,8 @@ void PFS_instance_iterator::visit_socket_instances(PFS_socket_class *klass,
232232
PFS_socket *pfs= sanitize_socket(klass->m_singleton);
233233
if (likely(pfs != NULL))
234234
{
235-
if (likely(pfs->m_lock.is_populated())
236-
&& pfs->m_thread_owner != NULL)
237-
{
238-
if (pfs->m_thread_owner == thread)
239-
visitor->visit_socket(pfs);
240-
}
235+
if (unlikely(pfs->m_thread_owner == thread))
236+
visitor->visit_socket(pfs);
241237
}
242238
}
243239
else
@@ -248,11 +244,10 @@ void PFS_instance_iterator::visit_socket_instances(PFS_socket_class *klass,
248244

249245
for ( ; pfs < pfs_last; pfs++)
250246
{
251-
if (pfs->m_class == klass && pfs->m_lock.is_populated()
252-
&& pfs->m_thread_owner != NULL)
247+
if (unlikely((pfs->m_class == klass) &&
248+
(pfs->m_thread_owner == thread)))
253249
{
254-
if (pfs->m_thread_owner == thread)
255-
visitor->visit_socket(pfs);
250+
visitor->visit_socket(pfs);
256251
}
257252
}
258253
}

0 commit comments

Comments
 (0)