X-Git-Url: http://git.tdb.fi/?p=xinema.git;a=blobdiff_plain;f=source%2Fclient.cpp;h=ba0be5b44da51b11af152c59e1c6255c584ac958;hp=8d61f3fa51e56c9a78d12a322e4ea973c9a479ba;hb=a1e6d14ce3a5d5415333a4d3def6c5504f4bc49b;hpb=2e629085885b652a10d775695e63bc4892aa2eca diff --git a/source/client.cpp b/source/client.cpp index 8d61f3f..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; @@ -90,8 +100,15 @@ void Client::process_command(const string &cmd) void Client::send_reply(const string &reply) { Msp::MutexLock lock(mutex); - socket->write(reply); - socket->put('\n'); + try + { + socket->write(reply); + socket->put('\n'); + } + catch(const std::exception &) + { + stale = true; + } } void Client::list_directory(const FS::Path &dn)