[asterisk-commits] wedhorn: trunk r405925 - in /trunk: ./ channels/chan_skinny.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 20 15:56:16 CST 2014


Author: wedhorn
Date: Mon Jan 20 15:56:14 2014
New Revision: 405925

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405925
Log:
Skinny: fix up session logging.

Logging from the skinny session loop was providing some incorrect reasons
for exiting the loop. Cleaned up messages and handling so correct reason
displayed.
........

Merged revisions 405924 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/channels/chan_skinny.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=405925&r1=405924&r2=405925
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Mon Jan 20 15:56:14 2014
@@ -7471,7 +7471,7 @@
 	struct skinny_line *l;
 	struct skinny_speeddial *sd;
 
-	ast_verb(3, "Ending Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
+	ast_verb(3, "Ending Skinny session from %s at %s\n", d ? d->name : "unknown", ast_inet_ntoa(s->sin.sin_addr));
 
 	if (s->lockstate) {
 		ast_mutex_unlock(&s->lock);
@@ -7517,6 +7517,7 @@
 static void *skinny_session(void *data)
 {
 	int res;
+	int bytesread;
 	struct skinny_req *req = NULL;
 	struct skinnysession *s = data;
 
@@ -7592,41 +7593,41 @@
 				break;
 			}
 
-			res = 0;
+			bytesread = 0;
 			while (1) {
-				int bytesread = res;
 				if ((res = read(s->fd, &req->data+bytesread, dlen-bytesread)) < 0) {
+					ast_log(LOG_WARNING, "Data read() returned error: %s\n", strerror(errno));
 					break;
 				}
-				res += bytesread;
-				if (res >= dlen) {
+				bytesread += res;
+				if (bytesread >= dlen) {
+					if (res < bytesread) {
+						ast_log(LOG_WARNING, "Rest of partial data received.\n");
+					}
+					if (bytesread > dlen) {
+						ast_log(LOG_WARNING, "Client sent wrong amount of data (%d), expected (%d).\n", bytesread, dlen);
+						res = -1;
+					}
 					break;
 				}
-				ast_log(LOG_WARNING, "Partial data received, waiting (%d bytes read of %d)\n", res, dlen);
+
+				ast_log(LOG_WARNING, "Partial data received, waiting (%d bytes read of %d)\n", bytesread, dlen);
 				if (sched_yield() < 0) {
 					ast_log(LOG_WARNING, "Data yield() returned error: %s\n", strerror(errno));
+					res = -1;
 					break;
 				}
 			}
-			if (res < 0) {
-				ast_log(LOG_WARNING, "Data read() returned error: %s\n", strerror(errno));
-				break;
-			}
-			if (res != dlen) {
-				ast_log(LOG_WARNING, "Client sent wrong amount of data (%d), expected (%d).\n", res, dlen);
-				break;
-			}
 
 			s->lockstate = 0;
 			ast_mutex_unlock(&s->lock);
+			if (res < 0) {
+				break;
+			}
 
 			pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
 			res = handle_message(req, s);
 			pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
-			if (res < 0) {
-				ast_verb(3, "Ending Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
-				break;
-			}
 		}
 
 		if (req) {




More information about the asterisk-commits mailing list