Module Name: src
Committed By: plunky
Date: Sat Nov 20 12:12:21 UTC 2010
Modified Files:
src/lib/libbluetooth: sdp_service.c
Log Message:
use atomic ops wisely
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libbluetooth/sdp_service.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libbluetooth/sdp_service.c
diff -u src/lib/libbluetooth/sdp_service.c:1.3 src/lib/libbluetooth/sdp_service.c:1.4
--- src/lib/libbluetooth/sdp_service.c:1.3 Sat Nov 13 19:43:56 2010
+++ src/lib/libbluetooth/sdp_service.c Sat Nov 20 12:12:21 2010
@@ -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;