Change the recv/send socket buffer size.
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 22 Jul 2013 06:01:22 +0000 (15:01 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Mon, 22 Jul 2013 06:01:22 +0000 (15:01 +0900)
Recv bufsz: 512KB (kernel will double this to 1MB)
Send bufsz: 256KB (kernel will double this to 512KB)
This change is only can be applied by selection of kernel.
So even if I change this, the kernel can change it what it can support.

Change-Id: Ic3119dd82bbaf3845ac34fcf39f2f099cb9a70eb

packaging/libcom-core.spec
src/secure_socket.c

index 3e49cc3..b4abc22 100644 (file)
@@ -1,6 +1,6 @@
 Name: libcom-core
 Summary: Library for the light-weight IPC 
-Version: 0.4.4
+Version: 0.4.5
 Release: 1
 Group: HomeTF/Framework
 License: Apache License
index 8c6c93e..6217bb7 100644 (file)
@@ -34,6 +34,8 @@
 #include "util.h"
 
 #define BACKLOG 50     /*!< Accept only 50 connections as default */
+#define SNDBUF_SZ      262144
+#define RCVBUF_SZ      524288
 
 int errno;
 
@@ -71,6 +73,8 @@ EAPI int secure_socket_create_client(const char *peer)
        int handle;
        int state;
        int on = 1;
+       int sndbuf = SNDBUF_SZ;
+       int rcvbuf = RCVBUF_SZ;
 
        handle = create_socket(peer, &addr);
        if (handle < 0)
@@ -93,6 +97,18 @@ EAPI int secure_socket_create_client(const char *peer)
                return -EFAULT;
        }
 
+       if (setsockopt(handle, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf)) < 0) {
+               ErrPrint("Failed to change rcvbuf size: %s\n", strerror(errno));
+       } else {
+               DbgPrint("rcvbuf: %d\n", rcvbuf);
+       }
+
+       if (setsockopt(handle, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)) < 0) {
+               ErrPrint("Failed to change rcvbuf size: %s\n", strerror(errno));
+       } else {
+               DbgPrint("sndbuf: %d\n", sndbuf);
+       }
+
        return handle;
 }
 
@@ -141,6 +157,8 @@ EAPI int secure_socket_get_connection_handle(int server_handle)
        int handle;
        int on = 1;
        socklen_t size = sizeof(addr);
+       int sndbuf = SNDBUF_SZ;
+       int rcvbuf = RCVBUF_SZ;
 
        handle = accept(server_handle, (struct sockaddr *)&addr, &size);
        if (handle < 0) {
@@ -158,6 +176,18 @@ EAPI int secure_socket_get_connection_handle(int server_handle)
                return ret;
        }
 
+       if (setsockopt(handle, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf)) < 0) {
+               ErrPrint("Failed to change rcvbuf size: %s\n", strerror(errno));
+       } else {
+               DbgPrint("rcvbuf: %d\n", rcvbuf);
+       }
+
+       if (setsockopt(handle, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)) < 0) {
+               ErrPrint("Failed to change rcvbuf size: %s\n", strerror(errno));
+       } else {
+               DbgPrint("sndbuf: %d\n", sndbuf);
+       }
+
        return handle;
 }