~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log.cc

  • Committer: Brian Aker
  • Date: 2008-12-05 03:17:16 UTC
  • mfrom: (641.3.11 devel)
  • Revision ID: brian@tangent.org-20081205031716-r65xkzugjylmvv1h
Monty merge (a couple of alterations for malloc()).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2219
2219
  if (trx_data)
2220
2220
    return(0);                             // Already set up
2221
2221
 
2222
 
  trx_data= (binlog_trx_data*) my_malloc(sizeof(binlog_trx_data), MYF(MY_ZEROFILL));
 
2222
  trx_data= (binlog_trx_data*) malloc(sizeof(binlog_trx_data));
 
2223
  memset(trx_data, 0, sizeof(binlog_trx_data));
2223
2224
  if (!trx_data ||
2224
2225
      open_cached_file(&trx_data->trans_log, drizzle_tmpdir,
2225
2226
                       LOG_PREFIX, binlog_cache_size, MYF(MY_WME)))
3048
3049
 
3049
3050
bool flush_error_log()
3050
3051
{
3051
 
  bool result=0;
 
3052
  bool result = 0;
3052
3053
  if (opt_error_log)
3053
3054
  {
3054
 
    char err_renamed[FN_REFLEN], *end;
3055
 
    end= strncpy(err_renamed,log_error_file,FN_REFLEN-4);
3056
 
    end+= strlen(err_renamed);
3057
 
    my_stpcpy(end, "-old");
3058
3055
    pthread_mutex_lock(&LOCK_error_log);
3059
 
    char err_temp[FN_REFLEN+4];
3060
 
    /*
3061
 
     On Windows is necessary a temporary file for to rename
3062
 
     the current error file.
3063
 
    */
3064
 
    strxmov(err_temp, err_renamed,"-tmp",NULL);
3065
 
    (void) my_delete(err_temp, MYF(0)); 
3066
 
    if (freopen(err_temp,"a+",stdout))
3067
 
    {
3068
 
      int fd;
3069
 
      size_t bytes;
3070
 
      unsigned char buf[IO_SIZE];
3071
 
 
3072
 
      if(freopen(err_temp,"a+",stderr)==NULL)
3073
 
        return 1;
3074
 
      (void) my_delete(err_renamed, MYF(0));
3075
 
      my_rename(log_error_file,err_renamed,MYF(0));
3076
 
      if (freopen(log_error_file,"a+",stdout)==NULL)
3077
 
        return 1;
3078
 
      else
3079
 
        if(freopen(log_error_file,"a+",stderr)==NULL)
3080
 
          return 1;
3081
 
 
3082
 
      if ((fd = my_open(err_temp, O_RDONLY, MYF(0))) >= 0)
3083
 
      {
3084
 
        while ((bytes= my_read(fd, buf, IO_SIZE, MYF(0))) &&
3085
 
               bytes != MY_FILE_ERROR)
3086
 
          my_fwrite(stderr, buf, bytes, MYF(0));
3087
 
        my_close(fd, MYF(0));
3088
 
      }
3089
 
      (void) my_delete(err_temp, MYF(0)); 
3090
 
    }
3091
 
    else
3092
 
     result= 1;
 
3056
    if (freopen(log_error_file,"a+",stdout)==NULL)
 
3057
      result = 1;
 
3058
    if (freopen(log_error_file,"a+",stderr)==NULL)
 
3059
      result = 1;
3093
3060
    pthread_mutex_unlock(&LOCK_error_log);
3094
3061
  }
3095
3062
   return result;
3241
3208
 
3242
3209
  npages=(uint)file_length/tc_log_page_size;
3243
3210
  assert(npages >= 3);             // to guarantee non-empty pool
3244
 
  if (!(pages=(PAGE *)my_malloc(npages*sizeof(PAGE), MYF(MY_WME|MY_ZEROFILL))))
 
3211
  if (!(pages=(PAGE *)malloc(npages*sizeof(PAGE))))
3245
3212
    goto err;
 
3213
  memset(pages, 0, npages*sizeof(PAGE));
3246
3214
  inited=3;
3247
3215
  for (pg=pages, i=0; i < npages; i++, pg++)
3248
3216
  {