xf86-video-intel: test/dri2-race.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Mar 30 13:45:46 UTC 2016


 test/dri2-race.c |   30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

New commits:
commit ebe86fdaa9aa13de3d1952c5d7a62bf36e834455
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Mar 30 14:31:18 2016 +0100

    test/dri2-race: Don't leak the Display after detecting the race
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/dri2-race.c b/test/dri2-race.c
index 4e5187c..79dc9c4 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)),


More information about the xorg-commit mailing list