summaryrefslogtreecommitdiff
path: root/libsysutils/src/SocketClient.cpp
Commit message (Collapse)AuthorAgeFilesLines
* SocketClient: don't ignore SIGPIPETom Cherry2020-07-311-35/+16
| | | | | | | | | | | | | | 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
* Suppress implicit-fallthrough warnings.Chih-Hung Hsieh2018-09-171-1/+4
| | | | | | | | Add FALLTHROUGH_INTENDED for clang compiler. Bug: 112564944 Test: build with global -Wimplicit-fallthrough. Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
* [libsysutils] Modernize codebase by replacing NULL with nullptrYi Kong2018-07-241-4/+4
| | | | | | | | Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I9e95daa0750f2622d1c4788941fdfae23ee61801
* system/core: preparation to pull back interfaces from android/log.hMark Salyzyn2016-10-201-1/+2
| | | | | | | | | | | | | | | | 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
* system/core Replace cutils/log.h with android/log.hMark Salyzyn2016-09-301-4/+20
| | | | | | | | | | | 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
* Add missing <malloc.h> and <string.h> includes.Elliott Hughes2015-01-281-0/+1
| | | | Change-Id: Ia41756e607663d056e7d2fdd7ecbec7e5841a913
* Fix formatting in 4df4dfedf6beef891d05d4e80704f5f4a594a885.Elliott Hughes2014-11-101-1/+2
| | | | Change-Id: I1ad219285cb1f4a39cfe2bdef224b78eff843317
* When new error happend,then errno should be updated accordingly.Bo Huang2014-11-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libsysutil: frequent native crash /system/bin/voldMark Salyzyn2014-01-311-12/+24
| | | | | | | | | | | | 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
* libsysutils: Add iovec/runOnEachSocketMark Salyzyn2014-01-271-19/+40
| | | | | | | | | | | | | | | | | | | | 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
* libsysutils: fix null pointer and memory leak issueHong-Mei Li2013-05-201-1/+8
| | | | | | | | | 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>
* am 7bb1b958: am ff856a2b: Merge "Add error handling to SocketClient::sendData"Robert Greenwalt2012-05-301-5/+5
|\ | | | | | | | | * commit '7bb1b9585d2d61beaf05c997971aee27f87ad3f7': Add error handling to SocketClient::sendData
| * Add error handling to SocketClient::sendDataMattias Falk2012-05-291-5/+5
| | | | | | | | | | | | Return failure and set errno if mSocket isn't valid. Change-Id: I579114d435db46d0bb5682167ef34bebe061a8f8
* | Add ability to quote responses as needed.Robert Greenwalt2012-04-201-0/+23
| | | | | | | | | | | | | | | | 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
* | Do not generate SIGPIPE errors in SocketCLient.Selim Gurun2012-03-121-1/+1
| | | | | | | | | | | | | | This change is to make sure the users of library does not crash if they are not handling SIGPIPE properly. Change-Id: I4ea80d6bfc26a4bca6b901959ae3060b059d46d3
* | Fix pointer arith.Robert Greenwalt2012-03-091-8/+8
| | | | | | | | | | | | | | | | | | 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
* | Add a utility function to send a code + binary msgSelim Gurun2012-03-071-4/+39
| | | | | | | | | | | | | | | | | | 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
* | New NativeDaemonConnector protocol adds a seqnum.Robert Greenwalt2012-03-051-22/+37
| | | | | | | | | | | | | | | | | | | | 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
* | Revert "New NativeDaemonConnector protocol adds a seqnum."Guang Zhu2012-02-071-21/+4
| | | | | | | | | | | | | | | | Reverting because it seems to break `adb reboot` This reverts commit dc58e73071aa829a5038caf37211f6b3e2d7b275. Change-Id: Ib8cc4379254694398cbb7f3e7a64c20e1ed8c1ba
* | New NativeDaemonConnector protocol adds a seqnum.Robert Greenwalt2012-02-071-4/+21
|/ | | | | | | Allows for one socket to be multiplexed for multiple requests. bug:5864209 Change-Id: I934c88da25d95e093371f455442bdf2f0ed7a4f4
* Fix SocketListener socket leak issue.Xianzhu Wang2011-09-291-1/+9
| | | | | | | | | | | | 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
* Fix potential race introduced in Icd7f5f03Brad Fitzpatrick2011-03-171-14/+17
| | | | | | | | | | | | 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
* SocketClient: add optional reference countingBrad Fitzpatrick2011-03-171-0/+21
| | | | | | | Needed to fix a race in netd. Bug: 3438459 Change-Id: Icd7f5f035510235f733a25c0621479d3e644b152
* libsysutils: Handle EINTR in SocketClient::sendData()David 'Digit' Turner2011-01-191-13/+29
| | | | | | + Improve allocation code in sendMsg(code,msg,addErrno) Change-Id: Ib5fe84bec1a167c369e7ba759acea395e832f6b5
* Permit 0 length writes.Brad Fitzpatrick2010-11-021-0/+4
| | | | Change-Id: I087d0074c8d9e13ce814187475966da94f693fc0
* Let SocketClient users write binary data to clients.Brad Fitzpatrick2010-10-271-5/+13
| | | | | | | | | | 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
* Fetch peer credentials for local socketsKenny Root2010-09-141-2/+18
| | | | | | | 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
* system/core: Switch libsysutils & sched_policy LOG -> SLOGSan Mehat2010-03-251-2/+2
| | | | | Change-Id: Id74c6895a8012c5915f2e259339101844de7c085 Signed-off-by: San Mehat <san@google.com>
* libsysutils: Move to a null terminated string protocol using space as a ↵San Mehat2009-06-151-12/+3
| | | | | | | | field separator. Also removes some debugging Signed-off-by: San Mehat <san@google.com>
* libsysutils: Fix command argument passing bug + whitespace cleanupSan Mehat2009-05-291-2/+2
| | | | Signed-off-by: San Mehat <san@google.com>
* libsysutils: const correctness fixes + remove some debuggingSan Mehat2009-05-201-10/+11
| | | | Signed-off-by: San Mehat <san@google.com>
* libsysutils: General clean up + disable build in simulator buildsSan Mehat2009-05-131-2/+0
| | | | Signed-off-by: San Mehat <san@google.com>
* libsysutils: Tweak SocketListener and friendsSan Mehat2009-05-121-14/+41
| | | | Signed-off-by: San Mehat <san@google.com>
* libsysutils: Add multiple client support and fix some bugsSan Mehat2009-05-101-0/+41