[xiph-cvs] cvs commit: icecast/src source.c

Michael Smith msmith at xiph.org
Tue May 7 22:18:43 PDT 2002



msmith      02/05/07 22:18:43

  Modified:    src      source.c
  Log:
  Ensure we don't throw away a buffer after only sending part of it.

Revision  Changes    Path
1.12      +18 -4     icecast/src/source.c

Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- source.c	2002/04/05 09:28:25	1.11
+++ source.c	2002/05/08 05:18:43	1.12
@@ -217,14 +217,21 @@
                                         bytes = abuf->len;
 
                                 sbytes = sock_write_bytes(client->con->sock, &abuf->data[client->pos], bytes);
-				if (sbytes >= 0) client->con->sent_bytes += sbytes;
+				if (sbytes >= 0) {
+                    client->con->sent_bytes += sbytes;
+                    if(sbytes != bytes) {
+                        client->pos += sbytes;
+                        refbuf_queue_insert(&client->queue, abuf);
+                        data_done = 1;
+                        break;
+                    }
+                }
                                 if (sbytes < 0) {
                                         if (!sock_recoverable(sock_error())) {
                                                 printf("SOURCE: Client had unrecoverable error catching up (%ld/%ld)\n", sbytes, bytes);
                                                 client->con->error = 1;
                                         } else {
                                                 printf("SOURCE: client had recoverable error...\n");
-						client->pos += sbytes>0?sbytes:0;
                                                 /* put the refbuf back on top of the queue, since we didn't finish with it */
                                                 refbuf_queue_insert(&client->queue, abuf);
                                         }
@@ -246,7 +253,14 @@
                                 refbuf_queue_add(&client->queue, refbuf);
                         } else {
                                 sbytes = sock_write_bytes(client->con->sock, refbuf->data, refbuf->len);
-				if (sbytes >= 0) client->con->sent_bytes += sbytes;
+				if (sbytes >= 0) {
+                    client->con->sent_bytes += sbytes;
+                    if(sbytes != bytes) {
+                        client->pos = sbytes;
+						refbuf_addref(refbuf);
+                        refbuf_queue_insert(&client->queue, abuf);
+                    }
+                }
                                 if (sbytes < 0) {
                                         bytes = sock_error();
                                         if (!sock_recoverable(bytes)) {
@@ -254,7 +268,7 @@
                                                 client->con->error = 1;
                                         } else {
                                                 printf("SOURCE: recoverable error %ld\n", bytes);
-						client->pos = sbytes > 0 ? sbytes : 0;
+						client->pos = 0;
                                                 refbuf_addref(refbuf);
                                                 refbuf_queue_insert(&client->queue, refbuf);
                                         }

<p><p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list