~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/xa_resource_manager.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
 
23
 
#include <drizzled/cached_directory.h>
 
23
#include "drizzled/cached_directory.h"
24
24
 
25
25
#include <drizzled/definitions.h>
26
26
#include <drizzled/session.h>
27
27
#include <drizzled/error.h>
28
28
#include <drizzled/gettext.h>
29
29
#include <drizzled/plugin/xa_resource_manager.h>
30
 
#include <drizzled/xid.h>
31
 
#include <drizzled/errmsg_print.h>
32
 
#include <drizzled/sys_var.h>
 
30
#include "drizzled/xid.h"
 
31
 
33
32
 
34
33
#include <string>
35
34
#include <vector>
36
35
#include <algorithm>
37
36
#include <functional>
38
37
 
39
 
namespace drizzled {
40
 
namespace plugin {
 
38
namespace drizzled
 
39
{
 
40
 
 
41
namespace plugin
 
42
{
41
43
 
42
44
static std::vector<XaResourceManager *> xa_resource_managers;
43
45
 
44
46
int XaResourceManager::commitOrRollbackXID(XID *xid, bool commit)
45
47
{
46
48
  std::vector<int> results;
47
 
 
 
49
  
48
50
  if (commit)
49
51
    transform(xa_resource_managers.begin(), xa_resource_managers.end(), results.begin(),
50
52
              std::bind2nd(std::mem_fun(&XaResourceManager::xaCommitXid), xid));
85
87
public:
86
88
  XaRecover(XID *trans_list_arg, int trans_len_arg,
87
89
            const XaResourceManager::commit_list_set& commit_list_arg,
88
 
            bool dry_run_arg)
 
90
            bool dry_run_arg) 
89
91
    : trans_len(trans_len_arg), found_foreign_xids(0), found_my_xids(0),
90
92
      result(false),
91
93
      trans_list(trans_list_arg), commit_list(commit_list_arg),
92
94
      dry_run(dry_run_arg)
93
95
  {}
94
 
 
 
96
  
95
97
  int getForeignXIDs()
96
98
  {
97
 
    return found_foreign_xids;
 
99
    return found_foreign_xids; 
98
100
  }
99
101
 
100
102
  int getMyXIDs()
101
103
  {
102
 
    return found_my_xids;
 
104
    return found_my_xids; 
103
105
  }
104
106
 
105
107
  result_type operator() (argument_type resource_manager)
106
108
  {
107
 
 
 
109
  
108
110
    int got;
109
 
 
 
111
  
110
112
    while ((got= resource_manager->xaRecover(trans_list, trans_len)) > 0 )
111
113
    {
112
114
      errmsg_printf(error::INFO,
117
119
        my_xid x=trans_list[i].get_my_xid();
118
120
        if (!x) // not "mine" - that is generated by external TM
119
121
        {
 
122
          xid_cache_insert(trans_list+i, XA_PREPARED);
120
123
          found_foreign_xids++;
121
124
          continue;
122
125
        }
183
186
                xa_resource_managers.end(),
184
187
                recover_func);
185
188
  free(trans_list);
186
 
 
 
189
 
187
190
  if (recover_func.getForeignXIDs())
188
191
    errmsg_printf(error::WARN,
189
192
                  _("Found %d prepared XA transactions"),