~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/repl_failsafe.cc

  • Committer: Brian Aker
  • Date: 2008-08-10 16:57:26 UTC
  • Revision ID: brian@tangent.org-20080810165726-mc1660l11a5vkv69
libdrizzle has ulong removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
*/
25
25
#include <drizzled/server_includes.h>
26
26
 
 
27
#ifdef HAVE_REPLICATION
 
28
 
27
29
#include "repl_failsafe.h"
28
30
#include "sql_repl.h"
29
31
#include "rpl_mi.h"
39
41
pthread_cond_t COND_rpl_status;
40
42
HASH slave_list;
41
43
 
42
 
const char *rpl_role_type[] = {"MASTER","SLAVE",NULL};
 
44
const char *rpl_role_type[] = {"MASTER","SLAVE",NullS};
43
45
TYPELIB rpl_role_typelib = {array_elements(rpl_role_type)-1,"",
44
46
                            rpl_role_type, NULL};
45
47
 
46
48
const char* rpl_status_type[]=
47
49
{
48
50
  "AUTH_MASTER","ACTIVE_SLAVE","IDLE_SLAVE", "LOST_SOLDIER","TROOP_SOLDIER",
49
 
  "RECOVERY_CAPTAIN","NULL",NULL
 
51
  "RECOVERY_CAPTAIN","NULL",NullS
50
52
};
51
53
TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"",
52
54
                             rpl_status_type, NULL};
64
66
 
65
67
#define get_object(p, obj, msg) \
66
68
{\
67
 
  uint32_t len = (uint)*p++;  \
 
69
  uint len = (uint)*p++;  \
68
70
  if (p + len > p_end || len >= sizeof(obj)) \
69
71
  {\
70
72
    errmsg= msg;\
91
93
 
92
94
    SLAVE_INFO* old_si;
93
95
    if ((old_si = (SLAVE_INFO*)hash_search(&slave_list,
94
 
                                           (unsigned char*)&thd->server_id, 4)) &&
 
96
                                           (uchar*)&thd->server_id, 4)) &&
95
97
        (!only_mine || old_si->thd == thd))
96
 
    hash_delete(&slave_list, (unsigned char*)old_si);
 
98
    hash_delete(&slave_list, (uchar*)old_si);
97
99
 
98
100
    if (need_mutex)
99
101
      pthread_mutex_unlock(&LOCK_slave_list);
110
112
    1   Error.   Error message sent to client
111
113
*/
112
114
 
113
 
int register_slave(THD* thd, unsigned char* packet, uint32_t packet_length)
 
115
int register_slave(THD* thd, uchar* packet, uint packet_length)
114
116
{
115
117
  int res;
116
118
  SLAVE_INFO *si;
117
 
  unsigned char *p= packet, *p_end= packet + packet_length;
 
119
  uchar *p= packet, *p_end= packet + packet_length;
118
120
  const char *errmsg= "Wrong parameters to function register_slave";
119
121
 
120
122
  if (!(si = (SLAVE_INFO*)my_malloc(sizeof(SLAVE_INFO), MYF(MY_WME))))
137
139
 
138
140
  pthread_mutex_lock(&LOCK_slave_list);
139
141
  unregister_slave(thd,0,0);
140
 
  res= my_hash_insert(&slave_list, (unsigned char*) si);
 
142
  res= my_hash_insert(&slave_list, (uchar*) si);
141
143
  pthread_mutex_unlock(&LOCK_slave_list);
142
144
  return res;
143
145
 
144
146
err:
145
 
  free(si);
 
147
  my_free(si, MYF(MY_WME));
146
148
  my_message(ER_UNKNOWN_ERROR, errmsg, MYF(0)); /* purecov: inspected */
147
149
err2:
148
150
  return 1;
158
160
 
159
161
extern "C" void slave_info_free(void *s)
160
162
{
161
 
  free(s);
 
163
  my_free(s, MYF(MY_WME));
162
164
}
163
165
 
164
166
void init_slave_list()
204
206
 
205
207
  pthread_mutex_lock(&LOCK_slave_list);
206
208
 
207
 
  for (uint32_t i = 0; i < slave_list.records; ++i)
 
209
  for (uint i = 0; i < slave_list.records; ++i)
208
210
  {
209
211
    SLAVE_INFO* si = (SLAVE_INFO*) hash_element(&slave_list, i);
210
212
    protocol->prepare_for_resend();
228
230
  my_eof(thd);
229
231
  return(false);
230
232
}
 
233
 
 
234
#endif /* HAVE_REPLICATION */
 
235