List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:December 13 2001 6:00pm
Subject:bk commit into 3.23 tree
View as plain text  
Hi!

>>>>> "sasha" == sasha  <sasha@stripped> writes:

sasha> ChangeSet@stripped, 2001-12-12 18:55:33-07:00, sasha@stripped

<cut>

sasha> +++ 1.119/sql/slave.cc	Wed Dec 12 18:55:33 2001
<cut>
sasha> +  use_slave_mask = 1;
sasha> +  for (;isspace(*arg);++arg)
sasha> +    /* empty */;

sasha> +  /* force first three chars to lower case */
sasha> +  for (p = arg, end = arg + 3; *p && p < end; ++p)
sasha> +    *p = tolower(*p);
sasha> +  if (!memcmp(arg,"all",3))

You can replace the above with:
         if (!my_casecmp(arg,"all",3))

sasha> +  {
sasha> +    bitmap_set_all(&slave_error_mask);
sasha> +    return;
sasha> +  }

sasha> +  for (p = arg, end = strend(arg); p < end; ++p)
sasha> +  {
sasha> +    int digit = *p - '0';
sasha> +    if (digit >= 0 && digit < 10) /* found real digit */
sasha> +    {
sasha> +      err_code = err_code * 10 + digit;
sasha> +      last_was_digit = 1;
sasha> +    }
sasha> +    else /* delimiter */
sasha> +    {
sasha> +      if (last_was_digit)
sasha> +      {
sasha> +	if (err_code < MAX_SLAVE_ERROR)
sasha> +	{
sasha> +	  bitmap_set_bit(&slave_error_mask,err_code);
sasha> +	}
sasha> +	err_code = 0;
sasha> +	last_was_digit = 0;
sasha> +      }
sasha> +    }
sasha> +  }
sasha> +}
 
A smaller, more correct, version of the above loop would be:

  for (p= arg ; *p; )
  {
    long err_code;
    if (!(p= str2int(p, 10, 0, LONG_MAX, &errcode)))
      break;
    if (err_code < MAX_SLAVE_ERROR)
       bitmap_set_bit(&slave_error_mask,err_code);
    while (!isdigit(*p) && *p)
      p++;
  }

<cut>

sasha> --- 1.3/include/my_bitmap.h	Wed Feb  7 14:27:18 2001
sasha> +++ 1.4/include/my_bitmap.h	Wed Dec 12 18:55:32 2001
<cut>

sasha> +  my_bool thread_safe; /* set if several threads access the bitmap */
sasha> +  /* mutex will be acquired for the duration of each bitmap operation if
sasha> +     thread_safe flag is set. Otherwise, we optimize by not acquiring the
sasha> +     mutex
sasha> +  */

Sasha, please remember how we should do comments.  It should have the
style:

  /*
     mutex will be acquired for the duration of each bitmap operation if
     thread_safe flag is set. Otherwise, we optimize by not acquiring the


<cut>

sasha> --- 1.6/mysys/my_bitmap.c	Sat Mar 24 11:15:08 2001
sasha> +++ 1.7/mysys/my_bitmap.c	Wed Dec 12 18:55:32 2001
sasha> @@ -26,14 +26,32 @@
sasha>  #include "mysys_priv.h"
sasha>  #include <my_bitmap.h>
sasha>  #include <assert.h>
sasha> +#include <string.h>
 
<cut>

sasha> +my_bool bitmap_init(MY_BITMAP *map, uint bitmap_size, my_bool thread_safe)
sasha>  {
sasha>    if (!(map->bitmap=(uchar*) my_malloc((bitmap_size+7)/8,
sasha>  				       MYF(MY_WME | MY_ZEROFILL))))
sasha>      return 1;
sasha>    dbug_assert(bitmap_size != ~(uint) 0);
sasha>  #ifdef THREAD
sasha> +  map->thread_safe = thread_safe;
sasha>    pthread_mutex_init(&map->mutex, MY_MUTEX_INIT_FAST);
sasha>  #endif

You don't have to init the mutex if we don't need to have this threadsafe!
You must of course have the same test when we free the bitmap.

<cut>

Otherwise ok!

Regards,
Monty
Thread
bk commit into 3.23 treesasha13 Dec
  • bk commit into 3.23 treeMichael Widenius13 Dec