summaryrefslogtreecommitdiff
path: root/libsysutils/src/SocketClient.cpp
AgeCommit message (Collapse)Author
2020-07-31SocketClient: don't ignore SIGPIPETom Cherry
1) All current users are better off ignoring SIGPIPE at the beginning of their process instead of ignoring it just for SocketClient 2) This isn't thread safe if users did want it, since sigaction() ignores SIGPIPE for the entire process 3) This costs 5-10% of logd CPU time when logcat is reading logs Also clean up the error handling in SocketClient::sendDataLockedv(). Test: kill logcat and see that logd doesn't crash Test: run simpleperf and see that no cycles are going to sigaction Change-Id: I6532c8a0d71338e534411707b9a9bd785145c730
2018-09-17Suppress implicit-fallthrough warnings.Chih-Hung Hsieh
Add FALLTHROUGH_INTENDED for clang compiler. Bug: 112564944 Test: build with global -Wimplicit-fallthrough. Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
2018-07-24[libsysutils] Modernize codebase by replacing NULL with nullptrYi Kong
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I9e95daa0750f2622d1c4788941fdfae23ee61801
2016-10-20system/core: preparation to pull back interfaces from android/log.hMark Salyzyn
Point to log/log.h where necessary, define LOG_TAG where necessary. Accept that private/android_logger.h is suitable replacement for log/logger.h and android/log.h. Correct liblog/README Effectively a cleanup and controlled select revert of 'system/core: drop or replace log/logger.h' and 'system/core: Replace log/log.h with android/log.h'. Test: compile Bug: 30465923 Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
2016-09-30system/core Replace cutils/log.h with android/log.hMark Salyzyn
Should use android/log.h instead of cutils/log.h as a good example to all others. Adjust header order to comply with Android Coding standards. Test: Compile Bug: 26552300 Bug: 31289077 Change-Id: I2c9cbbbd64d8dccf2d44356361d9742e4a9b9031
2015-01-28Add missing <malloc.h> and <string.h> includes.Elliott Hughes
Change-Id: Ia41756e607663d056e7d2fdd7ecbec7e5841a913
2014-11-10Fix formatting in 4df4dfedf6beef891d05d4e80704f5f4a594a885.Elliott Hughes
Change-Id: I1ad219285cb1f4a39cfe2bdef224b78eff843317
2014-11-10When new error happend,then errno should be updated accordingly.Bo Huang
Otherwise, need to keep previous errno. Reproduced steps: pre-condition: DUT support external SDcard or Usb mass storage; 1. Insert blank(no partition) SDcard or UMS to DUT; Expected result: Should prompt user with storage error. Test result: There is no notification for error. Error log: 01-01 01:06:49.239 I/fsck_msdos( 200): fsck_msdos terminated by exit(8) 01-01 01:06:49.239 E/Vold ( 200): /dev/block/vold/179:16 failed FS checks (I/O error) 01-01 01:06:49.239 D/Vold ( 200): Volume sdcard1 state changing 3 (Checking) -> 1 (Idle-Unmounted) 01-01 01:06:49.239 W/Vold ( 200): Returning OperationFailed - no handler for errno 0) Root cause analysis: 1.Volume::setState will call senBroadcase to send out state notification; 2.Finally, SocketClient::sendDataLockedv was called to sent message. In sendDataLockedv funtion, when current == iovcnt, e is 0 by default. So Vold get incorrect errno. Change-Id: Icb32a4193f02f22b5e3feaba177bc278f8f1f41b Signed-off-by: Bo Huang <bo.b.huang@intel.com>
2014-01-31libsysutil: frequent native crash /system/bin/voldMark Salyzyn
regression from commit a6e965578e44f9ae5f98de822ba5decec381dffc * wrap writev with sigaction SIG_IGN SIGPIPE to emulate the send(,,,MSG_NOSIGNAL) call it had replaced. (cherry pick from commit 83fc720785c4e40f3341daf7c0bf5ee99261fee9) BUG: 12796279 Change-Id: I14363630ada79c0a5b85bb6b2afd0a1c4d5c3109
2014-01-27libsysutils: Add iovec/runOnEachSocketMark Salyzyn
SocketClient: * Replace sendDataLocked with sendDataLockedv which takes an iovec. * Add a version of sendData, sendDatav, which takes an iovec. * do not preserve iovec content through sendDatav SocketListener: * Add runOnEachSocket, which allows to to specify a SocketClientCommand to run individually on each socket. This allows you to do broadcast-like actions customized for each individual socket. * Client safe list reference counting for sendBroadcast & runOnEach Socket (cherry picked from commit a6e965578e44f8ae5f98de822ba5decec381d5fc) Signed-off-by: Nick Kralevich <nnk@google.com> Signed-off-by: Mark Salyzyn <salyzyn@google.com> Change-Id: I716f89c01b4cb7af900045c7e41fac1492defb06
2013-05-20libsysutils: fix null pointer and memory leak issueHong-Mei Li
In SocketClient::quoteArg function 1. Fix potential null pointer accessing issue 2. Fix potential memory leak introduced by realloc fail Change-Id: I1ca0f9089290d43452e9a71428244545f4ed866b Signed-off-by: Hong-Mei Li <a21834@motorola.com>
2012-05-30am 7bb1b958: am ff856a2b: Merge "Add error handling to SocketClient::sendData"Robert Greenwalt
* commit '7bb1b9585d2d61beaf05c997971aee27f87ad3f7': Add error handling to SocketClient::sendData
2012-05-29Add error handling to SocketClient::sendDataMattias Falk
Return failure and set errno if mSocket isn't valid. Change-Id: I579114d435db46d0bb5682167ef34bebe061a8f8
2012-04-20Add ability to quote responses as needed.Robert Greenwalt
It's up to the protocol to know when quotes are required. In the future the response should probably all be binary blobs with lengths. bug:6353048 Change-Id: I3f9b48ab0f4e6746d75cdc9c0c84d33f38f63661
2012-03-12Do not generate SIGPIPE errors in SocketCLient.Selim Gurun
This change is to make sure the users of library does not crash if they are not handling SIGPIPE properly. Change-Id: I4ea80d6bfc26a4bca6b901959ae3060b059d46d3
2012-03-09Fix pointer arith.Robert Greenwalt
Sending 3digit code, null, binary-length and data. Current code sends 3digit code, space, null, binary-length, binary-data. The space should not be sent. Change-Id: I1df00a3e70805b39b6105966c7f3c613461a6858
2012-03-07Add a utility function to send a code + binary msgSelim Gurun
Add a utility function to SocketClient to send a c-string code prepended to a binary message. This is necessary to be able to send a binary message while keeping compatible with underlying text-based protocol. Change-Id: Ifc6562003a687577d7deb50260533a5147ae4f97
2012-03-05New NativeDaemonConnector protocol adds a seqnum.Robert Greenwalt
Allows for one socket to be multiplexed for multiple requests. Doesn't use command sequence numbers for broadcasts - would make no sense. Doesn't alter current default behavior so OEM's using these classes won't notice a difference. bug:5864209 Change-Id: Ie3b19c4f81eea868569229a365c8cb7de249c2dd
2012-02-07Revert "New NativeDaemonConnector protocol adds a seqnum."Guang Zhu
Reverting because it seems to break `adb reboot` This reverts commit dc58e73071aa829a5038caf37211f6b3e2d7b275. Change-Id: Ib8cc4379254694398cbb7f3e7a64c20e1ed8c1ba
2012-02-07New NativeDaemonConnector protocol adds a seqnum.Robert Greenwalt
Allows for one socket to be multiplexed for multiple requests. bug:5864209 Change-Id: I934c88da25d95e093371f455442bdf2f0ed7a4f4
2011-09-29Fix SocketListener socket leak issue.Xianzhu Wang
The problem was: if a socket is shared between SocketListener and another thread, only if the last reference is removed by SocketListener can the socket be closed, otherwise the socket will leak. This sometimes happens in netd's dnsproxyd. This change let the SocketClient own the socket and close the socket when the SocketClient is destructed. Change-Id: I2865fbfe9ee4d8b3e43d7e02919dbb2d261f70de
2011-03-17Fix potential race introduced in Icd7f5f03Brad Fitzpatrick
Digit wrote: "You probably don't want to close the socket here without updating c->socket as well. Otherwise, another thread holding a handle to the client after the c->decRef() could end up sending a message to a different socket, if the file descriptor index is reused by another client in the meantime." Change-Id: Icdefb5ffc0c7607325d7db761e1f04e5d868bfb7
2011-03-17SocketClient: add optional reference countingBrad Fitzpatrick
Needed to fix a race in netd. Bug: 3438459 Change-Id: Icd7f5f035510235f733a25c0621479d3e644b152
2011-01-19libsysutils: Handle EINTR in SocketClient::sendData()David 'Digit' Turner
+ Improve allocation code in sendMsg(code,msg,addErrno) Change-Id: Ib5fe84bec1a167c369e7ba759acea395e832f6b5
2010-11-02Permit 0 length writes.Brad Fitzpatrick
Change-Id: I087d0074c8d9e13ce814187475966da94f693fc0
2010-10-27Let SocketClient users write binary data to clients.Brad Fitzpatrick
This is a dependency for the DNS proxy CLs. This CL also adds a new socket for the netd process to inherit which is owned by the inet group. (so only apps with the INTERNET permission can use the DNS proxy...) Change-Id: Ic3475c697913ba85805b4e49801b65e7a1d59289
2010-09-14Fetch peer credentials for local socketsKenny Root
Fetch the PID, UID, and GID of the remote side of a local socket connection in case any users of this library class want to check it. Change-Id: Ia3230e6bc68ab6f93160df9f5996d2bf744b872c
2010-03-25system/core: Switch libsysutils & sched_policy LOG -> SLOGSan Mehat
Change-Id: Id74c6895a8012c5915f2e259339101844de7c085 Signed-off-by: San Mehat <san@google.com>
2009-06-15libsysutils: Move to a null terminated string protocol using space as a ↵San Mehat
field separator. Also removes some debugging Signed-off-by: San Mehat <san@google.com>
2009-05-29libsysutils: Fix command argument passing bug + whitespace cleanupSan Mehat
Signed-off-by: San Mehat <san@google.com>
2009-05-20libsysutils: const correctness fixes + remove some debuggingSan Mehat
Signed-off-by: San Mehat <san@google.com>
2009-05-13libsysutils: General clean up + disable build in simulator buildsSan Mehat
Signed-off-by: San Mehat <san@google.com>
2009-05-12libsysutils: Tweak SocketListener and friendsSan Mehat
Signed-off-by: San Mehat <san@google.com>
2009-05-10libsysutils: Add multiple client support and fix some bugsSan Mehat