Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libbluetooth use atomic ops wisely
details: https://anonhg.NetBSD.org/src/rev/a613d50c4e9c
branches: trunk
changeset: 758895:a613d50c4e9c
user: plunky <plunky%NetBSD.org@localhost>
date: Sat Nov 20 12:12:21 2010 +0000
description:
use atomic ops wisely
diffstat:
lib/libbluetooth/sdp_service.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diffs (44 lines):
diff -r 7eeea7336ae1 -r a613d50c4e9c lib/libbluetooth/sdp_service.c
--- a/lib/libbluetooth/sdp_service.c Fri Nov 19 18:27:12 2010 +0000
+++ b/lib/libbluetooth/sdp_service.c Sat Nov 20 12:12:21 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sdp_service.c,v 1.3 2010/11/13 19:43:56 plunky Exp $ */
+/* $NetBSD: sdp_service.c,v 1.4 2010/11/20 12:12:21 plunky Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,9 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: sdp_service.c,v 1.3 2010/11/13 19:43:56 plunky Exp $");
+__RCSID("$NetBSD: sdp_service.c,v 1.4 2010/11/20 12:12:21 plunky Exp $");
+
+#include <sys/atomic.h>
#include <errno.h>
#include <limits.h>
@@ -43,6 +45,7 @@
/*
* If AttributeIDList is given as NULL, request all attributes.
+ * (this is actually const data but we can't declare it const)
*/
static uint8_t ail_default[] = { 0x0a, 0x00, 0x00, 0xff, 0xff };
@@ -56,13 +59,11 @@
sdp_response_max(void)
{
static size_t max = UINT16_MAX;
- static bool check = true;
+ static unsigned int check = 1;
char *env, *ep;
unsigned long v;
- while (check) {
- check = false; /* only check env once */
-
+ while (atomic_swap_uint(&check, 0)) { /* only check env once */
env = getenv("SDP_RESPONSE_MAX");
if (env == NULL)
break;
Home |
Main Index |
Thread Index |
Old Index