tizen 2.4 release
[framework/web/wrt-commons.git] / modules / socket / src / unix_socket.cpp
old mode 100644 (file)
new mode 100755 (executable)
similarity index 90%
rename from modules_wearable/socket/src/unix_socket.cpp
rename to modules/socket/src/unix_socket.cpp
index 36bff51..ae577f7
@@ -21,7 +21,7 @@
  */
 #include <stddef.h>
 #include <dpl/socket/unix_socket.h>
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
 #include <dpl/exception.h>
 #include <new>
 #include <sys/socket.h>
@@ -39,7 +39,7 @@ UnixSocket::UnixSocket()
 
 int UnixSocket::AllocSpecificDescriptor() const
 {
-    LogPedantic("Creating UNIX socket...");
+    WrtLogD("Creating UNIX socket...");
 
     // Create new descriptor
     int newSocket = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -48,7 +48,7 @@ int UnixSocket::AllocSpecificDescriptor() const
         Throw(Exception::CreateFailed);
     }
 
-    LogPedantic("UNIX socket created");
+    WrtLogD("UNIX socket created");
 
     // Return new descriptor
     return newSocket;
@@ -102,6 +102,8 @@ UnixSocket *UnixSocket::AllocAcceptedSpecificSocket() const
 
 void UnixSocket::Bind(const Address &address)
 {
+    char *errstr =  NULL;
+    char errbuf[512] = {0,};
     // Always remove socket file if any
     unlink(address.GetAddress().c_str());
 
@@ -110,9 +112,14 @@ void UnixSocket::Bind(const Address &address)
 
     // Always set proper permissions to the socket file
     if (chmod(address.GetAddress().c_str(), 0777) < 0) {
-        LogError(
-            "Error setting permissions to the socket file. Errno " <<
-            strerror(errno));
+#ifdef _GNU_SOURCE
+        errstr = strerror_r(errno, errbuf, sizeof(errbuf));
+#else
+        strerror_r(errno, errbuf, sizeof(errbuf));
+        errstr = errbuf;
+#endif
+        WrtLogE(
+            "Error setting permissions to the socket file. Errno %s", errstr);
     }
 }
 }