Motion - Bug Report 2010x 11x 22x 033859
You are here: Foswiki>Motion Web>BugReports>BugReport2010x11x22x033859 (03 Jun 2012, AngelCarpintero)Edit Attach

BUG: No mysql_close

Recently I started using Motion with MySQL and a Wireless Camera. The issue with the wireless camera it cuts out here and there and it causes Motion to restart its connection to an AXIS 2400. Not a big deal but after about a day or two all my programs were reporting that they were running out connections to the MySQL server. When I started to investigate this I found over a hundred zombie connections from Motion.

A quick grep over the Motion code shows that it never closes the original MySQL connection. Motion I assume creates a new connection each time it restarts its connection to my camera.

As a quick fix, I added a “mysql_close(cnt->database);” right before the statement to create a new connection and also in the clean up function.

Below is a diff of what I added and has been working well for me so far.
XXXX@XXXX:/usr/local/src/motion-3.2.12# diff motion.c ../motion.c 
669,670d668 
< //Richard 
< mysql_close(cnt->database); 
879,883d876 
< #ifdef HAVE_MYSQL 
< if (cnt->conf.mysql_db) { 
< mysql_close(cnt->database); 
< } < #endif 
/* HAVE_MYSQL */ 
XXXX@XXXX:/usr/local/src/motion-3.2.12#

Other then this, Motion works great! Thanks for the program. Hopefully this small fix helps someone else out there.

Paste in your error messages, config settings, terminal window output etc in this text field.

Environment

Motion version: 3.2.12
ffmpeg version:  
Shared libraries: ffmpeg, mysql, postgresql
Server OS:  
-- RichardA - 22 Nov 2010

Follow up

Fix record

Richard you are totally right , motion never close DB connection ...WTF !

I'll commit to 3.2 branch and trunk

Thanks !

-- AngelCarpintero - 05 Dec 2010


I have made a more format patch adding also in event.c

You can see attached , i will commit everything adding your name in CREDITS and CHANGELOG files.

Thanks !

-- AngelCarpintero - 05 Dec 2010
Topic revision: r3 - 03 Jun 2012, AngelCarpintero
Copyright © 1999-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.