[sheepdog] [PATCH v2 2/2] sheep: fix illegal direct assignments to an uatomic_bool typed variable
Liu Yuan
namei.unix at gmail.com
Tue Jan 29 08:19:30 CET 2013
On 01/29/2013 02:01 PM, Hitoshi Mitake wrote:
> global_cache->in_reclaim and sockfd_cache_fd->in_use should be
> accessed with uatomic_set_{true, false}.
>
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
> v2: fixed a silly mistake
> 8<---
> sheep/object_cache.c | 2 +-
> sheep/sockfd_cache.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sheep/object_cache.c b/sheep/object_cache.c
> index 4e26392..56b700e 100644
> --- a/sheep/object_cache.c
> +++ b/sheep/object_cache.c
> @@ -1274,7 +1274,7 @@ int object_cache_init(const char *p)
> strbuf_copyout(&buf, object_cache_dir, sizeof(object_cache_dir));
>
> uatomic_set(&gcache.capacity, 0);
> - gcache.in_reclaim = false;
> + uatomic_set_false(&gcache.in_reclaim);
>
> ret = load_cache();
> err:
> diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
> index f1124c0..d39ff6e 100644
> --- a/sheep/sockfd_cache.c
> +++ b/sheep/sockfd_cache.c
> @@ -304,7 +304,7 @@ static void do_grow_fds(struct work *work)
> entry->fds = xrealloc(entry->fds, new_size);
> for (i = old_fds_count; i < new_fds_count; i++) {
> entry->fds[i].fd = -1;
> - entry->fds[i].in_use = false;
> + uatomic_set_false(&entry->fds[i].in_use);
> }
> }
> pthread_rwlock_unlock(&sockfd_cache.lock);
>
Oops, we can't call uatomic_set_false() directly because it assume it is
previously true.
Do we need to remove assert() in uatomic_set_false() or introduce
uatomic_bool_init()? It seems that removing assert() is simpler.
Thanks,
Yuan
More information about the sheepdog
mailing list