X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fclient.cpp;h=ba0be5b44da51b11af152c59e1c6255c584ac958;hb=a1e6d14ce3a5d5415333a4d3def6c5504f4bc49b;hp=0e87e205055f6a5c796ce40f53a056fc4293ca01;hpb=e9e15ac445100aee25fb3314a3ad89e7142c33fb;p=xinema.git diff --git a/source/client.cpp b/source/client.cpp index 0e87e20..ba0be5b 100644 --- a/source/client.cpp +++ b/source/client.cpp @@ -24,7 +24,17 @@ Client::Client(Xinema &x, Net::StreamSocket *s): void Client::data_available() { char rbuf[1024]; - unsigned len = socket->read(rbuf, sizeof(rbuf)); + unsigned len; + try + { + len = socket->read(rbuf, sizeof(rbuf)); + } + catch(const std::exception &) + { + stale = true; + return; + } + buffer.append(rbuf, len); string::size_type start = 0; @@ -89,8 +99,16 @@ void Client::process_command(const string &cmd) void Client::send_reply(const string &reply) { - socket->write(reply); - socket->put('\n'); + Msp::MutexLock lock(mutex); + try + { + socket->write(reply); + socket->put('\n'); + } + catch(const std::exception &) + { + stale = true; + } } void Client::list_directory(const FS::Path &dn)