summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-03-30 14:31:18 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-03-30 14:44:55 +0100
commitebe86fdaa9aa13de3d1952c5d7a62bf36e834455 (patch)
tree06778703ad1d6e313cbd790e4522b7f10a695b77 /test
parent094924f7f882da1f32395d4c982db6ad8e0f609f (diff)
downloadxorg-driver-xf86-video-intel-ebe86fdaa9aa13de3d1952c5d7a62bf36e834455.tar.gz
test/dri2-race: Don't leak the Display after detecting the race
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/dri2-race.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/test/dri2-race.c b/test/dri2-race.c
index 4e5187c6..79dc9c49 100644
--- a/test/dri2-race.c
+++ b/test/dri2-race.c
@@ -631,15 +631,15 @@ static void race_client(int width, int height,
printf("DRI2SwapBuffers(divisor=%d)", divisors[n]);
loop = 256 >> ffs(divisors[n]);
do {
- Display *dpy;
+ Display *dpy = XOpenDisplay(NULL);
Window win;
if (error_get()) {
+ XCloseDisplay(dpy);
printf("+"); fflush(stdout);
continue;
}
- dpy = XOpenDisplay(NULL);
win = XCreateWindow(dpy, DefaultRootWindow(dpy),
0, 0, width, height, 0,
DefaultDepth(dpy, DefaultScreen(dpy)),
@@ -653,11 +653,10 @@ static void race_client(int width, int height,
DRI2CreateDrawable(dpy, win);
free(DRI2GetBuffers(dpy, win, &width, &height,
attachments, nattachments, &count));
- if (count != nattachments)
- return;
-
- for (count = 0; count < loop; count++)
- DRI2SwapBuffers(dpy, win, 0, divisors[n], count & (divisors[n]-1));
+ if (count == nattachments) {
+ for (count = 0; count < loop; count++)
+ DRI2SwapBuffers(dpy, win, 0, divisors[n], count & (divisors[n]-1));
+ }
XFlush(dpy);
XKillClient(mgr, win);
@@ -675,15 +674,15 @@ static void race_client(int width, int height,
printf("xcb_dri2_swap_buffers(divisor=%d)", divisors[n]);
loop = 256 >> ffs(divisors[n]);
do {
- Display *dpy;
+ Display *dpy = XOpenDisplay(NULL);
Window win;
if (error_get()) {
+ XCloseDisplay(dpy);
printf("+"); fflush(stdout);
continue;
}
- dpy = XOpenDisplay(NULL);
win = XCreateWindow(dpy, DefaultRootWindow(dpy),
0, 0, width, height, 0,
DefaultDepth(dpy, DefaultScreen(dpy)),
@@ -697,11 +696,10 @@ static void race_client(int width, int height,
DRI2CreateDrawable(dpy, win);
free(DRI2GetBuffers(dpy, win, &width, &height,
attachments, nattachments, &count));
- if (count != nattachments)
- return;
-
- for (count = 0; count < loop; count++)
- swap_buffers(dpy, win, divisors[n], attachments, nattachments);
+ if (count == nattachments) {
+ for (count = 0; count < loop; count++)
+ swap_buffers(dpy, win, divisors[n], attachments, nattachments);
+ }
XFlush(dpy);
XKillClient(mgr, win);
@@ -719,17 +717,17 @@ static void race_client(int width, int height,
printf("DRI2WaitMsc(divisor=%d)", divisors[n]);
loop = 256 >> ffs(divisors[n]);
do {
+ Display *dpy = XOpenDisplay(NULL);
uint64_t ignore, msc;
- Display *dpy;
xcb_connection_t *c;
Window win;
if (error_get()) {
+ XCloseDisplay(dpy);
printf("+"); fflush(stdout);
continue;
}
- dpy = XOpenDisplay(NULL);
win = XCreateWindow(dpy, DefaultRootWindow(dpy),
0, 0, width, height, 0,
DefaultDepth(dpy, DefaultScreen(dpy)),