Tom Van Braeckel
Thu, 04 Feb 2010 02:43:43 -0800
Hi guys, Here's another patch - my first *code* patch to GnuCash !
Rationale: When we try to open a database transaction, and the database reports that the "server has gone away", we try to reconnect before failing hard. I've also attached it to the bug report, and taken the liberty to add myself to the AUTHORS file. I hope that's customary here, and I apologise if it's not... Thanks again for this great software, Tom Van Braeckel GSM: 0032 (0) 486 63 58 04
Index: AUTHORS
===================================================================
--- AUTHORS (revision 18610)
+++ AUTHORS (working copy)
@@ -113,6 +113,7 @@
Terry Boldt <tbo...@attglobal.net> financial calculator and expression parser
Forest Bond <for...@alittletooquiet.net> Budget report improvements
Richard Braakman <d...@xs4all.nl> xml version configure patch
+Tom Van Braeckel <tomvanbraec...@gmail.com> MySQL timeout reconnect patch
Simon Britnell <simon.britn...@peace.com> patch to RPM spec
Christopher B. Browne <cbbro...@hex.net> for perl, lots of scheme and documentation updates
Nathan Buchanan <nbin...@yahoo.ca> packaging Windows binaries for release
Index: src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- src/backend/dbi/gnc-backend-dbi.c (revision 18610)
+++ src/backend/dbi/gnc-backend-dbi.c (working copy)
@@ -1377,6 +1377,18 @@
DEBUG( "BEGIN\n" );
result = dbi_conn_queryf( dbi_conn->conn, "BEGIN" );
+
+ /* Handle MySQL connection timeouts with reconnect */
+ if (result == NULL) {
+ const gchar* msg;
+ (void)dbi_conn_error( dbi_conn->conn, &msg );
+ if( g_str_has_prefix( msg, "2006: MySQL server has gone away" ) ) {
+ DEBUG( "MySQL server has gone away, reconnecting and retrying...\n" );
+ (void)dbi_conn_connect( dbi_conn->conn );
+ result = dbi_conn_queryf( dbi_conn->conn, "BEGIN" );
+ }
+ }
+
status = dbi_result_free( result );
if( status < 0 ) {
PERR( "Error in dbi_result_free() result\n" );
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel