[xiph-commits] r8136 - icecast/trunk/libshout/src
brendan at motherfish-iii.xiph.org
brendan at motherfish-iii.xiph.org
Fri Oct 29 13:05:07 PDT 2004
Author: brendan
Date: 2004-10-29 13:05:07 -0700 (Fri, 29 Oct 2004)
New Revision: 8136
Modified:
icecast/trunk/libshout/src/shout.c
Log:
Per Karl, only queue data if it can't be sent right away (should
significantly reduce malloc/free overhead in the common case).
Modified: icecast/trunk/libshout/src/shout.c
===================================================================
--- icecast/trunk/libshout/src/shout.c 2004-10-29 17:43:19 UTC (rev 8135)
+++ icecast/trunk/libshout/src/shout.c 2004-10-29 20:05:07 UTC (rev 8136)
@@ -201,7 +201,23 @@
self->error = SHOUTERR_SUCCESS;
- queue_data(&self->wqueue, data, len);
+ /* send immediately if possible (should be the common case) */
+ if (len && ! self->wqueue) {
+ if ((ret = try_write(self, data, len)) < 0)
+ return self->error;
+ if (ret < len) {
+ self->error = queue_data(&self->wqueue, data + ret, len - ret);
+ if (self->error != SHOUTERR_SUCCESS)
+ return self->error;
+ }
+
+ return len;
+ }
+
+ self->error = queue_data(&self->wqueue, data, len);
+ if (self->error != SHOUTERR_SUCCESS)
+ return self->error;
+
ret = send_queue(self);
if (ret == SHOUTERR_SUCCESS || (len && ret == SHOUTERR_BUSY))
return len;
More information about the commits
mailing list