~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/command_log/command_log.cc

  • Committer: Monty Taylor
  • Date: 2009-10-01 21:04:24 UTC
  • mfrom: (1130.2.14 plugin-base-class)
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20091001210424-4b4zvqsv0ieen4tz
Merged latest plugin-base-class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
#include <drizzled/set_var.h>
77
77
#include <drizzled/gettext.h>
78
78
#include <drizzled/message/replication.pb.h>
 
79
#include <drizzled/crc32.h>
79
80
 
80
81
using namespace std;
81
82
using namespace drizzled;
169
170
  /*
170
171
   * Do an atomic increment on the offset of the log file position
171
172
   */
172
 
  cur_offset= log_offset.fetch_and_add((off_t) (HEADER_TRAILER_BYTES + length));
 
173
  cur_offset= log_offset.fetch_and_add(static_cast<off_t>((HEADER_TRAILER_BYTES + length)));
173
174
 
174
175
  /*
175
176
   * We adjust cur_offset back to the original log_offset before
176
177
   * the increment above...
177
178
   */
178
 
  cur_offset-= (off_t) (HEADER_TRAILER_BYTES + length);
 
179
  cur_offset-= static_cast<off_t>((HEADER_TRAILER_BYTES + length));
179
180
 
180
181
  /* 
181
182
   * Quick safety...if an error occurs below, the log file will
201
202
    errmsg_printf(ERRMSG_LVL_ERROR, 
202
203
                  _("Failed to write full size of command.  Tried to write %" PRId64 
203
204
                    " bytes at offset %" PRId64 ", but only wrote %" PRId64 " bytes.  Error: %s\n"), 
204
 
                  sizeof(int64_t), 
205
 
                  (int64_t) cur_offset,
206
 
                  (int64_t) written, 
 
205
                  static_cast<int64_t>(sizeof(uint64_t)), 
 
206
                  static_cast<int64_t>(cur_offset),
 
207
                  static_cast<int64_t>(written), 
207
208
                  strerror(errno));
208
209
    state= CRASHED;
209
210
    /* 
215
216
    return;
216
217
  }
217
218
 
218
 
  cur_offset+= (off_t) written;
 
219
  cur_offset+= static_cast<off_t>(written);
219
220
 
220
221
  /* 
221
222
   * Quick safety...if an error occurs above in another writer, the log 
238
239
  }
239
240
  while (written == -1 && errno == EINTR); /* Just retry the write when interrupted by a signal... */
240
241
 
241
 
  if (unlikely(written != (ssize_t) length))
 
242
  if (unlikely(written != static_cast<ssize_t>(length)))
242
243
  {
243
244
    errmsg_printf(ERRMSG_LVL_ERROR, 
244
245
                  _("Failed to write full serialized command.  Tried to write %" PRId64 
245
246
                    " bytes at offset %" PRId64 ", but only wrote %" PRId64 " bytes.  Error: %s\n"), 
246
 
                  (int64_t) length, 
247
 
                  (int64_t) cur_offset,
248
 
                  (int64_t) written, 
 
247
                  static_cast<int64_t>(length), 
 
248
                  static_cast<int64_t>(cur_offset),
 
249
                  static_cast<int64_t>(written), 
249
250
                  strerror(errno));
250
251
    state= CRASHED;
251
252
    /* 
256
257
    is_active= false;
257
258
  }
258
259
 
259
 
  cur_offset+= (off_t) written;
 
260
  cur_offset+= static_cast<off_t>(written);
260
261
 
261
262
  /* 
262
263
   * Quick safety...if an error occurs above in another writer, the log 
276
277
 
277
278
  if (do_checksum)
278
279
  {
279
 
    checksum= crc32(0, (unsigned char *) buffer.c_str(), length);
 
280
    checksum= hash_crc32(buffer.c_str(), length);
280
281
  }
281
282
 
282
283
  /* We always write in network byte order */
290
291
  }
291
292
  while (written == -1 && errno == EINTR); /* Just retry the write when interrupted by a signal... */
292
293
 
293
 
  if (unlikely(written != (ssize_t) sizeof(uint32_t)))
 
294
  if (unlikely(written != static_cast<ssize_t>(sizeof(uint32_t))))
294
295
  {
295
296
    errmsg_printf(ERRMSG_LVL_ERROR, 
296
297
                  _("Failed to write full checksum of command.  Tried to write %" PRId64 
297
298
                    " bytes at offset %" PRId64 ", but only wrote %" PRId64 " bytes.  Error: %s\n"), 
298
 
                  (int64_t) sizeof(uint32_t), 
299
 
                  (int64_t) cur_offset,
300
 
                  (int64_t) written, 
 
299
                  static_cast<int64_t>(sizeof(uint32_t)), 
 
300
                  static_cast<int64_t>(cur_offset),
 
301
                  static_cast<int64_t>(written), 
301
302
                  strerror(errno));
302
303
    state= CRASHED;
303
304
    /*