diff options
| author | 2019-07-17 01:20:35 -0700 | |
|---|---|---|
| committer | 2019-07-17 01:20:35 -0700 | |
| commit | 7eeda178422972f39aabb0836d8490a84e8e8504 (patch) | |
| tree | 57dc36e0a809bf3e5591b4c63f4dacafa52bf1ba | |
| parent | 899e29fb8cbf6982e35f568f3a5fcf2ec437eb01 (diff) | |
| parent | bf811221d1eeed73ce71dfc8789d8e4cf670cd2e (diff) | |
Merge "dumpstate: set backlog to zero" am: e0268511a0 am: 8b65dbc738 am: a1dbeb0120
am: bf811221d1
Change-Id: I169f2e3a9544bb6250095928ce6a1588eaa8a3e5
| -rw-r--r-- | cmds/dumpstate/utils.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp index 4cbf5776d3..e08c80627c 100644 --- a/cmds/dumpstate/utils.cpp +++ b/cmds/dumpstate/utils.cpp @@ -725,7 +725,11 @@ int open_socket(const char *service) { return -1; } fcntl(s, F_SETFD, FD_CLOEXEC); - if (listen(s, 4) < 0) { + + // Set backlog to 0 to make sure that queue size will be minimum. + // In Linux, because the minimum queue will be 1, connect() will be blocked + // if the other clients already called connect() and the connection request was not accepted. + if (listen(s, 0) < 0) { MYLOGE("listen(control socket): %s\n", strerror(errno)); return -1; } @@ -736,6 +740,9 @@ int open_socket(const char *service) { // Close socket just after accept(), to make sure that connect() by client will get error // when the socket is used by the other services. + // There is still a race condition possibility between accept and close, but there is no way + // to close-on-accept atomically. + // See detail; b/123306389#comment25 close(s); if (fd < 0) { |