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

brendan at motherfish-iii.xiph.org brendan at motherfish-iii.xiph.org
Tue Dec 28 21:53:05 PST 2004


Author: brendan
Date: 2004-12-28 21:53:04 -0800 (Tue, 28 Dec 2004)
New Revision: 8552

Modified:
   icecast/trunk/libshout/src/shout.c
Log:
cleanups to last commit (loop over short writes)

Modified: icecast/trunk/libshout/src/shout.c
===================================================================
--- icecast/trunk/libshout/src/shout.c	2004-12-29 05:44:13 UTC (rev 8551)
+++ icecast/trunk/libshout/src/shout.c	2004-12-29 05:53:04 UTC (rev 8552)
@@ -1,6 +1,5 @@
 /* -*- c-basic-offset: 8; -*- */
 /* shout.c: Implementation of public libshout interface shout.h
- * $Id$
  *
  *  Copyright (C) 2002-2004 the Icecast team <team at icecast.org>
  *
@@ -1003,18 +1002,15 @@
 
 static int try_write (shout_t *self, const void *data, size_t len)
 {
-    /* loop until whole buffer is written (unless it would block) */
-    int write_unfinished = 1;
     int ret;
     size_t pos = 0;
 
+    /* loop until whole buffer is written (unless it would block) */
     do {
         ret = sock_write_bytes (self->socket, data + pos, len - pos);
         if (ret > 0)
             pos += ret;
-        if (pos == len)
-            write_unfinished = 0;
-    } while (write_unfinished && ret >= 0);
+    } while (pos < len && ret >= 0);
 
     if (ret < 0)
     {
@@ -1024,6 +1020,7 @@
             return 0;
         }
         self->error = SHOUTERR_SOCKET;
+        return ret;
     }
 
     return pos;



More information about the commits mailing list