From: Richard Kettlewell Date: Tue, 30 Mar 2010 21:30:17 +0000 (+0100) Subject: disorder-speaker now treats read errors as equivalent to EOF (apart X-Git-Tag: 5.0~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/de38ab9bf224a9803e79c1fd07890214dc3bf964 disorder-speaker now treats read errors as equivalent to EOF (apart from logging them) rather than calling disorder_fatal(). Should fix issue #51. --- diff --git a/CHANGES.html b/CHANGES.html index 9634289..51cf92b 100644 --- a/CHANGES.html +++ b/CHANGES.html @@ -244,6 +244,11 @@ span.command { Disobedience's 'When' column gets out of date + + #51 + Improved speaker process robustness + + (none) “found track in no collection” messages for scratches diff --git a/server/speaker.c b/server/speaker.c index ccdf1e1..a2c2e7c 100644 --- a/server/speaker.c +++ b/server/speaker.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder - * Copyright (C) 2005-2009 Richard Kettlewell + * Copyright (C) 2005-2010 Richard Kettlewell * Portions (C) 2007 Mark Wooding * * This program is free software: you can redistribute it and/or modify @@ -316,12 +316,16 @@ static int speaker_fill(struct track *t) { n = read(t->fd, t->buffer + where, left); } while(n < 0 && errno == EINTR); pthread_mutex_lock(&lock); - if(n < 0) { - if(errno != EAGAIN) - disorder_fatal(errno, "error reading sample stream"); + if(n < 0 && errno == EAGAIN) { + /* EAGAIN means more later */ rc = 0; - } else if(n == 0) { - D(("fill %s: eof detected", t->id)); + } else if(n <= 0) { + /* n=0 means EOF. n<0 means some error occurred. We log the error but + * otherwise treat it as identical to EOF. */ + if(n < 0) + disorder_error(errno, "error reading sample stream for %s", t->id); + else + D(("fill %s: eof detected", t->id)); t->eof = 1; /* A track always becomes playable at EOF; we're not going to see any * more data. */ @@ -521,7 +525,8 @@ static void mainloop(void) { D(("id %s fd %d", id, fd)); t = findtrack(id, 1/*create*/); if (write(fd, "", 1) < 0) /* write an ack */ - disorder_error(errno, "writing ack to inbound connection"); + disorder_error(errno, "writing ack to inbound connection for %s", + id); if(t->fd != -1) { disorder_error(0, "%s: already got a connection", id); xclose(fd);