~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/command_log/command_log.cc

  • Committer: Brian Aker
  • Date: 2009-09-30 00:48:37 UTC
  • mfrom: (1143.1.1 bug437896)
  • Revision ID: brian@gaz-20090930004837-vrhjzvzg19e0sq0e
Update from Jay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
#include <drizzled/set_var.h>
71
71
#include <drizzled/gettext.h>
72
72
#include <drizzled/message/replication.pb.h>
 
73
#include <drizzled/crc32.h>
73
74
 
74
75
#include <vector>
75
76
#include <string>
76
77
#include <unistd.h>
77
 
#include <zlib.h>
78
78
 
79
79
using namespace std;
80
80
using namespace drizzled;
167
167
  /*
168
168
   * Do an atomic increment on the offset of the log file position
169
169
   */
170
 
  cur_offset= log_offset.fetch_and_add((off_t) (HEADER_TRAILER_BYTES + length));
 
170
  cur_offset= log_offset.fetch_and_add(static_cast<off_t>((HEADER_TRAILER_BYTES + length)));
171
171
 
172
172
  /*
173
173
   * We adjust cur_offset back to the original log_offset before
174
174
   * the increment above...
175
175
   */
176
 
  cur_offset-= (off_t) (HEADER_TRAILER_BYTES + length);
 
176
  cur_offset-= static_cast<off_t>((HEADER_TRAILER_BYTES + length));
177
177
 
178
178
  /* 
179
179
   * Quick safety...if an error occurs below, the log file will
199
199
    errmsg_printf(ERRMSG_LVL_ERROR, 
200
200
                  _("Failed to write full size of command.  Tried to write %" PRId64 
201
201
                    " bytes at offset %" PRId64 ", but only wrote %" PRId64 " bytes.  Error: %s\n"), 
202
 
                  sizeof(int64_t), 
203
 
                  (int64_t) cur_offset,
204
 
                  (int64_t) written, 
 
202
                  static_cast<int64_t>(sizeof(uint64_t)), 
 
203
                  static_cast<int64_t>(cur_offset),
 
204
                  static_cast<int64_t>(written), 
205
205
                  strerror(errno));
206
206
    state= CRASHED;
207
207
    /* 
213
213
    return;
214
214
  }
215
215
 
216
 
  cur_offset+= (off_t) written;
 
216
  cur_offset+= static_cast<off_t>(written);
217
217
 
218
218
  /* 
219
219
   * Quick safety...if an error occurs above in another writer, the log 
236
236
  }
237
237
  while (written == -1 && errno == EINTR); /* Just retry the write when interrupted by a signal... */
238
238
 
239
 
  if (unlikely(written != (ssize_t) length))
 
239
  if (unlikely(written != static_cast<ssize_t>(length)))
240
240
  {
241
241
    errmsg_printf(ERRMSG_LVL_ERROR, 
242
242
                  _("Failed to write full serialized command.  Tried to write %" PRId64 
243
243
                    " bytes at offset %" PRId64 ", but only wrote %" PRId64 " bytes.  Error: %s\n"), 
244
 
                  (int64_t) length, 
245
 
                  (int64_t) cur_offset,
246
 
                  (int64_t) written, 
 
244
                  static_cast<int64_t>(length), 
 
245
                  static_cast<int64_t>(cur_offset),
 
246
                  static_cast<int64_t>(written), 
247
247
                  strerror(errno));
248
248
    state= CRASHED;
249
249
    /* 
254
254
    is_active= false;
255
255
  }
256
256
 
257
 
  cur_offset+= (off_t) written;
 
257
  cur_offset+= static_cast<off_t>(written);
258
258
 
259
259
  /* 
260
260
   * Quick safety...if an error occurs above in another writer, the log 
274
274
 
275
275
  if (do_checksum)
276
276
  {
277
 
    checksum= crc32(0, (unsigned char *) buffer.c_str(), length);
 
277
    checksum= hash_crc32(buffer.c_str(), length);
278
278
  }
279
279
 
280
280
  /* We always write in network byte order */
288
288
  }
289
289
  while (written == -1 && errno == EINTR); /* Just retry the write when interrupted by a signal... */
290
290
 
291
 
  if (unlikely(written != (ssize_t) sizeof(uint32_t)))
 
291
  if (unlikely(written != static_cast<ssize_t>(sizeof(uint32_t))))
292
292
  {
293
293
    errmsg_printf(ERRMSG_LVL_ERROR, 
294
294
                  _("Failed to write full checksum of command.  Tried to write %" PRId64 
295
295
                    " bytes at offset %" PRId64 ", but only wrote %" PRId64 " bytes.  Error: %s\n"), 
296
 
                  (int64_t) sizeof(uint32_t), 
297
 
                  (int64_t) cur_offset,
298
 
                  (int64_t) written, 
 
296
                  static_cast<int64_t>(sizeof(uint32_t)), 
 
297
                  static_cast<int64_t>(cur_offset),
 
298
                  static_cast<int64_t>(written), 
299
299
                  strerror(errno));
300
300
    state= CRASHED;
301
301
    /*