sync from fd.org

timeout support in connection
This commit is contained in:
Andreas Volz 2009-11-16 23:00:10 +01:00
parent d55e70a385
commit 25a2ef65af
3 changed files with 27 additions and 5 deletions

View file

@ -202,6 +202,7 @@ Connection Connection::ActivationBus()
}
Connection::Connection(const char *address, bool priv)
: _timeout(-1)
{
InternalError e;
DBusConnection *conn = priv
@ -218,13 +219,13 @@ Connection::Connection(const char *address, bool priv)
}
Connection::Connection(Connection::Private *p)
: _pvt(p)
: _pvt(p), _timeout(-1)
{
setup(default_dispatcher);
}
Connection::Connection(const Connection &c)
: _pvt(c._pvt)
: _pvt(c._pvt),_timeout(c._timeout)
{
dbus_connection_ref(_pvt->conn);
}
@ -360,7 +361,14 @@ Message Connection::send_blocking(Message &msg, int timeout)
DBusMessage *reply;
InternalError e;
reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e);
if (this->_timeout != -1)
{
reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, this->_timeout, e);
}
else
{
reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e);
}
if (e) throw Error(e);
@ -444,3 +452,13 @@ bool Connection::start_service(const char *name, unsigned long flags)
return b;
}
void Connection::set_timeout(int timeout)
{
_timeout=timeout;
}
int Connection::get_timeout()
{
return _timeout;
}