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.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@405924 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Damien Wedhorn
2014-01-20 21:53:02 +00:00
parent d44c84fee0
commit 22aac2e4d6
+19 -18
View File
@@ -7471,7 +7471,7 @@ static void skinny_session_cleanup(void *data)
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_cleanup(void *data)
static void *skinny_session(void *data)
{
int res;
int bytesread;
struct skinny_req *req = NULL;
struct skinnysession *s = data;
@@ -7592,41 +7593,41 @@ static void *skinny_session(void *data)
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) {