mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
os: xtrans: replace _XSERVTransSetOption() by _XSERVTransNonBlock()
The only option left is TRANS_NONBLOCKING, and we only enable and never disable it. Thus trim down the code into one function for exactly that. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
09a80bb1d5
commit
2353d7a710
33
os/Xtrans.c
33
os/Xtrans.c
@@ -553,34 +553,11 @@ _XSERVTransReopenCOTSServer (int trans_id, int fd, const char *port)
|
||||
return _XSERVTransReopen (XTRANS_OPEN_COTS_SERVER, trans_id, fd, port);
|
||||
}
|
||||
|
||||
int _XSERVTransSetOption (XtransConnInfo ciptr, int option, int arg)
|
||||
|
||||
int _XSERVTransNonBlock(XtransConnInfo ciptr)
|
||||
{
|
||||
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)
|
||||
@@ -606,13 +583,7 @@ int _XSERVTransSetOption (XtransConnInfo ciptr, int option, int arg)
|
||||
#endif /* WIN32 */
|
||||
#endif /* FIOSNBIO */
|
||||
#endif /* O_NONBLOCK */
|
||||
break;
|
||||
default:
|
||||
/* Unknown option */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
20
os/Xtrans.h
20
os/Xtrans.h
@@ -129,14 +129,6 @@ struct iovec {
|
||||
|
||||
typedef struct _XtransConnInfo *XtransConnInfo;
|
||||
|
||||
|
||||
/*
|
||||
* Transport Option definitions
|
||||
*/
|
||||
|
||||
#define TRANS_NONBLOCKING 1
|
||||
|
||||
|
||||
/*
|
||||
* Return values of Connect (0 is success)
|
||||
*/
|
||||
@@ -190,11 +182,13 @@ XtransConnInfo _XSERVTransReopenCOTSServer(
|
||||
const char * /* port */
|
||||
);
|
||||
|
||||
int _XSERVTransSetOption(
|
||||
XtransConnInfo, /* ciptr */
|
||||
int, /* option */
|
||||
int /* arg */
|
||||
);
|
||||
/*
|
||||
* 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 _XSERVTransCreateListener(
|
||||
XtransConnInfo, /* ciptr */
|
||||
|
||||
@@ -690,7 +690,7 @@ EstablishNewConnections(int curconn, int ready, void *data)
|
||||
|
||||
newconn = _XSERVTransGetConnectionNumber(new_trans_conn);
|
||||
|
||||
_XSERVTransSetOption(new_trans_conn, TRANS_NONBLOCKING, 1);
|
||||
_XSERVTransNonBlock(new_trans_conn);
|
||||
|
||||
if (trans_conn->flags & TRANS_NOXAUTH)
|
||||
new_trans_conn->flags = new_trans_conn->flags | TRANS_NOXAUTH;
|
||||
@@ -1071,7 +1071,7 @@ AddClientOnOpenFD(int fd)
|
||||
if (ciptr == NULL)
|
||||
return FALSE;
|
||||
|
||||
_XSERVTransSetOption(ciptr, TRANS_NONBLOCKING, 1);
|
||||
_XSERVTransNonBlock(ciptr);
|
||||
ciptr->flags |= TRANS_NOXAUTH;
|
||||
|
||||
connect_time = GetTimeInMillis();
|
||||
|
||||
Reference in New Issue
Block a user