On a system with many visuals, leaving the display connections open
until test cleanup can cause the test to fail when the server reaches
MAX_CLIENTS simultaneous connections.

Signed-off-by: Robert Morell <[email protected]>
---
 xts5/Xlib7/XStoreColor.m  | 10 +++++++++-
 xts5/Xlib7/XStoreColors.m | 10 +++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/xts5/Xlib7/XStoreColor.m b/xts5/Xlib7/XStoreColor.m
index 35109f37ebb8..ae9f13d6325a 100644
--- a/xts5/Xlib7/XStoreColor.m
+++ b/xts5/Xlib7/XStoreColor.m
@@ -377,10 +377,15 @@ unsigned long     i;
                if(i == maxsize(vp))
                        CHECK;
 
-               disp2 = opendisplay();
+               disp2 = XOpenDisplay(config.display);
+               if (!disp2) {
+                       delete("XOpenDisplay() failed.");
+                       return;
+               }
 
                if(XAllocColor(disp2, colormap, &testcol) == False) {
                        delete("XAllocColor() failed to allocate a r/o cell for 
a second client.");
+                       XCloseDisplay(disp2);
                        return;
                } else
                        CHECK;
@@ -397,6 +402,7 @@ unsigned long       i;
 
                if(XAllocColor(display, colormap, &testcol) == False) {
                        delete("XAllocColor() failed to allocate a r/o cell");
+                       XCloseDisplay(disp2);
                        return;
                } else
                        CHECK;
@@ -406,6 +412,8 @@ unsigned long       i;
                XCALL;
                if(geterr() == BadAccess)
                        CHECK;
+
+               XCloseDisplay(disp2);
        }
 
        CHECKPASS(5*nvinf());
diff --git a/xts5/Xlib7/XStoreColors.m b/xts5/Xlib7/XStoreColors.m
index 729e7a43c185..ab68bd0a076b 100644
--- a/xts5/Xlib7/XStoreColors.m
+++ b/xts5/Xlib7/XStoreColors.m
@@ -564,10 +564,15 @@ unsigned long     i;
                }
 
                trace("Open second client connection.");
-               disp2 = opendisplay();
+               disp2 = XOpenDisplay(config.display);
+               if (!disp2) {
+                       delete("XOpenDisplay() failed.");
+                       return;
+               }
 
                if(XAllocColor(disp2, colormap, &testcol[0]) == False) {
                        delete("XAllocColor() failed to allocate a r/o cell for 
a second client.");
+                       XCloseDisplay(disp2);
                        return;
                } else
                        CHECK;
@@ -581,6 +586,7 @@ unsigned long       i;
 
                if(XAllocColor(display, colormap, &testcol[1]) == False) {
                        delete("XAllocColor() failed to allocate a r/o cell");
+                       XCloseDisplay(disp2);
                        return;
                } else
                        CHECK;
@@ -591,6 +597,8 @@ unsigned long       i;
                XCALL;
                if(geterr() == BadAccess)
                        CHECK;
+
+               XCloseDisplay(disp2);
        }
 
        CHECKPASS(6*nvinf());
-- 
2.0.5

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to