summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@freedesktop.org>2008-05-15 09:55:17 -0700
committerJeremy Huddleston <jeremyhu@freedesktop.org>2008-05-15 09:55:17 -0700
commit543c2cd68d1ffef65d4644b860faad7191c6b9da (patch)
tree42523ab62f41fbfd51d9e4a5578e66b05eb76d42 /os
parentc28fecc621b1803a4d4536afbc724d141de9e6ee (diff)
XQuartz: Added functionality to add a file descriptor to the connection list after the server is already running.
Diffstat (limited to 'os')
-rw-r--r--os/connection.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/os/connection.c b/os/connection.c
index bd98f7416..d34cddd1e 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1262,3 +1262,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