logd: add thread setname
- permits easier determination of logd thread at fault in a stack trace from debuggerd. Bug: 14275676 Change-Id: Iac2c523147e2bcce34ab7ddcecd02582c5fa7cc0
This commit is contained in:
parent
ab3d49b035
commit
8daa9af02d
|
@ -21,6 +21,7 @@
|
|||
#include <netinet/in.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -66,8 +67,13 @@ CommandListener::ClearCmd::ClearCmd(LogBuffer *buf)
|
|||
, mBuf(*buf)
|
||||
{ }
|
||||
|
||||
static void setname() {
|
||||
prctl(PR_SET_NAME, "logd.control");
|
||||
}
|
||||
|
||||
int CommandListener::ClearCmd::runCommand(SocketClient *cli,
|
||||
int argc, char **argv) {
|
||||
setname();
|
||||
if (!clientHasLogCredentials(cli)) {
|
||||
cli->sendMsg("Permission Denied");
|
||||
return 0;
|
||||
|
@ -96,6 +102,7 @@ CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf)
|
|||
|
||||
int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli,
|
||||
int argc, char **argv) {
|
||||
setname();
|
||||
if (argc < 2) {
|
||||
cli->sendMsg("Missing Argument");
|
||||
return 0;
|
||||
|
@ -121,6 +128,7 @@ CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf)
|
|||
|
||||
int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli,
|
||||
int argc, char **argv) {
|
||||
setname();
|
||||
if (!clientHasLogCredentials(cli)) {
|
||||
cli->sendMsg("Permission Denied");
|
||||
return 0;
|
||||
|
@ -154,6 +162,7 @@ CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf)
|
|||
|
||||
int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli,
|
||||
int argc, char **argv) {
|
||||
setname();
|
||||
if (argc < 2) {
|
||||
cli->sendMsg("Missing Argument");
|
||||
return 0;
|
||||
|
@ -197,6 +206,7 @@ static void package_string(char **strp) {
|
|||
|
||||
int CommandListener::GetStatisticsCmd::runCommand(SocketClient *cli,
|
||||
int argc, char **argv) {
|
||||
setname();
|
||||
uid_t uid = cli->getUid();
|
||||
gid_t gid = cli->getGid();
|
||||
if (clientHasLogCredentials(cli)) {
|
||||
|
@ -236,6 +246,7 @@ CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf)
|
|||
|
||||
int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli,
|
||||
int /*argc*/, char ** /*argv*/) {
|
||||
setname();
|
||||
char *buf = NULL;
|
||||
mBuf.formatPrune(&buf);
|
||||
if (!buf) {
|
||||
|
@ -255,6 +266,7 @@ CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf)
|
|||
|
||||
int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli,
|
||||
int argc, char **argv) {
|
||||
setname();
|
||||
if (!clientHasLogCredentials(cli)) {
|
||||
cli->sendMsg("Permission Denied");
|
||||
return 0;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/klog.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include "libaudit.h"
|
||||
|
@ -34,6 +35,8 @@ LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmsg)
|
|||
}
|
||||
|
||||
bool LogAudit::onDataAvailable(SocketClient *cli) {
|
||||
prctl(PR_SET_NAME, "logd.auditd");
|
||||
|
||||
struct audit_message rep;
|
||||
|
||||
if (audit_get_reply(cli->getSocket(), &rep, GET_REPLY_BLOCKING, 0) < 0) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
@ -31,6 +32,8 @@ LogListener::LogListener(LogBuffer *buf, LogReader *reader)
|
|||
{ }
|
||||
|
||||
bool LogListener::onDataAvailable(SocketClient *cli) {
|
||||
prctl(PR_SET_NAME, "logd.writer");
|
||||
|
||||
char buffer[sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time)
|
||||
+ LOGGER_ENTRY_MAX_PAYLOAD];
|
||||
struct iovec iov = { buffer, sizeof(buffer) };
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <ctype.h>
|
||||
#include <poll.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <cutils/sockets.h>
|
||||
|
@ -36,6 +37,8 @@ void LogReader::notifyNewLog() {
|
|||
}
|
||||
|
||||
bool LogReader::onDataAvailable(SocketClient *cli) {
|
||||
prctl(PR_SET_NAME, "logd.reader");
|
||||
|
||||
char buffer[255];
|
||||
|
||||
int len = read(cli->getSocket(), buffer, sizeof(buffer) - 1);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <sys/prctl.h>
|
||||
|
||||
#include "FlushCommand.h"
|
||||
#include "LogBuffer.h"
|
||||
#include "LogTimes.h"
|
||||
|
@ -107,6 +109,8 @@ void LogTimeEntry::threadStop(void *obj) {
|
|||
}
|
||||
|
||||
void *LogTimeEntry::threadStart(void *obj) {
|
||||
prctl(PR_SET_NAME, "logd.reader.per");
|
||||
|
||||
LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj);
|
||||
|
||||
pthread_cleanup_push(threadStop, obj);
|
||||
|
|
Loading…
Reference in New Issue