[asterisk-commits] wedhorn: branch wedhorn/skinny-session r383963 - /team/wedhorn/skinny-session...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 27 03:21:31 CDT 2013


Author: wedhorn
Date: Wed Mar 27 03:21:28 2013
New Revision: 383963

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383963
Log:
skinny: move destroy session to end of skinny_session, change return to break and check session on session start.

Modified:
    team/wedhorn/skinny-session/channels/chan_skinny.c

Modified: team/wedhorn/skinny-session/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/wedhorn/skinny-session/channels/chan_skinny.c?view=diff&rev=383963&r1=383962&r2=383963
==============================================================================
--- team/wedhorn/skinny-session/channels/chan_skinny.c (original)
+++ team/wedhorn/skinny-session/channels/chan_skinny.c Wed Mar 27 03:21:28 2013
@@ -7443,6 +7443,11 @@
 	int *bufaddr;
 	struct pollfd fds[1];
 
+	if (!s) {
+		ast_verb(3, "Bad Skinny Session\n");
+		return 0;
+	}
+
 	ast_verb(3, "Starting Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
 
 	for (;;) {
@@ -7451,16 +7456,14 @@
 			if(time(&now) == -1) {
 				ast_log(LOG_ERROR, "error executing time(): %s\n", strerror(errno));
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 			timeout = (auth_timeout - (now - s->start)) * 1000;
 			if (timeout < 0) {
 				/* we have timed out */
 				ast_log(LOG_WARNING, "Skinny Client failed to authenticate in %d seconds\n", auth_timeout);
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 		} else {
 			timeout = keep_alive * 1100;
@@ -7476,8 +7479,7 @@
 			if (errno != EINTR) {
 				ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 		} else if (res == 0) {
 			if (s->device) {
@@ -7487,8 +7489,7 @@
 			}
 			skinny_unregister(NULL, s);
 			ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-			destroy_session(s);
-			return NULL;
+			break;
 		}
 
 		if (fds[0].revents) {
@@ -7503,8 +7504,7 @@
 				skinny_unregister(NULL, s);
 				ast_mutex_unlock(&s->lock);
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			} else if (res != 4) {
 				ast_log(LOG_WARNING, "Skinny Client sent less data than expected.  Expected 4 but got %d.\n", res);
 				ast_mutex_unlock(&s->lock);
@@ -7514,8 +7514,7 @@
 					skinny_unregister(NULL, s);
 				}
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 
 			bufaddr = (int *)s->inbuf;
@@ -7524,8 +7523,7 @@
 				ast_log(LOG_WARNING, "Skinny Client sent invalid data.\n");
 				ast_mutex_unlock(&s->lock);
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 			if (dlen+8 > sizeof(s->inbuf)) {
 				ast_log(LOG_WARNING, "Skinny packet too large (%d bytes), max length(%d bytes)\n", dlen+8, SKINNY_MAX_PACKET);
@@ -7538,21 +7536,18 @@
 			if (res < 0) {
 				ast_log(LOG_WARNING, "read() returned error: %s\n", strerror(errno));
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			} else if (res != (dlen+4)) {
 				ast_log(LOG_WARNING, "Skinny Client sent less data than expected.\n");
 				ast_verb(3, "Ending Skinny session from %s (bad input)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 		}
 
 		if (res > 0) {
 			if (!(req = ast_calloc(1, SKINNY_MAX_PACKET))) {
 				ast_verb(3, "Ending Skinny session from %s (failed parse)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 
 			ast_mutex_lock(&s->lock);
@@ -7566,22 +7561,19 @@
 				ast_log(LOG_ERROR, "Event Message is NULL from socket %d, This is bad\n", s->fd);
 				ast_free(req);
 				ast_verb(3, "Ending Skinny session from %s (failed parse)\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
+				break;
 			}
 
 			res = handle_message(req, s);
 			if (res < 0) {
 				ast_verb(3, "Ending Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
-				destroy_session(s);
-				return NULL;
-			}
-		}
-	}
+				break;
+			}
+		}
+	}
+
 	ast_debug(3, "Skinny Session returned: %s\n", strerror(errno));
-
-	if (s)
-		destroy_session(s);
+	destroy_session(s);
 
 	return 0;
 }




More information about the asterisk-commits mailing list