summaryrefslogtreecommitdiffstats
path: root/hci/src/hci_inject.c
diff options
context:
space:
mode:
authorSharvil Nanavati <sharvil@google.com>2014-08-13 00:40:49 -0700
committerAndre Eisenbach <eisenbach@google.com>2015-03-16 16:51:28 -0700
commitfbf89085bf308a98b00da77d1538539f6dd58604 (patch)
tree82802f0ae12dec58034a2cc0683da6a841765329 /hci/src/hci_inject.c
parent278abce72967eaa496b402ffc867e37a4613c187 (diff)
downloadandroid_system_bt-fbf89085bf308a98b00da77d1538539f6dd58604.tar.gz
android_system_bt-fbf89085bf308a98b00da77d1538539f6dd58604.tar.bz2
android_system_bt-fbf89085bf308a98b00da77d1538539f6dd58604.zip
Switch to an epoll-based reactor implementation.
epoll is a much nicer interface that very closely matches the reactor interface. It's also thread-safe which makes it a more suitable choice for bluedroid. As a result of this change, reactor_register and reactor_unregister are both thread-safe without introducing any synchronization in user-space.
Diffstat (limited to 'hci/src/hci_inject.c')
-rw-r--r--hci/src/hci_inject.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/hci/src/hci_inject.c b/hci/src/hci_inject.c
index 78c1cc1a7..af5ed704d 100644
--- a/hci/src/hci_inject.c
+++ b/hci/src/hci_inject.c
@@ -62,14 +62,14 @@ bool hci_inject_open(void) {
hci = bt_hc_get_interface();
- clients = list_new(client_free);
- if (!clients)
- goto error;
-
thread = thread_new("hci_inject");
if (!thread)
goto error;
+ clients = list_new(client_free);
+ if (!clients)
+ goto error;
+
listen_socket = socket_new();
if (!listen_socket)
goto error;
@@ -77,7 +77,7 @@ bool hci_inject_open(void) {
if (!socket_listen(listen_socket, LISTEN_PORT))
goto error;
- socket_register(listen_socket, thread, accept_ready, NULL, NULL);
+ socket_register(listen_socket, thread_get_reactor(thread), NULL, accept_ready, NULL);
return true;
error:;
@@ -87,8 +87,8 @@ error:;
void hci_inject_close(void) {
socket_free(listen_socket);
- thread_free(thread);
list_free(clients);
+ thread_free(thread);
listen_socket = NULL;
thread = NULL;
@@ -132,7 +132,7 @@ static void accept_ready(socket_t *socket, UNUSED_ATTR void *context) {
return;
}
- socket_register(socket, thread, read_ready, NULL, client);
+ socket_register(socket, thread_get_reactor(thread), client, read_ready, NULL);
}
static void read_ready(UNUSED_ATTR socket_t *socket, void *context) {