Do not update chunk->size using return of recv.
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 30 Apr 2013 04:52:13 +0000 (13:52 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 30 Apr 2013 04:52:13 +0000 (13:52 +0900)
Update logging message

Change-Id: Ie877e765c80f66ac949d0c9826f4be10c69a1c18

src/com-core.c
src/com-core_thread.c

index 430a003..fea5ce1 100644 (file)
@@ -370,8 +370,10 @@ EAPI int com_core_recv(int handle, char *buffer, int size, int *sender_pid, doub
                                DbgPrint("Retry to get data (%d:%d)\n", readsize, size);
                                continue;
                        }
+                       DbgPrint("[%d] recv returns: %d\n", handle, ret);
                        return ret;
                } else if (ret == 0) {
+                       DbgPrint("Disconnected(req.size: %d)\n", size);
                        return 0;
                }
 
index 248a35d..cb93e4c 100644 (file)
@@ -351,25 +351,28 @@ static void *client_cb(void *data)
                        break;
                }
 
-               chunk->size = secure_socket_recv(tcb->handle, chunk->data, chunk->size, &chunk->pid);
-               if (chunk->size < 0) {
-                       ret = chunk->size;
+               ret = secure_socket_recv(tcb->handle, chunk->data, chunk->size, &chunk->pid);
+               if (ret <= 0) {
                        destroy_chunk(chunk);
                        if (ret == -EAGAIN) {
-                               DbgPrint("Retry to get data (%d)\n", readsize);
+                               DbgPrint("Retry to get data (%d)\n", chunk->size);
                                continue;
                        }
 
-                       ErrPrint("Recv returns: %d\n", ret);
+                       DbgPrint("Recv returns: %d (req.size: %d)\n", ret, chunk->size);
                        break;
                }
 
+               /* Update chunk size */
+               chunk->size = ret;
+
                /*!
                 * Count of chunk elements are same with PIPE'd data
                 */
                chunk_append(tcb, chunk);
        }
 
+       DbgPrint("Client CB is terminated (%d)\n", tcb->handle);
        /* Wake up main thread to get disconnected event */
        event_ch = EVENT_TERM;
        if (write(tcb->evt_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch))
@@ -856,7 +859,7 @@ EAPI int com_core_thread_recv(int handle, char *buffer, int size, int *sender_pi
                                } else if (event_ch == EVENT_READY) {
                                        ErrPrint("Failed to get a new chunk\n");
                                } else if (event_ch == EVENT_TERM) {
-                                       ErrPrint("Disconnected\n");
+                                       DbgPrint("Disconnected\n");
                                }
 
                                break;