Index: pjproject/trunk/pjlib/include/pj/pool.h
===================================================================
--- pjproject/trunk/pjlib/include/pj/pool.h	(revision 5979)
+++ pjproject/trunk/pjlib/include/pj/pool.h	(revision 5980)
@@ -178,8 +178,5 @@
    static void my_perror(const char *title, pj_status_t status)
    {
-        char errmsg[PJ_ERR_MSG_SIZE];
-
-	pj_strerror(status, errmsg, sizeof(errmsg));
-	PJ_LOG(1,(THIS_FILE, "%s: %s [status=%d]", title, errmsg, status));
+	PJ_PERROR(1,(THIS_FILE, status, title));
    }
 
Index: pjproject/trunk/pjlib/src/pj/ioqueue_select.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/ioqueue_select.c	(revision 5979)
+++ pjproject/trunk/pjlib/src/pj/ioqueue_select.c	(revision 5980)
@@ -751,5 +751,5 @@
             status = pj_sock_getsockname(old_sock, &local_addr, &addr_len);
             if (status != PJ_SUCCESS) {
-                PJ_LOG(5,(THIS_FILE, "Error get socket name %d", status));
+                PJ_PERROR(5,(THIS_FILE, status, "Error get socket name"));
             	continue;
             }
@@ -758,5 +758,5 @@
             status = pj_sock_getpeername(old_sock, &rem_addr, &addr_len);
             if (status != PJ_SUCCESS) {
-                PJ_LOG(5,(THIS_FILE, "Error get peer name %d", status));
+                PJ_PERROR(5,(THIS_FILE, status, "Error get peer name"));
             } else {
             	flags |= HAS_PEER_ADDR;
@@ -767,10 +767,10 @@
                 status == PJ_STATUS_FROM_OS(EINVAL))
             {
-            	PJ_LOG(5,(THIS_FILE, "Error get qos param %d", status));
+            	PJ_PERROR(5,(THIS_FILE, status, "Error get qos param"));
             	continue;
             }
         
             if (status != PJ_SUCCESS) {
-            	PJ_LOG(5,(THIS_FILE, "Error get qos param %d", status));
+            	PJ_PERROR(5,(THIS_FILE, status, "Error get qos param"));
             } else {
             	flags |= HAS_QOS;
@@ -782,5 +782,5 @@
             status = pj_sock_close(old_sock);
        	    if (status != PJ_SUCCESS) {
-                PJ_LOG(5,(THIS_FILE, "Error closing socket %d", status));
+                PJ_PERROR(5,(THIS_FILE, status, "Error closing socket"));
             }
             
@@ -792,5 +792,5 @@
                                 &new_sock);
         if (status != PJ_SUCCESS) {
-            PJ_LOG(5,(THIS_FILE, "Error create socket %d", status));
+            PJ_PERROR(5,(THIS_FILE, status, "Error create socket"));
             continue;
         }
@@ -805,6 +805,5 @@
             status == PJ_STATUS_FROM_OS(EINVAL))
         {
-            PJ_LOG(5,(THIS_FILE, "Error set socket option %d",
-                      status));
+            PJ_PERROR(5,(THIS_FILE, status, "Error set socket option"));
             continue;
         }
@@ -826,5 +825,5 @@
             status = pj_sock_set_qos_params(new_sock, &qos_params);
             if (status == PJ_STATUS_FROM_OS(EINVAL)) {
-                PJ_LOG(5,(THIS_FILE, "Error set qos param %d", status));
+                PJ_PERROR(5,(THIS_FILE, status, "Error set qos param"));
                 continue;
             }
@@ -834,5 +833,5 @@
             status = pj_sock_connect(new_sock, &rem_addr, addr_len);
             if (status != PJ_SUCCESS) {
-                PJ_LOG(5,(THIS_FILE, "Error connect socket %d", status));
+                PJ_PERROR(5,(THIS_FILE, status, "Error connect socket"));
                 continue;
             }
@@ -889,5 +888,5 @@
 
     h->fd = PJ_INVALID_SOCKET;
-    PJ_PERROR(1,(THIS_FILE, status, "Error replacing socket [%d]", status));
+    PJ_PERROR(1,(THIS_FILE, status, "Error replacing socket %d", old_sock));
     pj_lock_release(h->ioqueue->lock);
     return PJ_ESOCKETSTOP;
Index: pjproject/trunk/pjlib/src/pj/ssl_sock_imp_common.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/ssl_sock_imp_common.c	(revision 5979)
+++ pjproject/trunk/pjlib/src/pj/ssl_sock_imp_common.c	(revision 5980)
@@ -226,12 +226,10 @@
 	    /* Handshake failed in accepting, destroy our self silently. */
 
-	    char errmsg[PJ_ERR_MSG_SIZE];
 	    char buf[PJ_INET6_ADDRSTRLEN+10];
 
