Commit c9ac4b7f authored by brendan's avatar brendan
Browse files

cleanups to last commit (loop over short writes)

svn path=/icecast/trunk/libshout/; revision=8552
parent a455b815
/* -*- c-basic-offset: 8; -*- */
/* shout.c: Implementation of public libshout interface shout.h
* $Id$
*
* Copyright (C) 2002-2004 the Icecast team <team@icecast.org>
*
......@@ -1003,18 +1002,15 @@ static int try_connect (shout_t *self)
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 @@ static int try_write (shout_t *self, const void *data, size_t len)
return 0;
}
self->error = SHOUTERR_SOCKET;
return ret;
}
return pos;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment