Force logging server-side write() and close() operations 17/199517/4
authorTomasz Swierczek <t.swierczek@samsung.com>
Tue, 12 Feb 2019 09:24:34 +0000 (10:24 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Tue, 12 Feb 2019 10:44:30 +0000 (11:44 +0100)
In some cases on TV, client gets 0 from recv while it should receive
an int with status from server. At the same time, there are no error
logs from server side and no issues with systemd service perceived.

This patch is a temporary solution to force logging relevant actions
on server side, to check whether server actually properly processes data.

Logs were added as ErrorLog to make sure these are visible during robustness
tests of TV (where platform code is synced automatically).

This patch WILL BE REVERTED after 31.03

Change-Id: I9284c42b87e49d333261a4dde7aedeae5261343c

src/server/main/socket-manager.cpp
src/server/service/service.cpp

index ec0d6f705d7e927c05f9f8f528cd65729fc79f70..6728af28a813e229d352a777d0e0cfda441399c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2000 - 2019 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Contact: Rafal Krypa <r.krypa@samsung.com>
  *
@@ -310,6 +310,7 @@ void SocketManager::ReadyForWriteBuffer(int sock) {
     auto &desc = m_socketDescriptionVector[sock];
     size_t size = desc.rawBuffer.size();
     ssize_t result = write(sock, &desc.rawBuffer[0], size);
+    LogError("[DEBUG ONLY] write result : " << result << " writing size: " << size << " on sock " << sock);
     if (result == -1) {
         int err = errno;
         switch (err) {
@@ -650,13 +651,13 @@ void SocketManager::ProcessQueue() {
             auto &desc = m_socketDescriptionVector[buffer.connectionID.sock];
 
             if (!desc.isOpen) {
-                LogDebug("Received packet for write but connection is closed. Packet ignored!");
+                LogError("Received packet for write but connection is closed. Packet ignored!");
                 continue;
             }
 
             if (desc.counter != buffer.connectionID.counter)
             {
-                LogDebug("Received packet for write but counter is broken. Packet ignored!");
+                LogError("Received packet for write but counter is broken. Packet ignored!");
                 continue;
             }
 
@@ -722,7 +723,7 @@ void SocketManager::ProcessQueue() {
 }
 
 void SocketManager::CloseSocket(int sock) {
-//    LogInfo("Closing socket: " << sock);
+    LogError("[DEBUG ONLY] Closing socket: " << sock);
     auto &desc = m_socketDescriptionVector[sock];
 
     if (!(desc.isOpen)) {
@@ -752,6 +753,7 @@ void SocketManager::CloseSocket(int sock) {
     TEMP_FAILURE_RETRY(close(sock));
     FD_CLR(sock, &m_readSet);
     FD_CLR(sock, &m_writeSet);
+    LogError("[DEBUG ONLY] Closing socket done ");
 }
 
 } // namespace SecurityManager
index d8818665c41d3b7ad467082bf1a7e0df42cbc1d2..30b3dd73bf2ac0e807bd30664830ca878792a761 100644 (file)
@@ -198,7 +198,7 @@ bool Service::processOne(const ConnectionID &conn, MessageBuffer &buffer,
 
     if (retval) {
         //send response
-        LogDebug("Writing response to client, size of serialized response: " << send.SerializedSize());
+        LogError("Writing response to client, size of serialized response: " << send.SerializedSize());
         m_serviceManager->Write(conn, send.Pop());
     } else {
         LogError("Closing socket because of error");
@@ -366,11 +366,12 @@ void Service::processGroupsGet(MessageBuffer &send)
 {
     std::vector<gid_t> groups;
     int ret = serviceImpl.policyGetGroups(groups);
-
+    LogError("[DEBUG ONLY] policyGetGroups return value: " << ret);
     Serialization::Serialize(send, ret);
     if (ret == SECURITY_MANAGER_SUCCESS) {
         Serialization::Serialize(send, groups);
     }
+    LogError("[DEBUG ONLY] processGroupsGet send serialized size: " << send.SerializedSize());
 }
 
 void Service::processGroupsForUid(MessageBuffer &recv, MessageBuffer &send)