~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/xa_resource_manager.cc

  • Committer: pcrews
  • Date: 2011-05-24 17:36:24 UTC
  • mfrom: (1099.4.232 drizzle)
  • Revision ID: pcrews@lucid32-20110524173624-mwr1bvq6fa1r01ao
Updated translations + 2011.05.18 tarball tag

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