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;
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)
+#include <msp/io/print.h>
#include <msp/net/inet6.h>
#include <msp/net/resolve.h>
#include "client.h"
{
while(!done)
{
- network.event_disp.tick();
+ try
+ {
+ network.event_disp.tick();
+ }
+ catch(const std::exception &e)
+ {
+ IO::print(IO::cerr, "Unhandled exception in network thread: %s\n", e.what());
+ }
for(list<Client *>::iterator i=network.clients.begin(); i!=network.clients.end(); )
{