am 108d3d74
: Merge "libsysutils: Handle EINTR in FrameworkClient.cpp" into honeycomb
* commit '108d3d74a805ad15d2cd2db47dad86f1082a59ba': libsysutils: Handle EINTR in FrameworkClient.cpp
This commit is contained in:
commit
75b9f6dc97
1 changed files with 6 additions and 4 deletions
|
@ -14,13 +14,15 @@ FrameworkClient::FrameworkClient(int socket) {
|
|||
}
|
||||
|
||||
int FrameworkClient::sendMsg(const char *msg) {
|
||||
int ret;
|
||||
if (mSocket < 0) {
|
||||
errno = EHOSTUNREACH;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mWriteMutex);
|
||||
if (write(mSocket, msg, strlen(msg) +1) < 0) {
|
||||
ret = TEMP_FAILURE_RETRY(write(mSocket, msg, strlen(msg) +1));
|
||||
if (ret < 0) {
|
||||
SLOGW("Unable to send msg '%s' (%s)", msg, strerror(errno));
|
||||
}
|
||||
pthread_mutex_unlock(&mWriteMutex);
|
||||
|
@ -28,13 +30,13 @@ int FrameworkClient::sendMsg(const char *msg) {
|
|||
}
|
||||
|
||||
int FrameworkClient::sendMsg(const char *msg, const char *data) {
|
||||
char *buffer = (char *) alloca(strlen(msg) + strlen(data) + 1);
|
||||
size_t bufflen = strlen(msg) + strlen(data) + 1;
|
||||
char *buffer = (char *) alloca(bufflen);
|
||||
if (!buffer) {
|
||||
errno = -ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
strcpy(buffer, msg);
|
||||
strcat(buffer, data);
|
||||
snprintf(buffer, bufflen, "%s%s", msg, data);
|
||||
return sendMsg(buffer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue