~ubuntu-branches/ubuntu/lucid/mysql-dfsg-5.1/lucid-security

« back to all changes in this revision

Viewing changes to sql/rpl_mi.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 22:33:55 UTC
  • mto: (1.2.1) (37.1.1 lucid-security)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: package-import@ubuntu.com-20120222223355-ku1tb4r70osci6v2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2003 MySQL AB
 
1
/*
 
2
   Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
#include <my_global.h> // For HAVE_REPLICATION
17
19
#include "mysql_priv.h"
312
314
  mi->inited = 1;
313
315
  // now change cache READ -> WRITE - must do this before flush_master_info
314
316
  reinit_io_cache(&mi->file, WRITE_CACHE, 0L, 0, 1);
315
 
  if ((error=test(flush_master_info(mi, 1))))
 
317
  if ((error=test(flush_master_info(mi, TRUE, TRUE))))
316
318
    sql_print_error("Failed to flush master info file");
317
319
  pthread_mutex_unlock(&mi->data_lock);
318
320
  DBUG_RETURN(error);
338
340
     1 - flush master info failed
339
341
     0 - all ok
340
342
*/
341
 
int flush_master_info(Master_info* mi, bool flush_relay_log_cache)
 
343
int flush_master_info(Master_info* mi, 
 
344
                      bool flush_relay_log_cache, 
 
345
                      bool need_lock_relay_log)
342
346
{
343
347
  IO_CACHE* file = &mi->file;
344
348
  char lbuf[22];
 
349
  int err= 0;
345
350
 
346
351
  DBUG_ENTER("flush_master_info");
347
352
  DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos));
358
363
    When we come to this place in code, relay log may or not be initialized;
359
364
    the caller is responsible for setting 'flush_relay_log_cache' accordingly.
360
365
  */
361
 
  if (flush_relay_log_cache &&
362
 
      flush_io_cache(mi->rli.relay_log.get_log_file()))
363
 
    DBUG_RETURN(2);
 
366
  if (flush_relay_log_cache)
 
367
  {
 
368
    pthread_mutex_t *log_lock= mi->rli.relay_log.get_log_lock();
 
369
    IO_CACHE *log_file= mi->rli.relay_log.get_log_file();
 
370
 
 
371
    if (need_lock_relay_log)
 
372
      pthread_mutex_lock(log_lock);
 
373
 
 
374
    safe_mutex_assert_owner(log_lock);
 
375
    err= flush_io_cache(log_file);
 
376
 
 
377
    if (need_lock_relay_log)
 
378
      pthread_mutex_unlock(log_lock);
 
379
 
 
380
    if (err)
 
381
      DBUG_RETURN(2);
 
382
  }
364
383
 
365
384
  /*
366
385
    We flushed the relay log BEFORE the master.info file, because if we crash