e9f7d829b6
windows/tabs would make gnome-pty-helper hungry for cpu time. so hungry that it would try to eat all cpu time. from chpe@gnome.org bugzilla: #562385
102 lines
2.5 KiB
Plaintext
102 lines
2.5 KiB
Plaintext
$OpenBSD: patch-gnome-pty-helper_gnome-pty-helper_c,v 1.3 2008/11/27 18:22:53 jasper Exp $
|
|
|
|
Patch to fix 64-bit issues where gnome-pty-helper would eat up 100% CPU usage.
|
|
From chpe@gnome.org Bugzilla: #562385
|
|
|
|
--- gnome-pty-helper/gnome-pty-helper.c.orig Thu Jun 26 19:49:45 2008
|
|
+++ gnome-pty-helper/gnome-pty-helper.c Thu Nov 27 13:21:41 2008
|
|
@@ -95,27 +95,25 @@ static pty_info *pty_list;
|
|
#endif
|
|
#endif /* CMSG_DATA */
|
|
|
|
-static struct cmsghdr *cmptr;
|
|
-static int CONTROLLEN;
|
|
+/* Solaris doesn't define these */
|
|
+#ifndef CMSG_ALIGN
|
|
+#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))
|
|
+#endif
|
|
+#ifndef CMSG_SPACE
|
|
+#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
|
|
+#endif
|
|
+#ifndef CMSG_LEN
|
|
+#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
|
|
+#endif
|
|
|
|
static int
|
|
-init_msg_pass (void)
|
|
-{
|
|
- CONTROLLEN = (CMSG_DATA (cmptr) - (unsigned char *)cmptr) + sizeof(int);
|
|
- cmptr = malloc (CONTROLLEN);
|
|
-
|
|
- if (cmptr)
|
|
- return 0;
|
|
-
|
|
- return -1;
|
|
-}
|
|
-
|
|
-static int
|
|
pass_fd (int client_fd, int fd)
|
|
{
|
|
struct iovec iov[1];
|
|
struct msghdr msg;
|
|
char buf [1];
|
|
+ char cmsgbuf[CMSG_SPACE(sizeof(int))];
|
|
+ struct cmsghdr *cmptr;
|
|
|
|
iov [0].iov_base = buf;
|
|
iov [0].iov_len = 1;
|
|
@@ -124,12 +122,13 @@ pass_fd (int client_fd, int fd)
|
|
msg.msg_iovlen = 1;
|
|
msg.msg_name = NULL;
|
|
msg.msg_namelen = 0;
|
|
- msg.msg_control = (caddr_t) cmptr;
|
|
- msg.msg_controllen = CONTROLLEN;
|
|
-
|
|
+ msg.msg_control = (caddr_t) cmsgbuf;
|
|
+ msg.msg_controllen = sizeof(cmsgbuf);
|
|
+
|
|
+ cmptr = CMSG_FIRSTHDR(&msg);
|
|
cmptr->cmsg_level = SOL_SOCKET;
|
|
cmptr->cmsg_type = SCM_RIGHTS;
|
|
- cmptr->cmsg_len = CONTROLLEN;
|
|
+ cmptr->cmsg_len = CMSG_LEN(sizeof(int));
|
|
*(int *)CMSG_DATA (cmptr) = fd;
|
|
|
|
if (sendmsg (client_fd, &msg, 0) != 1)
|
|
@@ -154,12 +153,6 @@ pass_fd (int client_fd, int fd)
|
|
#include <sys/uio.h>
|
|
|
|
static int
|
|
-init_msg_pass ()
|
|
-{
|
|
- return 0;
|
|
-}
|
|
-
|
|
-static int
|
|
pass_fd (int client_fd, int fd)
|
|
{
|
|
struct iovec iov[1];
|
|
@@ -185,12 +178,6 @@ pass_fd (int client_fd, int fd)
|
|
#else
|
|
#include <stropts.h>
|
|
#ifdef I_SENDFD
|
|
-static int
|
|
-init_msg_pass ()
|
|
-{
|
|
- /* nothing */
|
|
- return 0;
|
|
-}
|
|
|
|
int
|
|
pass_fd (int client_fd, int fd)
|
|
@@ -707,9 +694,6 @@ main (int argc, char *argv [])
|
|
/* Make sure we clean up utmp/wtmp even under vncserver */
|
|
signal (SIGHUP, exit_handler);
|
|
signal (SIGTERM, exit_handler);
|
|
-
|
|
- if (init_msg_pass () == -1)
|
|
- exit (1);
|
|
|
|
while (!done) {
|
|
res = n_read (STDIN_FILENO, &op, sizeof (op));
|