Skip to content

Only look for socket connections to X server.#939

Merged
Lekensteyn merged 2 commits intoBumblebee-Project:developfrom
westernmagic:develop
Aug 12, 2018
Merged

Only look for socket connections to X server.#939
Lekensteyn merged 2 commits intoBumblebee-Project:developfrom
westernmagic:develop

Conversation

@westernmagic
Copy link

XOpenDisplay tries all protocolls in turn (socket, IPv4, IPv6) [1]. This can lead to delays and timeouts, especially on systems with incomplete /etc/hosts (eg. missing localhost127.0.0.1), due to the fact that the hostname has to be resolved.

Since we start the X server not accepting TCP connections, we can pass the protocoll to XOpenDisplay.

Closes #782.

[1] http://xwindow.angelfire.com/page2.html

Copy link
Member

@bluca bluca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nrmisturak
Copy link

Please merge this. Spent the better part of two days trying to figure out why Bumblebee seemed to work only 20% of the time before finding this. For any other person looking for a workaround, adding
127.0.0.1 localhost to /etc/hosts as alluded to by @westernmagic does seem to work.

time_t xtimer = time(0);
Display * xdisp = 0;
char unix_x_display[5 + sizeof(bb_config.x_display)] = "unix/";
strcat(unix_x_display, bb_config.x_display);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizeof(bb_config.c_display) is not correct, it gives the size of a pointer. Also strcat should not be used due to the risk of a buffer overrun.

What about:

char unix_x_display[16];
snprintf(unix_x_display, sizeof(unix_x_display), "unix/%s", bb_config.x_display);

Alternatively, you could set g_strdup_printf("unix/%s", bb_config.x_display), but that needs to be freed afterwards.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that; I don't do much C.
Fixed as requested.

@Lekensteyn Lekensteyn merged commit 9695e22 into Bumblebee-Project:develop Aug 12, 2018
@Lekensteyn
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants