[xiph-commits] r7356 - icecast/trunk/libshout/src

brendan at dactyl.lonelymoon.com brendan
Mon Jul 26 14:20:31 PDT 2004


Author: brendan
Date: Mon Jul 26 14:20:31 2004
New Revision: 7356

Modified:
icecast/trunk/libshout/src/shout.c
Log:
Full nonblocking IO support, per the API spec posted to the list.
Not very well tested.


Modified: icecast/trunk/libshout/src/shout.c
===================================================================
--- icecast/trunk/libshout/src/shout.c	2004-07-26 20:11:39 UTC (rev 7355)
+++ icecast/trunk/libshout/src/shout.c	2004-07-26 21:20:29 UTC (rev 7356)
@@ -183,13 +183,15 @@
if (self->starttime <= 0)
self->starttime = timing_get_time();

+	if (!len)
+		return send_queue(self);
+
return self->send(self, data, len);
}

ssize_t shout_send_raw(shout_t *self, const unsigned char *data, size_t len)
{
ssize_t ret;
-	size_t remaining = len;

if (!self)
return SHOUTERR_INSANE;
@@ -199,20 +201,12 @@

self->error = SHOUTERR_SUCCESS;

-	while(remaining) {
-		ret = sock_write_bytes(self->socket, data, remaining);
-		if(ret == (ssize_t)remaining)
-			return len;
-		else if(ret < 0) {
-			if(errno == EINTR)
-				ret = 0;
-			else
-				return self->error = SHOUTERR_SOCKET;
-		}
-		remaining -= ret;
-	}
+	queue_data(&self->wqueue, data, len);
+	ret = send_queue(self);
+	if (ret == SHOUTERR_SUCCESS || (len && ret == SHOUTERR_BUSY))
+		return len;

-	return len;
+	return ret;
}

void shout_sync(shout_t *self)



More information about the commits mailing list