Remove high frequency log to avoid the log full with useless information
authorCaiwen Zhang <caiwen.zhang@intel.com>
Tue, 13 Jan 2015 06:58:06 +0000 (14:58 +0800)
committerCaiwen Zhang <caiwen.zhang@intel.com>
Wed, 14 Jan 2015 01:01:02 +0000 (09:01 +0800)
The OCProcess function is invoked in while loop. The functions that are
invoked by OCProcess will be invoked very frequently. If add log in these
functions, it may make the log full of useless information.

This patch removes frequent log from OCProcess/OCProcessPresence/
OCProcessCoAP/coap_read/OCRecvFrom function.

Signed-off-by: Caiwen Zhang<caiwen.zhang@intel.com>
Change-Id: Iabe182aca8430438085296cd16d69f5bde0626a8

resource/csdk/libcoap-4.1.1/net.c
resource/csdk/occoap/src/occoap.c
resource/csdk/ocsocket/src/ocsocket.c
resource/csdk/stack/src/ocstack.c

index dfc04ff..4acea0f 100644 (file)
@@ -916,9 +916,13 @@ int coap_read(coap_context_t *ctx, int sockfd) {
         goto error_early;
     }
 
-    if ((size_t) bytes_read < sizeof(coap_hdr_t)) {
-        debug("coap_read: discarded invalid frame\n");
-        goto error_early;
+    if (bytes_read == 0) {
+      goto error_early;
+    }
+
+    else if ((size_t) bytes_read < sizeof(coap_hdr_t)) {
+       debug("coap_read: discard invalid frame\n"); 
+       goto error_early;
     }
 
     if (pdu->version != COAP_DEFAULT_VERSION) {
index 30881ab..ccf428b 100644 (file)
@@ -909,8 +909,6 @@ OCStackResult OCStopCoAP() {
  * @return 0 - success, else - TBD error
  */
 OCStackResult OCProcessCoAP() {
-
-    OC_LOG(INFO, TAG, PCF("Entering OCProcessCoAP"));
     int read = 0;
     read = coap_read(gCoAPCtx, gCoAPCtx->sockfd);
     if(read > 0) {
index fb4b700..1593d94 100644 (file)
@@ -321,8 +321,6 @@ int32_t OCRecvFrom(int32_t sockfd, uint8_t* buf, uint32_t bufLen, uint32_t flags
     timeout.tv_usec = 5000;
     fd_set reads;
 
-    OC_LOG_V(DEBUG, MOD_NAME, "%s Begin", __func__ );
-
     FD_ZERO(&reads);
     FD_SET(sockfd, &reads);
     ret = select(sockfd + 1, &reads, NULL, NULL, &timeout);
@@ -331,7 +329,6 @@ int32_t OCRecvFrom(int32_t sockfd, uint8_t* buf, uint32_t bufLen, uint32_t flags
         return ret;
     }
     if (!FD_ISSET(sockfd, &reads)) {
-        OC_LOG(DEBUG, MOD_NAME, "No data to read");
         return ERR_SUCCESS;
     }
 
@@ -341,7 +338,7 @@ int32_t OCRecvFrom(int32_t sockfd, uint8_t* buf, uint32_t bufLen, uint32_t flags
     if (ret < 1) {
         OC_LOG(FATAL, MOD_NAME, "OCRecvFrom ERR");
     }
-    OC_LOG_V(DEBUG, MOD_NAME, "%s End", __func__ );
+
     return ret;
 }
 
index cdc2bf5..816b0e1 100644 (file)
@@ -735,7 +735,6 @@ OCStackResult OCProcessPresence()
     uint8_t ipAddr[4] = { 0 };
     uint16_t port = 0;
 
-    OC_LOG(INFO, TAG, PCF("Entering RequestPresence"));
     ClientCB* cbNode = NULL;
     OCDevAddr dst;
     OCClientResponse clientResponse;
@@ -827,9 +826,8 @@ exit:
  *     OC_STACK_OK    - no errors
  *     OC_STACK_ERROR - stack process error
  */
-OCStackResult OCProcess() {
-
-    OC_LOG(INFO, TAG, PCF("Entering OCProcess"));
+OCStackResult OCProcess()
+{
     #ifdef WITH_PRESENCE
     OCProcessPresence();
     #endif