X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=dccp_send.c;h=c7805f735b02c096083058d269ee4b0d2ee6b759;hb=6817a8f0c4f649168a43fc347179771600a908fc;hp=ace92dee9f13ae2037e34279751494bf4245a00e;hpb=c9f109a9e7f2d6116b7906a852afc339c858c275;p=paraslash.git diff --git a/dccp_send.c b/dccp_send.c index ace92dee..c7805f73 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -1,3 +1,26 @@ +/* + * Copyright (C) 2006 Andre Noll + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + */ + +/* + * based on server.c of dccp-cs-0.01.tar.bz2, + * (C) 2005 Ian McDonald + */ + #include "server.h" #include "net.h" #include "list.h" @@ -99,7 +122,12 @@ static void dccp_send(__unused struct audio_format *af, return; list_for_each_entry_safe(dc, tmp, &clients, node) { - if (!_write_ok(dc->fd)) + ret = write_ok(dc->fd); + if (ret < 0) { + dccp_shutdown_client(dc); + continue; + } + if (!ret) continue; if (!dc->header_sent && af->get_header_info && current_chunk) { header_buf = af->get_header_info(&header_len); @@ -107,13 +135,22 @@ static void dccp_send(__unused struct audio_format *af, continue; /* header not yet available */ ret = write(dc->fd, header_buf, header_len); if (ret != header_len) { + int err = errno; + PARA_ERROR_LOG("header write: %d/%d (%s)\n", + ret, header_len, ret < 0? + strerror(err) : ""); + dccp_shutdown_client(dc); + continue; + } + ret = write_ok(dc->fd); + if (ret < 0) { dccp_shutdown_client(dc); continue; } - if (!_write_ok(dc->fd)) + if (!ret) continue; } - PARA_DEBUG_LOG("writing %d bytes to fd %d\n", len, dc->fd); +// PARA_DEBUG_LOG("writing %d bytes to fd %d\n", len, dc->fd); ret = write(dc->fd, buf, len); if (ret != len) dccp_shutdown_client(dc);