mirror of
https://github.com/X11Libre/xserver.git
synced 2026-10-26 01:59:57 +00:00
Merge 8f8233788b into a8192aa709
This commit is contained in:
commit
661621e65d
3 changed files with 57 additions and 10 deletions
41
os/Xtrans.c
41
os/Xtrans.c
|
|
@ -522,11 +522,34 @@ _XSERVTransReopenCOTSServer (int trans_id, int fd, const char *port)
|
|||
return _XSERVTransReopen (XTRANS_OPEN_COTS_SERVER, trans_id, fd, port);
|
||||
}
|
||||
|
||||
int _XSERVTransNonBlock(XtransConnInfo ciptr)
|
||||
int _XSERVTransSetOption (XtransConnInfo ciptr, int option, int arg)
|
||||
|
||||
{
|
||||
int fd = ciptr->fd;
|
||||
int ret = 0;
|
||||
|
||||
prmsg (2,"SetOption(%d,%d,%d)\n", fd, option, arg);
|
||||
|
||||
/*
|
||||
* For now, all transport type use the same stuff for setting options.
|
||||
* As long as this is true, we can put the common code here. Once a more
|
||||
* complicated transport such as shared memory or an OSI implementation
|
||||
* that uses the session and application libraries is implemented, this
|
||||
* code may have to move to a transport dependent function.
|
||||
*
|
||||
* ret = ciptr->transptr->SetOption (ciptr, option, arg);
|
||||
*/
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case TRANS_NONBLOCKING:
|
||||
switch (arg)
|
||||
{
|
||||
case 0:
|
||||
/* Set to blocking mode */
|
||||
break;
|
||||
case 1: /* Set to non-blocking mode */
|
||||
|
||||
#if defined(O_NONBLOCK)
|
||||
ret = fcntl (fd, F_GETFL, 0);
|
||||
if (ret != -1)
|
||||
|
|
@ -552,6 +575,22 @@ int _XSERVTransNonBlock(XtransConnInfo ciptr)
|
|||
#endif /* WIN32 */
|
||||
#endif /* FIOSNBIO */
|
||||
#endif /* O_NONBLOCK */
|
||||
break;
|
||||
default:
|
||||
/* Unknown option */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case TRANS_CLOSEONEXEC:
|
||||
#ifdef F_SETFD
|
||||
#ifdef FD_CLOEXEC
|
||||
ret = fcntl (fd, F_SETFD, FD_CLOEXEC);
|
||||
#else
|
||||
ret = fcntl (fd, F_SETFD, 1);
|
||||
#endif /* FD_CLOEXEC */
|
||||
#endif /* F_SETFD */
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
21
os/Xtrans.h
21
os/Xtrans.h
|
|
@ -105,6 +105,15 @@ typedef struct {
|
|||
|
||||
typedef struct _XtransConnInfo *XtransConnInfo;
|
||||
|
||||
|
||||
/*
|
||||
* Transport Option definitions
|
||||
*/
|
||||
|
||||
#define TRANS_NONBLOCKING 1
|
||||
#define TRANS_CLOSEONEXEC 2
|
||||
|
||||
|
||||
/*
|
||||
* Return values of Connect (0 is success)
|
||||
*/
|
||||
|
|
@ -149,13 +158,11 @@ XtransConnInfo _XSERVTransReopenCOTSServer(
|
|||
const char * /* port */
|
||||
);
|
||||
|
||||
/*
|
||||
* set connection to non-blocking mode
|
||||
*
|
||||
* @param conn the connection to set to non-blocking mode
|
||||
* @return zero on success or errno value
|
||||
*/
|
||||
int _XSERVTransNonBlock(XtransConnInfo conn);
|
||||
int _XSERVTransSetOption(
|
||||
XtransConnInfo, /* ciptr */
|
||||
int, /* option */
|
||||
int /* arg */
|
||||
);
|
||||
|
||||
int _XSERVTransCreateListener(
|
||||
XtransConnInfo, /* ciptr */
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ CreateWellKnownSockets(void)
|
|||
int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
|
||||
|
||||
ListenTransFds[i] = fd;
|
||||
_XSERVTransSetOption(ListenTransConns[i], TRANS_CLOSEONEXEC, 0);
|
||||
SetNotifyFd(fd, EstablishNewConnections, X_NOTIFY_READ, NULL);
|
||||
|
||||
if (!_XSERVTransIsLocal(ListenTransConns[i]))
|
||||
|
|
@ -640,7 +641,7 @@ EstablishNewConnections(int curconn, int ready, void *data)
|
|||
|
||||
newconn = _XSERVTransGetConnectionNumber(new_trans_conn);
|
||||
|
||||
_XSERVTransNonBlock(new_trans_conn);
|
||||
_XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
|
||||
|
||||
if (trans_conn->flags & TRANS_NOXAUTH)
|
||||
new_trans_conn->flags = new_trans_conn->flags | TRANS_NOXAUTH;
|
||||
|
|
@ -1017,7 +1018,7 @@ AddClientOnOpenFD(int fd)
|
|||
if (ciptr == NULL)
|
||||
return FALSE;
|
||||
|
||||
_XSERVTransNonBlock(ciptr);
|
||||
_XSERVTransSetOption(ciptr, TRANS_NONBLOCKING, 1);
|
||||
ciptr->flags |= TRANS_NOXAUTH;
|
||||
|
||||
connect_time = GetTimeInMillis();
|
||||
|
|
|
|||
Loading…
Reference in a new issue