mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 08:04:30 +00:00
WIP: XTRANS_SEND_FDS
This commit is contained in:
10
os/Xtrans.c
10
os/Xtrans.c
@@ -682,17 +682,19 @@ ssize_t _XSERVTransWrite (XtransConnInfo ciptr, const char *buf, size_t size)
|
||||
return ciptr->transptr->Write (ciptr, buf, size);
|
||||
}
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
int _XSERVTransSendFd (XtransConnInfo ciptr, int fd, int do_close)
|
||||
{
|
||||
return ciptr->transptr->SendFd(ciptr, fd, do_close);
|
||||
if (ciptr->transptr->SendFd)
|
||||
return ciptr->transptr->SendFd(ciptr, fd, do_close);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _XSERVTransRecvFd (XtransConnInfo ciptr)
|
||||
{
|
||||
return ciptr->transptr->RecvFd(ciptr);
|
||||
if (ciptr->transptr->RecvFd)
|
||||
return ciptr->transptr->RecvFd(ciptr);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int _XSERVTransDisconnect (XtransConnInfo ciptr)
|
||||
{
|
||||
|
||||
@@ -100,16 +100,12 @@ from The Open Group.
|
||||
|
||||
#define X_TCP_PORT 6000
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
|
||||
struct _XtransConnFd {
|
||||
struct _XtransConnFd *next;
|
||||
int fd;
|
||||
int do_close;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct _XtransConnInfo {
|
||||
struct _Xtransport *transptr;
|
||||
int index;
|
||||
@@ -175,7 +171,6 @@ typedef struct _Xtransport {
|
||||
|
||||
ssize_t (*Write)(XtransConnInfo ciptr, const char *buf, size_t size);
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
int (*SendFd)(
|
||||
XtransConnInfo, /* connection */
|
||||
int, /* fd */
|
||||
@@ -185,7 +180,6 @@ typedef struct _Xtransport {
|
||||
int (*RecvFd)(
|
||||
XtransConnInfo /* connection */
|
||||
);
|
||||
#endif
|
||||
|
||||
int (*Disconnect)(
|
||||
XtransConnInfo /* connection */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002, 2025, Oracle and/or its affiliates.
|
||||
*
|
||||
@@ -1138,8 +1139,6 @@ static XtransConnInfo _XSERVTransSocketUNIXAccept (
|
||||
|
||||
#endif /* UNIXCONN */
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
|
||||
static void
|
||||
appendFd(struct _XtransConnFd **prev, int fd, int do_close)
|
||||
{
|
||||
@@ -1241,8 +1240,6 @@ union fd_pass {
|
||||
char buf[CMSG_SPACE(MAX_FDS * sizeof(int))];
|
||||
};
|
||||
|
||||
#endif /* XTRANS_SEND_FDS */
|
||||
|
||||
static int _XSERVTransSocketRead (
|
||||
XtransConnInfo ciptr, char *buf, int size)
|
||||
{
|
||||
@@ -1378,9 +1375,7 @@ static int _XSERVTransSocketUNIXClose (XtransConnInfo ciptr)
|
||||
|
||||
prmsg (2,"SocketUNIXClose(%p,%d)\n", (void *) ciptr, ciptr->fd);
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
cleanupFds(ciptr);
|
||||
#endif
|
||||
ret = ossock_close(ciptr->fd);
|
||||
|
||||
if (ciptr->flags
|
||||
@@ -1404,9 +1399,7 @@ static int _XSERVTransSocketUNIXCloseForCloning (XtransConnInfo ciptr)
|
||||
prmsg (2,"SocketUNIXCloseForCloning(%p,%d)\n",
|
||||
(void *) ciptr, ciptr->fd);
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
cleanupFds(ciptr);
|
||||
#endif
|
||||
return ossock_close(ciptr->fd);
|
||||
}
|
||||
|
||||
@@ -1439,10 +1432,8 @@ static Xtransport _XSERVTransSocketTCPFuncs = {
|
||||
_XSERVTransSocketINETAccept,
|
||||
_XSERVTransSocketRead,
|
||||
_XSERVTransSocketWrite,
|
||||
#if XTRANS_SEND_FDS
|
||||
_XSERVTransSocketSendFdInvalid,
|
||||
_XSERVTransSocketRecvFdInvalid,
|
||||
#endif
|
||||
_XSERVTransSocketDisconnect,
|
||||
_XSERVTransSocketINETClose,
|
||||
_XSERVTransSocketINETClose,
|
||||
@@ -1461,10 +1452,8 @@ static Xtransport _XSERVTransSocketINETFuncs = {
|
||||
_XSERVTransSocketINETAccept,
|
||||
_XSERVTransSocketRead,
|
||||
_XSERVTransSocketWrite,
|
||||
#if XTRANS_SEND_FDS
|
||||
_XSERVTransSocketSendFdInvalid,
|
||||
_XSERVTransSocketRecvFdInvalid,
|
||||
#endif
|
||||
_XSERVTransSocketDisconnect,
|
||||
_XSERVTransSocketINETClose,
|
||||
_XSERVTransSocketINETClose,
|
||||
@@ -1484,10 +1473,8 @@ static Xtransport _XSERVTransSocketINET6Funcs = {
|
||||
_XSERVTransSocketINETAccept,
|
||||
_XSERVTransSocketRead,
|
||||
_XSERVTransSocketWrite,
|
||||
#if XTRANS_SEND_FDS
|
||||
_XSERVTransSocketSendFdInvalid,
|
||||
_XSERVTransSocketRecvFdInvalid,
|
||||
#endif
|
||||
_XSERVTransSocketDisconnect,
|
||||
_XSERVTransSocketINETClose,
|
||||
_XSERVTransSocketINETClose,
|
||||
@@ -1512,10 +1499,8 @@ static Xtransport _XSERVTransSocketLocalFuncs = {
|
||||
_XSERVTransSocketUNIXAccept,
|
||||
_XSERVTransSocketRead,
|
||||
_XSERVTransSocketWrite,
|
||||
#if XTRANS_SEND_FDS
|
||||
_XSERVTransSocketSendFd,
|
||||
_XSERVTransSocketRecvFd,
|
||||
#endif
|
||||
_XSERVTransSocketDisconnect,
|
||||
_XSERVTransSocketUNIXClose,
|
||||
_XSERVTransSocketUNIXCloseForCloning,
|
||||
@@ -1540,10 +1525,8 @@ static Xtransport _XSERVTransSocketUNIXFuncs = {
|
||||
_XSERVTransSocketUNIXAccept,
|
||||
_XSERVTransSocketRead,
|
||||
_XSERVTransSocketWrite,
|
||||
#if XTRANS_SEND_FDS
|
||||
_XSERVTransSocketSendFd,
|
||||
_XSERVTransSocketRecvFd,
|
||||
#endif
|
||||
_XSERVTransSocketDisconnect,
|
||||
_XSERVTransSocketUNIXClose,
|
||||
_XSERVTransSocketUNIXCloseForCloning,
|
||||
|
||||
20
os/io.c
20
os/io.c
@@ -255,14 +255,13 @@ ReadRequestFromClient(ClientPtr client)
|
||||
oc->input = oci;
|
||||
}
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
/* Discard any unused file descriptors */
|
||||
while (client->req_fds > 0) {
|
||||
int req_fd = ReadFdFromClient(client);
|
||||
if (req_fd >= 0)
|
||||
close(req_fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* advance to start of next request */
|
||||
|
||||
oci->bufptr += oci->lenLastReq;
|
||||
@@ -474,31 +473,22 @@ ReadRequestFromClient(ClientPtr client)
|
||||
int
|
||||
ReadFdFromClient(ClientPtr client)
|
||||
{
|
||||
int fd = -1;
|
||||
|
||||
#if XTRANS_SEND_FDS
|
||||
if (client->req_fds > 0) {
|
||||
OsCommPtr oc = (OsCommPtr) client->osPrivate;
|
||||
|
||||
--client->req_fds;
|
||||
fd = _XSERVTransRecvFd(oc->trans_conn);
|
||||
} else
|
||||
LogMessage(X_ERROR, "Request asks for FD without setting req_fds\n");
|
||||
#endif
|
||||
return _XSERVTransRecvFd(oc->trans_conn);
|
||||
}
|
||||
|
||||
return fd;
|
||||
LogMessage(X_ERROR, "Request asks for FD without setting req_fds\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
WriteFdToClient(ClientPtr client, int fd, Bool do_close)
|
||||
{
|
||||
#if XTRANS_SEND_FDS
|
||||
OsCommPtr oc = (OsCommPtr) client->osPrivate;
|
||||
|
||||
return _XSERVTransSendFd(oc->trans_conn, fd, do_close);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
|
||||
Reference in New Issue
Block a user