Hello Max, Thanks but it should not have been broken to begin with. I made SQLite email list suggested changes (which did work) by adding resets after every execution of prepared statements to prevent "hanging" statements and tested it with adding new users with a couple of constant find_users() running interference. I should have tested the workplace logic again.
It won't happen again boss! Thanks, John --- On Tue, 6/7/11, Max Bossino <m...@miragroupware.org> wrote: > From: Max Bossino <m...@miragroupware.org> > Subject: Re: [Mira-development] [Branch ~mira-dev/mira/dbBackEnd] Rev 227: > Fixed problem with creating and subscribing to workplaces. > To: "Mira Development Mailing List" <mira-development@lists.sourceforge.net> > Date: Tuesday, June 7, 2011, 4:13 PM > Hi John, > > Great work with this fix. I can't replicate the Server's > Segfault when trying to join a Workplace that doesn't > exist. > > Regards, > > Max > > On 6 Jun 2011, at 03:31, nore...@launchpad.net > wrote: > > > > ------------------------------------------------------------ > > revno: 227 > > committer: John Deal <bassd...@yahoo.com> > > branch nick: dbBackEnd > > timestamp: Sun 2011-06-05 22:30:14 -0400 > > message: > > Fixed problem with creating and subscribing to > workplaces. > > modified: > > > mira-server/src/directory/db/sqlite/DbSqliteDirectory.cpp > > > > > > -- > > lp:~mira-dev/mira/dbBackEnd > > https://code.launchpad.net/~mira-dev/mira/dbBackEnd > > > > You are subscribed to branch > lp:~mira-dev/mira/dbBackEnd. > > To unsubscribe from this branch go to > > https://code.launchpad.net/~mira-dev/mira/dbBackEnd/+edit-subscription > > === modified file > 'mira-server/src/directory/db/sqlite/DbSqliteDirectory.cpp' > > --- > mira-server/src/directory/db/sqlite/DbSqliteDirectory.cpp > 2011-05-31 14:00:52 +0000 > > +++ > mira-server/src/directory/db/sqlite/DbSqliteDirectory.cpp > 2011-06-06 02:30:14 +0000 > > @@ -340,7 +340,7 @@ > > > continue; > > } > > > > - if ((current_size == 0) > || (current_size < count)) > > + if ((current_size == 0) > || (current_size <= count)) > > { // Anything > still in target_list should be added. > > > add_list.push_back(*target_itr); > > > target_itr++; > > @@ -460,6 +460,7 @@ > > const std::string& > workplace_name) > > { > > int > error_code; > > + unsigned int > return_id; > > Field > work_field; > > std::string > work_string; > > SubscriptionList > work_subscription_list; > > @@ -493,8 +494,9 @@ > > return (unsigned > int) 0; > > } > > > > + return_id = (unsigned int) > sqlite3_column_int64(m_prep_get_workplace_id, 0); > > > sqlite3_reset(m_prep_get_workplace_id); > > - return (unsigned int) > sqlite3_column_int64(m_prep_get_workplace_id, 0); > > + return return_id; > > } > > > > bool DbSqliteDirectory::beginTransaction(const > std::string& moduleName) > > @@ -1638,21 +1640,12 @@ > > return false; > > } > > > > - if (error_code != SQLITE_DONE) > > - { // Begin transaction failed. > > - cout << "Error > (DbSqliteDirectory::add_workplace): Begin of transaction > failed. Error Code: " > > - << > error_code << " Message: " << > sqlite3_errmsg(m_db) << endl; > > - > sqlite3_reset(m_prep_begin_transaction_exclusive); > > - return false; > > - } > > - > > -// Add the workplace to the DB. > > + // Add the workplace to the DB. > > error_code = > sqlite3_step(m_prep_put_workplace); > > > > if (error_code != > SQLITE_DONE) > > { // Insert failed. > > - cout << "Error > (DbSqliteDirectory::add_workplace): Insert of workplace '" > << > > - > workplace.get_name() << "' failed. Error Code: " > > + cout << "Error > (DbSqliteDirectory::add_workplace): Insert of workplace > '" << > workplace.get_name() << "' failed. Error Code: " > > > << error_code << " Message: " > << sqlite3_errmsg(m_db) << endl; > > > > // Note: > No rollback since 1st insert failed. > > @@ -1661,6 +1654,20 @@ > > return false; > > } > > > > + if > (commitTransaction(m_max_commit_tries, > > + > "DbSqliteDirectory::add_workplace") == false) > > + { // Commit failed. > > + // Rollback the failed > transaction. Note may automatically be rolled > > + // back and return error > if done expecitly so return not checked. > > + > sqlite3_reset(m_prep_rollback_transaction); > > + > sqlite3_step(m_prep_rollback_transaction); > > + > > + // Reset other used > prepared statements. > > + > sqlite3_reset(m_prep_begin_transaction_exclusive); > > + > sqlite3_reset(m_prep_put_workplace); > > + return false; // > Something seriously wrong. > > + } > > + > > // Now must add workplace > subscription list. > > work_id = > get_workplace_id(workplace.get_name()); > > > > @@ -1668,18 +1675,6 @@ > > { // Could not find workplace > just added! > > cout << > "Error (DbSqliteDirectonary::add_workplace): Can not > retrieve workplace: " << > > > workplace.get_name() << ". > Adding subscriptions failed." << endl; > > - > > - error_code = > sqlite3_step(m_prep_rollback_transaction); > > - > > - if (error_code != > SQLITE_DONE) > > - { // Rollback of > transaction failed. > > - cout > << "Error (DbSqliteDirectory::add_workplace): Rollback > of transaction failed. Error Code: " > > - > << error_code << " Message: " << > sqlite3_errmsg(m_db) << endl; > > - } > > - > > - > sqlite3_reset(m_prep_rollback_transaction); > > - > sqlite3_reset(m_prep_put_workplace); > > - > sqlite3_reset(m_prep_begin_transaction_exclusive); > > return false; // > Transaction failed and rolled back (hopefully). > > } > > > > @@ -1698,19 +1693,13 @@ > > > workplace.get_name() << "' failed. > Subscribed user ID: " << > > > *flItr << " invalid. Update > aborted." << endl; > > > > - // Rollback > transaction. > > - > sqlite3_reset(m_prep_rollback_transaction); > > - error_code > = sqlite3_step(m_prep_rollback_transaction); > > + return > false; > > + } > > > > - if > (error_code != SQLITE_DONE) > > - { // > Rollback failed. Punt! > > - > cout << "Error > (DbSqliteDirectory::add_workplace): Rollback of transaction > failed. Error Code: " << > > - > error_code << " Message: " > << sqlite3_errmsg(m_db) << endl; > > - > sqlite3_reset(m_prep_rollback_transaction); > > - > sqlite3_reset(m_prep_put_workplace); > > - > sqlite3_reset(m_prep_begin_transaction_exclusive); > > - > return false; // Something seriously wrong. > > - } > > + // BEGIN TRANSACTION > > + if > (beginTransaction("DbSqliteDirectory::add_workplace") == > false) > > + { // Start of transaction > failed. > > + return > false; > > } > > > > if > (add_subscription(work_id, work_user.get_id()) == false) > > @@ -1734,23 +1723,23 @@ > > > sqlite3_reset(m_prep_begin_transaction_exclusive); > > > return false; > > } > > + > > + // END TRANSACTION. > > + if > (commitTransaction(m_max_commit_tries, > > + > "DbSqliteDirectory::add_workplace") == false) > > + { // Commit failed. > > + // Rollback > the failed transaction. May automatically be rolled > > + // back and > return error if done expecitly so return not checked. > > + > sqlite3_reset(m_prep_rollback_transaction); > > + > sqlite3_step(m_prep_rollback_transaction); > > + > > + // Reset > other used prepared statements. > > + > sqlite3_reset(m_prep_begin_transaction_exclusive); > > + > sqlite3_reset(m_prep_put_workplace); > > + return > false; // Something seriously wrong. > > + } > > } // End for flItr != > work_field.value_list.end(). > > > > - // END TRANSACTION. > > - if > (commitTransaction(m_max_commit_tries, > > - > "DbSqliteDirectory::add_workplace") == false) > > - { // Commit failed. > > - // Rollback the failed > transaction. Note may automatically be rolled > > - // back and return error > if done expecitly so return not checked. > > - > sqlite3_reset(m_prep_rollback_transaction); > > - > sqlite3_step(m_prep_rollback_transaction); > > - > > - // Reset other used > prepared statements. > > - > sqlite3_reset(m_prep_begin_transaction_exclusive); > > - > sqlite3_reset(m_prep_put_workplace); > > - return false; // > Something seriously wrong. > > - } > > - > > > sqlite3_reset(m_prep_put_workplace); > > > sqlite3_reset(m_prep_begin_transaction_exclusive); > > return true; > > @@ -1791,6 +1780,9 @@ > > > cout << "Error > (DbSqliteDirectory::find_workplace: Error retrieving > workplace record. Error Code: " > > > << error_code << " Message: " > << sqlite3_errmsg(m_db) << endl; > > } > > + > > + workplace.set_invalid(); > > + return workplace; > > } > > > > try > > @@ -2191,9 +2183,6 @@ > > } // End if subscribtions to > add or delete. > > > > // Things look good so commit > the transaction. > > - > sqlite3_reset(m_prep_commit_transaction); > > - error_code = > sqlite3_step(m_prep_commit_transaction); > > - > > if > (commitTransaction(m_max_commit_tries, > > > "DbSqliteDirectory::update_workplace") == > false) > > { > > > > > ------------------------------------------------------------------------------ > > Simplify data backup and recovery for your virtual > environment with vRanger. > > Installation's a snap, and flexible recovery options > mean your data is safe, > > secure and there when you need it. Discover what all > the cheering's about. > > Get your free trial download today. > > http://p.sf.net/sfu/quest-dev2dev2 > _______________________________________________ > > Mira-development mailing list > > Mira-development@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/mira-development > > > ------------------------------------------------------------------------------ > EditLive Enterprise is the world's most technically > advanced content > authoring tool. Experience the power of Track Changes, > Inline Image > Editing and ensure content is compliant with Accessibility > Checking. > http://p.sf.net/sfu/ephox-dev2dev > _______________________________________________ > Mira-development mailing list > Mira-development@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mira-development > ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Mira-development mailing list Mira-development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mira-development