[dbus] Poll on dbus connection fd
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
dfa0cbcb8d
commit
9058bd1fd3
12
awesome.c
12
awesome.c
|
@ -293,7 +293,7 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
const char *confpath = NULL;
|
const char *confpath = NULL;
|
||||||
int r, xfd, csfd, i, screen_nbr, opt;
|
int r, xfd, csfd, dbusfd, i, screen_nbr, opt;
|
||||||
ssize_t cmdlen = 1;
|
ssize_t cmdlen = 1;
|
||||||
const xcb_query_extension_reply_t *shape_query, *randr_query;
|
const xcb_query_extension_reply_t *shape_query, *randr_query;
|
||||||
statusbar_t *statusbar;
|
statusbar_t *statusbar;
|
||||||
|
@ -494,7 +494,8 @@ main(int argc, char **argv)
|
||||||
warn("error binding UNIX domain socket: %s\n", strerror(errno));
|
warn("error binding UNIX domain socket: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
a_dbus_init();
|
if(!a_dbus_init(&dbusfd))
|
||||||
|
dbusfd = -1;
|
||||||
|
|
||||||
/* register function for signals */
|
/* register function for signals */
|
||||||
signal(SIGINT, &exit_on_signal);
|
signal(SIGINT, &exit_on_signal);
|
||||||
|
@ -511,8 +512,10 @@ main(int argc, char **argv)
|
||||||
FD_ZERO(&rd);
|
FD_ZERO(&rd);
|
||||||
if(csfd >= 0)
|
if(csfd >= 0)
|
||||||
FD_SET(csfd, &rd);
|
FD_SET(csfd, &rd);
|
||||||
|
if(dbusfd >= 0)
|
||||||
|
FD_SET(dbusfd, &rd);
|
||||||
FD_SET(xfd, &rd);
|
FD_SET(xfd, &rd);
|
||||||
if(select(MAX(xfd, csfd) + 1, &rd, NULL, NULL, NULL) == -1)
|
if(select(MAX(MAX(xfd, csfd), dbusfd) + 1, &rd, NULL, NULL, NULL) == -1)
|
||||||
{
|
{
|
||||||
if(errno == EINTR)
|
if(errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
@ -536,7 +539,8 @@ main(int argc, char **argv)
|
||||||
layout_refresh();
|
layout_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a_dbus_process_requests(); */
|
if(dbusfd >= 0 && FD_ISSET(dbusfd, &rd))
|
||||||
|
a_dbus_process_requests(&dbusfd);
|
||||||
|
|
||||||
/* two level XPending:
|
/* two level XPending:
|
||||||
* we need to first check we have XEvent to handle
|
* we need to first check we have XEvent to handle
|
||||||
|
|
18
dbus.c
18
dbus.c
|
@ -52,12 +52,12 @@ a_dbus_process_widget_tell(DBusMessage *req)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
a_dbus_process_requests(void)
|
a_dbus_process_requests(int *fd)
|
||||||
{
|
{
|
||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
int nmsg = 0;
|
int nmsg = 0;
|
||||||
|
|
||||||
if(!dbus_connection && !a_dbus_init())
|
if(!dbus_connection && !a_dbus_init(fd))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
|
@ -87,7 +87,7 @@ a_dbus_process_requests(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
a_dbus_init(void)
|
a_dbus_init(int *fd)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
|
@ -97,11 +97,8 @@ a_dbus_init(void)
|
||||||
if(dbus_error_is_set(&err))
|
if(dbus_error_is_set(&err))
|
||||||
{
|
{
|
||||||
warn("DBus system bus connection failed: %s\n", err.message);
|
warn("DBus system bus connection failed: %s\n", err.message);
|
||||||
|
|
||||||
dbus_connection = NULL;
|
dbus_connection = NULL;
|
||||||
|
|
||||||
dbus_error_free(&err);
|
dbus_error_free(&err);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,18 +109,21 @@ a_dbus_init(void)
|
||||||
if(dbus_error_is_set(&err))
|
if(dbus_error_is_set(&err))
|
||||||
{
|
{
|
||||||
warn("failed to request DBus name: %s\n", err.message);
|
warn("failed to request DBus name: %s\n", err.message);
|
||||||
|
|
||||||
a_dbus_cleanup();
|
a_dbus_cleanup();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
if(ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
||||||
{
|
{
|
||||||
warn("not primary DBus name owner\n");
|
warn("not primary DBus name owner\n");
|
||||||
|
|
||||||
a_dbus_cleanup();
|
a_dbus_cleanup();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!dbus_connection_get_unix_fd(dbus_connection, fd))
|
||||||
|
{
|
||||||
|
warn("cannot get DBus connection file descriptor\n");
|
||||||
|
a_dbus_cleanup();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue