summaryrefslogtreecommitdiff
path: root/os/connection.c
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-05-17 14:56:53 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-05-17 14:56:53 -0700
commit2408303d79297385063cae557195bd5fd3698478 (patch)
tree2611d6c0e56861f5f2b1cbe8a2b166103e1a1e6f /os/connection.c
parent01612fe612aa27262fc3c8167f52e0376941f1ef (diff)
XQuartz: Added functionality to add a file descriptor to the connection list after the server is already running.
(cherry picked from commit 543c2cd68d1ffef65d4644b860faad7191c6b9da)
Diffstat (limited to 'os/connection.c')
-rw-r--r--os/connection.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/os/connection.c b/os/connection.c
index 396593698..a87725782 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1297,3 +1297,67 @@ MakeClientGrabPervious(ClientPtr client)
}
}
+#ifdef XQUARTZ
+/* Add a fd (from launchd) to our listeners */
+_X_EXPORT void ListenOnOpenFD(int fd) {
+ char port[20];
+ XtransConnInfo ciptr, *ciptr2, *ciptr3;
+ int *iptr, *iptr2;
+
+ /* Sigh for inconsistencies. */
+ sprintf (port, ":%d", atoi(display));
+
+ /* Make our XtransConnInfo
+ * TRANS_SOCKET_LOCAL_INDEX = 5 from Xtrans.c
+ */
+ ciptr = _XSERVTransReopenCOTSServer(5, fd, port);
+ if(ciptr == NULL) {
+ fprintf(stderr, "Got NULL while trying to Reopen launchd port.\n");
+ return;
+ }
+
+ /* Allocate space to store it */
+ iptr = (int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof (int));
+
+ if(!iptr) {
+ fprintf(stderr, "Memory allocation error");
+ return;
+ }
+
+ ciptr2 = (XtransConnInfo *) realloc(ListenTransConns, (ListenTransCount + 1) * sizeof (XtransConnInfo));
+ if(!ciptr2) {
+ fprintf(stderr, "Memory allocation error");
+ if(iptr != ListenTransFds)
+ free(ListenTransFds);
+ return;
+ }
+
+ if(iptr != ListenTransFds) {
+ iptr2 = ListenTransFds;
+ ListenTransFds = iptr;
+ free(iptr2);
+ }
+
+ if(ciptr2 != ListenTransConns) {
+ ciptr3 = ListenTransConns;
+ ListenTransConns = ciptr2;
+ free(ciptr3);
+ }
+
+ /* Store it */
+ ListenTransConns[ListenTransCount] = ciptr;
+ ListenTransFds[ListenTransCount] = fd;
+
+ FD_SET(fd, &WellKnownConnections);
+
+ /* It is always local
+ if (!_XSERVTransIsLocal(ciptr)) {
+ // DefineSelf (fd);
+ }
+ */
+
+ /* Increment the count */
+ ListenTransCount++;
+}
+
+#endif