summaryrefslogtreecommitdiff
path: root/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc')
-rw-r--r--src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc b/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc
index f520841a47..5e9f3d941d 100644
--- a/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc
+++ b/src/components/transport_manager/src/transport_adapter/threaded_socket_connection.cc
@@ -49,19 +49,20 @@ namespace transport_adapter {
CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
ThreadedSocketConnection::ThreadedSocketConnection(
- const DeviceUID& device_id, const ApplicationHandle& app_handle,
+ const DeviceUID& device_id,
+ const ApplicationHandle& app_handle,
TransportAdapterController* controller)
- : read_fd_(-1),
- write_fd_(-1),
- controller_(controller),
- frames_to_send_(),
- frames_to_send_mutex_(),
- socket_(-1),
- terminate_flag_(false),
- unexpected_disconnect_(false),
- device_uid_(device_id),
- app_handle_(app_handle),
- thread_(NULL) {
+ : read_fd_(-1)
+ , write_fd_(-1)
+ , controller_(controller)
+ , frames_to_send_()
+ , frames_to_send_mutex_()
+ , socket_(-1)
+ , terminate_flag_(false)
+ , unexpected_disconnect_(false)
+ , device_uid_(device_id)
+ , app_handle_(app_handle)
+ , thread_(NULL) {
const std::string thread_name = std::string("Socket ") + device_handle();
thread_ = threads::CreateThread(thread_name.c_str(),
new SocketConnectionDelegate(this));
@@ -100,8 +101,8 @@ TransportAdapter::Error ThreadedSocketConnection::Start() {
LOG4CXX_ERROR(logger_, "pipe creation failed");
return TransportAdapter::FAIL;
}
- const int fcntl_ret = fcntl(read_fd_, F_SETFL,
- fcntl(read_fd_, F_GETFL) | O_NONBLOCK);
+ const int fcntl_ret =
+ fcntl(read_fd_, F_SETFL, fcntl(read_fd_, F_GETFL) | O_NONBLOCK);
if (0 != fcntl_ret) {
LOG4CXX_ERROR(logger_, "fcntl failed");
return TransportAdapter::FAIL;
@@ -119,8 +120,8 @@ void ThreadedSocketConnection::Finalize() {
LOG4CXX_AUTO_TRACE(logger_);
if (unexpected_disconnect_) {
LOG4CXX_DEBUG(logger_, "unexpected_disconnect");
- controller_->ConnectionAborted(device_handle(), application_handle(),
- CommunicationError());
+ controller_->ConnectionAborted(
+ device_handle(), application_handle(), CommunicationError());
} else {
LOG4CXX_DEBUG(logger_, "not unexpected_disconnect");
controller_->ConnectionFinished(device_handle(), application_handle());
@@ -161,7 +162,7 @@ TransportAdapter::Error ThreadedSocketConnection::Disconnect() {
void ThreadedSocketConnection::threadMain() {
LOG4CXX_AUTO_TRACE(logger_);
- controller_->ConnectionCreated(this, device_uid_, app_handle_);
+ controller_->ConnectionCreated(this, device_handle(), application_handle());
ConnectError* connect_error = NULL;
if (!Establish(&connect_error)) {
LOG4CXX_ERROR(logger_, "Connection Establish failed");
@@ -179,8 +180,8 @@ void ThreadedSocketConnection::threadMain() {
LOG4CXX_INFO(logger_, "removing message");
::protocol_handler::RawMessagePtr message = frames_to_send_.front();
frames_to_send_.pop();
- controller_->DataSendFailed(device_handle(), application_handle(),
- message, DataSendError());
+ controller_->DataSendFailed(
+ device_handle(), application_handle(), message, DataSendError());
}
}
@@ -199,8 +200,8 @@ void ThreadedSocketConnection::Transmit() {
const bool is_queue_empty_on_poll = IsFramesToSendQueueEmpty();
- poll_fds[0].events = POLLIN | POLLPRI
- | (is_queue_empty_on_poll ? 0 : POLLOUT);
+ poll_fds[0].events =
+ POLLIN | POLLPRI | (is_queue_empty_on_poll ? 0 : POLLOUT);
poll_fds[1].fd = read_fd_;
poll_fds[1].events = POLLIN | POLLPRI;
@@ -210,10 +211,10 @@ void ThreadedSocketConnection::Transmit() {
Abort();
return;
}
- LOG4CXX_DEBUG(
- logger_,
- "poll is ok " << this << " revents0: " << std::hex << poll_fds[0].revents <<
- " revents1:" << std::hex << poll_fds[1].revents);
+ LOG4CXX_DEBUG(logger_,
+ "poll is ok " << this << " revents0: " << std::hex
+ << poll_fds[0].revents << " revents1:" << std::hex
+ << poll_fds[1].revents);
// error check
if (0 != (poll_fds[1].revents & (POLLERR | POLLHUP | POLLNVAL))) {
LOG4CXX_ERROR(logger_,
@@ -276,13 +277,13 @@ bool ThreadedSocketConnection::Receive() {
bytes_read = recv(socket_, buffer, sizeof(buffer), MSG_DONTWAIT);
if (bytes_read > 0) {
- LOG4CXX_DEBUG(
- logger_,
- "Received " << bytes_read << " bytes for connection " << this);
+ LOG4CXX_DEBUG(logger_,
+ "Received " << bytes_read << " bytes for connection "
+ << this);
::protocol_handler::RawMessagePtr frame(
new protocol_handler::RawMessage(0, 0, buffer, bytes_read));
- controller_->DataReceiveDone(device_handle(), application_handle(),
- frame);
+ controller_->DataReceiveDone(
+ device_handle(), application_handle(), frame);
} else if (bytes_read < 0) {
if (EAGAIN != errno && EWOULDBLOCK != errno) {
LOG4CXX_ERROR_WITH_ERRNO(logger_,
@@ -311,8 +312,8 @@ bool ThreadedSocketConnection::Send() {
while (!frames_to_send_local.empty()) {
LOG4CXX_INFO(logger_, "frames_to_send is not empty");
::protocol_handler::RawMessagePtr frame = frames_to_send_local.front();
- const ssize_t bytes_sent = ::send(socket_, frame->data() + offset,
- frame->data_size() - offset, 0);
+ const ssize_t bytes_sent =
+ ::send(socket_, frame->data() + offset, frame->data_size() - offset, 0);
if (bytes_sent >= 0) {
LOG4CXX_DEBUG(logger_, "bytes_sent >= 0");
@@ -327,8 +328,8 @@ bool ThreadedSocketConnection::Send() {
LOG4CXX_ERROR_WITH_ERRNO(logger_, "Send failed for connection " << this);
frames_to_send_local.pop();
offset = 0;
- controller_->DataSendFailed(device_handle(), application_handle(), frame,
- DataSendError());
+ controller_->DataSendFailed(
+ device_handle(), application_handle(), frame, DataSendError());
}
}
@@ -337,8 +338,7 @@ bool ThreadedSocketConnection::Send() {
ThreadedSocketConnection::SocketConnectionDelegate::SocketConnectionDelegate(
ThreadedSocketConnection* connection)
- : connection_(connection) {
-}
+ : connection_(connection) {}
void ThreadedSocketConnection::SocketConnectionDelegate::threadMain() {
LOG4CXX_AUTO_TRACE(logger_);