[asterisk-commits] wedhorn: branch wedhorn/skinny-session r384239 - /team/wedhorn/skinny-session...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Mar 28 04:16:09 CDT 2013
Author: wedhorn
Date: Thu Mar 28 04:15:31 2013
New Revision: 384239
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384239
Log:
skinny: add in fragmented packet handling
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=384239&r1=384238&r2=384239
==============================================================================
--- team/wedhorn/skinny-session/channels/chan_skinny.c (original)
+++ team/wedhorn/skinny-session/channels/chan_skinny.c Thu Mar 28 04:15:31 2013
@@ -7512,16 +7512,32 @@
ast_log(LOG_WARNING, "Skinny packet too large (%d bytes), max length(%d bytes)\n", dlen+8, SKINNY_MAX_PACKET);
break;
}
-
- if ((res = read(s->fd, &req->data, dlen)) != dlen) {
- if (res < 0) {
- ast_log(LOG_WARNING, "Data read() returned error: %s\n", strerror(errno));
- } else {
- ast_log(LOG_WARNING, "Unable to read data. Only found %d bytes.\n", res);
+
+ res = 0;
+ while (1) {
+ int bytesread = res;
+ if ((res = read(s->fd, &req->data+bytesread, dlen-bytesread)) < 0) {
+ break;
}
+ res += bytesread;
+ if (res >= dlen) {
+ break;
+ }
+ ast_log(LOG_WARNING, "Partial data received, waiting\n");
+ if (sched_yield() < 0) {
+ ast_log(LOG_WARNING, "Data yield() returned error: %s\n", strerror(errno));
+ 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;
+ }
+
ast_mutex_unlock(&s->lock);
lockstate = 0;
More information about the asterisk-commits
mailing list