xf86-video-intel: 2 commits - tools/virtual.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Sep 2 13:49:50 PDT 2013


 tools/virtual.c |   34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

New commits:
commit d3558251777ab71b2a505d7acb2edd35d05b0d58
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Sep 2 21:46:35 2013 +0100

    intel-virtual-overlay: Don't do a sibling search if bumblebee is explicitly requested
    
    If either all or bumblee is explicitly requested, don't automatically
    perform the other search.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/tools/virtual.c b/tools/virtual.c
index 64b869c..6759135 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -2338,7 +2338,7 @@ int main(int argc, char **argv)
 					} else
 						open++;
 				}
-				if (all || (optind == argc && open == 0)) {
+				if (all || (optind == argc && !bumblebee)) {
 					first_display_for_each_sibling(&ctx, i) {
 						ret = first_display_send_command(&ctx, 5000, "C%s", ctx.command);
 						if (ret && ret != -EBUSY)
@@ -2347,7 +2347,7 @@ int main(int argc, char **argv)
 							open++;
 					}
 				}
-				if (bumblebee || (optind == argc && open == 0)) {
+				if (bumblebee || (optind == argc && !all)) {
 					ret = first_display_send_command(&ctx, 5000, "B");
 					if (ret && ret != -EBUSY) {
 						if (bumblebee)
@@ -2390,7 +2390,7 @@ int main(int argc, char **argv)
 		} else
 			open++;
 	}
-	if (all || (optind == argc && open == 0)) {
+	if (all || (optind == argc && !bumblebee)) {
 		first_display_for_each_sibling(&ctx, i) {
 			ret = last_display_clone(&ctx, display_open(&ctx, ctx.command));
 			if (ret && ret != -EBUSY)
@@ -2399,7 +2399,7 @@ int main(int argc, char **argv)
 				open++;
 		}
 	}
-	if (bumblebee || (optind == argc && open == 0)) {
+	if (bumblebee || (optind == argc && !all)) {
 		ret = last_display_clone(&ctx, bumblebee_open(&ctx));
 		if (ret && ret != -EBUSY) {
 			if (bumblebee)
commit d2f7f85cd20fb3a2bb3dba8c9be7ff21d2a8c049
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Sep 2 21:41:48 2013 +0100

    intel-virtual-overlay: Fix the bumblebee query parsing
    
    It supplies both a trailing newline, NUL byte and length.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/tools/virtual.c b/tools/virtual.c
index 27d80e8..64b869c 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -1658,33 +1658,45 @@ static int bumblebee_open(struct context *ctx)
 	struct sockaddr_un addr;
 	int fd, len;
 
-	fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
-	if (fd < 0)
+	fd = socket(PF_UNIX, SOCK_STREAM, 0);
+	if (fd < 0) {
+		DBG(("%s unable to create a socket: %d\n", __func__, errno));
 		return -ECONNREFUSED;
+	}
 
 	addr.sun_family = AF_UNIX;
 	strcpy(addr.sun_path, optarg && *optarg ? optarg : "/var/run/bumblebee.socket");
-	if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+	if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+		DBG(("%s unable to create a socket: %d\n", __func__, errno));
 		goto err;
+	}
 
 	/* Ask bumblebee to start the second server */
 	buf[0] = 'C';
-	if (send(fd, &buf, 1, 0) != 1 || (len = recv(fd, &buf, 255, 0)) <= 0)
+	if (send(fd, &buf, 1, 0) != 1 || (len = recv(fd, &buf, 255, 0)) <= 0) {
+		DBG(("%s startup send/recv failed: %d\n", __func__, errno));
 		goto err;
+	}
 	buf[len] = '\0';
 
 	/* Query the display name */
 	strcpy(buf, "Q VirtualDisplay");
-	if (send(fd, buf, 17, 0) != 17 || (len = recv(fd, buf, 255, 0)) <= 0)
+	if (send(fd, buf, 17, 0) != 17 || (len = recv(fd, buf, 255, 0)) <= 0) {
+		DBG(("%s query send/recv failed: %d\n", __func__, errno));
 		goto err;
+	}
 	buf[len] = '\0';
 	close(fd);
 
+	DBG(("%s query result '%s'\n", __func__, buf));
+
 	if (strncmp(buf, "Value: ", 7))
 		return -ECONNREFUSED;
 
-	while (isspace(buf[--len]))
-		buf[len] = '\0';
+	len = 7;
+	while (buf[len] != '\n' && buf[len] != '\0')
+		len++;
+	buf[len] = '\0';
 
 	return display_open(ctx, buf+7);
 


More information about the xorg-commit mailing list