grininmonkey
Posts: 92
Joined: Mon Jul 30, 2018 3:44 pm

Mysql and Pthread

Thu Nov 08, 2018 6:51 pm

So I initially setup the beginnings of querying mysql and updating some elements in my little project.... and I had no mem leaks reported by valgrind ...

I then setup a pthread as a timer to act as an interval to query and update ... etc.. and when the mysql query func is called via a path initiated from a thread... it has mem leaks.... but when the exact same func is called outside of a thread... no mem leaks....

Is there specific things I should do when defining a mysql query that will be used within a thread? Appears to impact host name resolution piece within the mysql library.

Code: Select all

==11102== 142 bytes in 1 blocks are definitely lost in loss record 10 of 19
==11102==    at 0x483777F: malloc (vg_replace_malloc.c:299)
==11102==    by 0x56A60D5: __libc_alloc_buffer_allocate (in /usr/lib/libc-2.28.so)
==11102==    by 0x573ACF9: __resolv_conf_allocate (in /usr/lib/libc-2.28.so)
==11102==    by 0x57386AB: __resolv_conf_load (in /usr/lib/libc-2.28.so)
==11102==    by 0x573A9CE: __resolv_conf_get_current (in /usr/lib/libc-2.28.so)
==11102==    by 0x573932C: __res_vinit (in /usr/lib/libc-2.28.so)
==11102==    by 0x573A2BA: context_get.part.1 (in /usr/lib/libc-2.28.so)
==11102==    by 0x5701B54: gaih_inet.constprop.7 (in /usr/lib/libc-2.28.so)
==11102==    by 0x5703037: getaddrinfo (in /usr/lib/libc-2.28.so)
==11102==    by 0x4F32D6B: mysql_real_connect (in /usr/lib/libmysqlclient.so.18.0.0)
==11102==    by 0x10BBFC: thermsettings_update (thermsettings.c:66)
==11102==    by 0x10DCC2: events_timer (events.c:37)
=

grininmonkey
Posts: 92
Joined: Mon Jul 30, 2018 3:44 pm

Re: Mysql and Pthread

Thu Nov 08, 2018 8:36 pm

Ahhh.... found it....

calling mysql_thread_end() before pthread_exit() within the thread func seems to have resolved it....

Return to “C/C++”