Permalink
Browse files

fix authentication issues

Fix a few issues with the re-worked authentication.  If x11/wayland
auth fails, we want to preserve the original fd, and *not* call
drmOpen() again if dce_set_fd() has been called.
  • Loading branch information...
1 parent 1116ca1 commit d5ff7c605b83e99e54b9e6d5698f6edc932d95cd Rob Clark committed Sep 24, 2012
Showing with 26 additions and 13 deletions.
  1. +12 −4 libdce-wayland.c
  2. +7 −2 libdce-x11.c
  3. +7 −7 libdce.c
View
@@ -77,7 +77,7 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
d->fd = open(device, O_RDWR | O_CLOEXEC);
if (d->fd == -1) {
ERROR("could not open %s: %m", device);
- d->error = 1;
+ d->error = -1;
return;
}
}
@@ -120,14 +120,19 @@ display_handle_global (struct wl_display *display, uint32_t id,
}
}
-int dce_auth_wayland(int fd)
+int dce_auth_wayland(int *fd)
{
struct display disp = {0};
struct display *d = &disp;
- d->fd = fd;
+ d->fd = *fd;
+ INFO("attempting to open wayland connection");
d->display = wl_display_connect(NULL);
+ if (!d->display) {
+ ERROR("Could not open display");
+ return -1;
+ }
wl_display_add_global_listener (d->display,
display_handle_global, d);
@@ -141,5 +146,8 @@ int dce_auth_wayland(int fd)
wl_display_flush (d->display);
wl_display_disconnect (d->display);
- return d->fd;
+ if (!d->error)
+ *fd = d->fd;
+
+ return d->error;
}
View
@@ -51,13 +51,15 @@
#include <ti/dce/dce_priv.h>
-int dce_auth_x11(int fd)
+int dce_auth_x11(int *pfd)
{
Display *dpy;
Window root;
drm_magic_t magic;
int eventBase, errorBase, major, minor;
char *driver, *device;
+ int ret = -1;
+ int fd = *pfd;
INFO("attempting to open X11 connection");
dpy = XOpenDisplay(NULL);
@@ -118,9 +120,12 @@ int dce_auth_x11(int fd)
goto no_x11_free;
}
+ ret = 0;
+ *pfd = fd;
+
no_x11_free:
XFree(driver);
XFree(device);
no_x11:
- return fd;
+ return ret;
}
View
@@ -51,10 +51,10 @@
#include <ti/sdo/ce/video2/videnc2.h>
#ifdef HAVE_X11
-int dce_auth_x11(int fd);
+int dce_auth_x11(int *fd);
#endif
#ifdef HAVE_WAYLAND
-int dce_auth_wayland(int fd);
+int dce_auth_wayland(int *fd);
#endif
static int init(void);
@@ -430,20 +430,20 @@ static int init(void)
#ifdef HAVE_X11
if (!authenticated) {
- fd = dce_auth_x11(fd);
- if (fd != -1)
+ int ret = dce_auth_x11(&fd);
+ if (!ret)
authenticated = 1;
}
#endif
#ifdef HAVE_WAYLAND
if (!authenticated) {
- fd = dce_auth_wayland(fd);
- if (fd != -1)
+ int ret = dce_auth_wayland(&fd);
+ if (!ret)
authenticated = 1;
}
#endif
- if (!authenticated) {
+ if ((fd == -1) && !authenticated) {
INFO("no X11/wayland, fallback to opening DRM device directly");
fd = drmOpen("omapdrm", "platform:omapdrm:00");
}

0 comments on commit d5ff7c6

Please sign in to comment.