summaryrefslogtreecommitdiff
path: root/utils/LocIpc.cpp
diff options
context:
space:
mode:
authorKevin Tang <zhikait@codeaurora.org>2018-01-15 10:18:49 -0800
committerKevin Tang <zhikait@codeaurora.org>2018-01-15 10:18:49 -0800
commit4cac1baf97d8b5e953cdcc55a3ec9bc26052e52c (patch)
tree871aa667dc78cfb76a744db19b27438b5c76fe0b /utils/LocIpc.cpp
parentc98dcaa84072a901167d0083fc3fef6b98077052 (diff)
downloadgps-4cac1baf97d8b5e953cdcc55a3ec9bc26052e52c.tar.gz
LocIpc: enhance startListeningNoBlocking with ready callback
For startListeningNoBlocking, for callers that need to know when the socket is actually being created and ready to receive message, this change allows callback to be invoked when socket is ready. Change-Id: Ie7c6eb1a3966371d84fc98109f07805ac7d4e3a1 CRs-fixed: 2169568
Diffstat (limited to 'utils/LocIpc.cpp')
-rw-r--r--utils/LocIpc.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/utils/LocIpc.cpp b/utils/LocIpc.cpp
index 0ee156e..1df1546 100644
--- a/utils/LocIpc.cpp
+++ b/utils/LocIpc.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -76,6 +76,7 @@ bool LocIpc::startListeningNonBlocking(const std::string& name) {
}
bool LocIpc::startListeningBlocking(const std::string& name) {
+
int fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
LOC_LOGe("create socket error. reason:%s", strerror(errno));
@@ -100,6 +101,9 @@ bool LocIpc::startListeningBlocking(const std::string& name) {
mIpcFd = fd;
+ // inform that the socket is ready to receive message
+ onListenerReady();
+
ssize_t nBytes = 0;
std::string msg = "";
while (1) {