summaryrefslogtreecommitdiffstats
path: root/libcutils/properties.c
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2011-03-07 13:52:21 -0800
committerBrad Fitzpatrick <bradfitz@android.com>2011-03-10 16:00:48 -0800
commiteb1f0c6fd162fe34d91e8766e53e440349130a36 (patch)
treec969f821e5c09e0362aa61dbb9ef3078149e4cdc /libcutils/properties.c
parentd8ed091c6eaa5f44b84407af5d8e902f9358dc60 (diff)
downloadsystem_core-eb1f0c6fd162fe34d91e8766e53e440349130a36.zip
system_core-eb1f0c6fd162fe34d91e8766e53e440349130a36.tar.gz
system_core-eb1f0c6fd162fe34d91e8766e53e440349130a36.tar.bz2
Fix a race in system properties.
This now passes: $ adb shell am instrument -w -e class android.os.SystemPropertiesTest \ com.android.frameworks.coretests.systemproperties/android.test.InstrumentationTestRunner (which tests setting and re-reading back system properties in a loop) This patch depends on I110b653a which moves property setting from libcutils into bionic. Bug: 3511230 Change-Id: Iee1ca9b7defd6060510a01f40fbe63ba4c96eb8d
Diffstat (limited to 'libcutils/properties.c')
-rw-r--r--libcutils/properties.c40
1 files changed, 1 insertions, 39 deletions
diff --git a/libcutils/properties.c b/libcutils/properties.c
index 547cc6d..98f356b 100644
--- a/libcutils/properties.c
+++ b/libcutils/properties.c
@@ -31,47 +31,9 @@
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
-static int send_prop_msg(prop_msg *msg)
-{
- int s;
- int r;
-
- s = socket_local_client(PROP_SERVICE_NAME,
- ANDROID_SOCKET_NAMESPACE_RESERVED,
- SOCK_STREAM);
- if(s < 0) return -1;
-
- while((r = send(s, msg, sizeof(prop_msg), 0)) < 0) {
- if((errno == EINTR) || (errno == EAGAIN)) continue;
- break;
- }
-
- if(r == sizeof(prop_msg)) {
- r = 0;
- } else {
- r = -1;
- }
-
- close(s);
- return r;
-}
-
int property_set(const char *key, const char *value)
{
- prop_msg msg;
- unsigned resp;
-
- if(key == 0) return -1;
- if(value == 0) value = "";
-
- if(strlen(key) >= PROP_NAME_MAX) return -1;
- if(strlen(value) >= PROP_VALUE_MAX) return -1;
-
- msg.cmd = PROP_MSG_SETPROP;
- strcpy((char*) msg.name, key);
- strcpy((char*) msg.value, value);
-
- return send_prop_msg(&msg);
+ return __system_property_set(key, value);
}
int property_get(const char *key, char *value, const char *default_value)