return;
resolve_tag = 0;
- signal_socket_error.emit(err);
-
delete request;
request = 0;
+
+ if(signal_socket_error.empty())
+ throw err;
+ signal_socket_error.emit(err);
}
void Client::connect_finished(const exception *err)
{
if(err)
{
- signal_socket_error.emit(*err);
-
delete request;
request = 0;
+
+ if(signal_socket_error.empty())
+ throw *err;
+ signal_socket_error.emit(*err);
}
else
- sock->write(request->str());
+ {
+ try
+ {
+ sock->write(request->str());
+ }
+ catch(const exception &e)
+ {
+ if(signal_socket_error.empty())
+ throw;
+ signal_socket_error.emit(e);
+ return;
+ }
+ }
}
void Client::data_available()
}
catch(const exception &e)
{
+ if(signal_socket_error.empty())
+ throw;
signal_socket_error.emit(e);
return;
}
break;
}
- char rbuf[4096];
- unsigned len = cl.sock->read(rbuf, sizeof(rbuf));
- if(cl.stale)
+ try
+ {
+ char rbuf[4096];
+ unsigned len = cl.sock->read(rbuf, sizeof(rbuf));
+ if(cl.stale)
+ return;
+ cl.in_buf.append(rbuf, len);
+ }
+ catch(const exception &)
+ {
+ cl.stale = true;
return;
- cl.in_buf.append(rbuf, len);
+ }
RefPtr<Response> response;
if(!cl.request)
}
else
{
- len = cl.request->parse_content(cl.in_buf);
+ unsigned len = cl.request->parse_content(cl.in_buf);
cl.in_buf.erase(0, len);
}
{
if(cl.keepalive)
resp.set_header("Connection", "keep-alive");
- cl.sock->write(resp.str());
+
+ try
+ {
+ cl.sock->write(resp.str());
+ }
+ catch(const exception &)
+ {
+ cl.stale = true;
+ return;
+ }
+
cl.async = false;
if(cl.keepalive)
{
if(task->addr)
signal_address_resolved.emit(task->tag, *task->addr);
else if(task->error)
+ {
+ if(signal_resolve_failed.empty())
+ {
+ RefPtr<runtime_error> err = task->error;
+ task->error = 0;
+ thread.pop_complete_task();
+ throw *err;
+ }
signal_resolve_failed.emit(task->tag, *task->error);
+ }
thread.pop_complete_task();
}
}