-	    pj_strerror(status, errmsg, sizeof(errmsg));
-	    PJ_LOG(3,(ssock->pool->obj_name, "Handshake failed in accepting "
-		      "%s: %s",
-		      pj_sockaddr_print(&ssock->rem_addr, buf, sizeof(buf), 3),
-		      errmsg));
+	    PJ_PERROR(3,(ssock->pool->obj_name, status,
+			 "Handshake failed in accepting %s",
+			 pj_sockaddr_print(&ssock->rem_addr, buf,
+					   sizeof(buf), 3)));
 
 	    if (ssock->param.cb.on_accept_complete2) {
@@ -251,4 +249,5 @@
 	    if (ssock->param.timer_heap) {
 		pj_time_val interval = {0, PJ_SSL_SOCK_DELAYED_CLOSE_TIMEOUT};
+		pj_status_t status1;
 
 		ssock->ssl_state = SSL_STATE_NULL;
@@ -261,9 +260,10 @@
 		ssock->timer.id = TIMER_CLOSE;
 		pj_time_val_normalize(&interval);
-		if (pj_timer_heap_schedule(ssock->param.timer_heap, 
-					   &ssock->timer, &interval) != 0)
-		{
-	    	    PJ_LOG(3,(ssock->pool->obj_name, "Failed to schedule "
-		      	      "a delayed close. Race condition may occur."));
+		status1 = pj_timer_heap_schedule(ssock->param.timer_heap, 
+						 &ssock->timer, &interval);
+		if (status1 != PJ_SUCCESS) {
+	    	    PJ_PERROR(3,(ssock->pool->obj_name, status,
+				 "Failed to schedule a delayed close. "
+				 "Race condition may occur."));
 		    ssock->timer.id = TIMER_NONE;
 		    pj_ssl_sock_close(ssock);
Index: pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 5979)
+++ pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c	(revision 5980)
@@ -804,12 +804,12 @@
 		status = GET_SSL_STATUS(ssock);
 		if (cert->CA_file.slen) {
-		    PJ_LOG(1,(ssock->pool->obj_name,
-			      "Error loading CA list file '%s'",
-			      cert->CA_file.ptr));
+		    PJ_PERROR(1,(ssock->pool->obj_name, status,
+				 "Error loading CA list file '%s'",
+				 cert->CA_file.ptr));
 		}
 		if (cert->CA_path.slen) {
-		    PJ_LOG(1,(ssock->pool->obj_name,
-			      "Error loading CA path '%s'",
-			      cert->CA_path.ptr));
+		    PJ_PERROR(1,(ssock->pool->obj_name, status,
+				 "Error loading CA path '%s'",
+				 cert->CA_path.ptr));
 		}
 		SSL_CTX_free(ctx);
@@ -833,6 +833,7 @@
 	    if(rc != 1) {
 		status = GET_SSL_STATUS(ssock);
-		PJ_LOG(1,(ssock->pool->obj_name, "Error loading certificate "
-			  "chain file '%s'", cert->cert_file.ptr));
+		PJ_PERROR(1,(ssock->pool->obj_name, status,
+			     "Error loading certificate chain file '%s'",
+			     cert->cert_file.ptr));
 		SSL_CTX_free(ctx);
 		return status;
@@ -849,6 +850,7 @@
 	    if(rc != 1) {
 		status = GET_SSL_STATUS(ssock);
-		PJ_LOG(1,(ssock->pool->obj_name, "Error adding private key "
-			  "from '%s'", cert->privkey_file.ptr));
+		PJ_PERROR(1,(ssock->pool->obj_name, status,
+			     "Error adding private key from '%s'",
+			     cert->privkey_file.ptr));
 		SSL_CTX_free(ctx);
 		return status;
@@ -892,6 +894,6 @@
 		    if (rc != 1) {
 			status = GET_SSL_STATUS(ssock);
-			PJ_LOG(1, (ssock->pool->obj_name, "Error loading "
-				   "chain certificate from buffer"));
+			PJ_PERROR(1,(ssock->pool->obj_name, status,
+			      "Error loading chain certificate from buffer"));
 			X509_free(xcert);
 			BIO_free(cbio);
@@ -940,6 +942,6 @@
 		    if (rc != 1) {
 			status = GET_SSL_STATUS(ssock);
-			PJ_LOG(1, (ssock->pool->obj_name, "Error adding "
-				   "private key from buffer"));
+			PJ_PERROR(1,(ssock->pool->obj_name, status,
+				     "Error adding private key from buffer"));
 			EVP_PKEY_free(pkey);
 			BIO_free(kbio);
@@ -1004,6 +1006,6 @@
 			      "Additional certificate '%s' loaded.", cf));
 		} else {
-		    pj_perror(1, ssock->pool->obj_name, GET_SSL_STATUS(ssock),
-			      "Error loading certificate file '%s'", cf);
+		    PJ_PERROR(1,(ssock->pool->obj_name, GET_SSL_STATUS(ssock),
+				 "Error loading certificate file '%s'", cf));
 		    ERR_clear_error();
 		}
@@ -1306,5 +1308,5 @@
 static void set_entropy(pj_ssl_sock_t *ssock)
 {
-    int ret;
+    int ret = 0;
 
     switch (ssock->param.entropy_type) {
@@ -1324,13 +1326,13 @@
 	    break;
 	case PJ_SSL_ENTROPY_NONE:
-	    default:
-	    return;
+	default:
 	    break;
     }
 
     if (ret < 0) {
-	PJ_LOG(3, (ssock->pool->obj_name, "SSL failed to reseed with "
-					  "entropy type %d",
-			  		  ssock->param.entropy_type));
+	PJ_LOG(3, (ssock->pool->obj_name,
+		   "SSL failed to reseed with entropy type %d "
+		   "[native err=%d]",
+		   ssock->param.entropy_type, ret));
     }
 }
