aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-05-02 09:01:55 +0200
committermarha <marha@users.sourceforge.net>2012-05-02 09:01:55 +0200
commit3d353f31ac1671d1b39c09b1f8d82c8811d3edd6 (patch)
treece19dbcec75ce7e87547f6f9b3495888aaea0966 /xorg-server/os
parentb2a0f04a2984b290c1224fc1b1883d08b01a6231 (diff)
parente67b35e7a899da5805fcce3d390cb10ebcaffe91 (diff)
downloadvcxsrv-3d353f31ac1671d1b39c09b1f8d82c8811d3edd6.tar.gz
vcxsrv-3d353f31ac1671d1b39c09b1f8d82c8811d3edd6.tar.bz2
vcxsrv-3d353f31ac1671d1b39c09b1f8d82c8811d3edd6.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/os/connection.c
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/WaitFor.c18
-rw-r--r--xorg-server/os/connection.c73
-rw-r--r--xorg-server/os/utils.c9
3 files changed, 76 insertions, 24 deletions
diff --git a/xorg-server/os/WaitFor.c b/xorg-server/os/WaitFor.c
index 6c8ede29d..95762ef18 100644
--- a/xorg-server/os/WaitFor.c
+++ b/xorg-server/os/WaitFor.c
@@ -388,6 +388,7 @@ CheckAllTimers(void)
OsTimerPtr timer;
CARD32 now;
+ OsBlockSignals();
start:
now = GetTimeInMillis();
@@ -397,6 +398,7 @@ CheckAllTimers(void)
goto start;
}
}
+ OsReleaseSignals();
}
static void
@@ -404,11 +406,13 @@ DoTimer(OsTimerPtr timer, CARD32 now, OsTimerPtr *prev)
{
CARD32 newTime;
+ OsBlockSignals();
*prev = timer->next;
timer->next = NULL;
newTime = (*timer->callback) (timer, now, timer->arg);
if (newTime)
TimerSet(timer, 0, newTime, timer->callback, timer->arg);
+ OsReleaseSignals();
}
OsTimerPtr
@@ -424,6 +428,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
return NULL;
}
else {
+ OsBlockSignals();
for (prev = &timers; *prev; prev = &(*prev)->next) {
if (*prev == timer) {
*prev = timer->next;
@@ -432,6 +437,7 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
break;
}
}
+ OsReleaseSignals();
}
if (!millis)
return timer;
@@ -451,26 +457,32 @@ TimerSet(OsTimerPtr timer, int flags, CARD32 millis,
if (!millis)
return timer;
}
+ OsBlockSignals();
for (prev = &timers;
*prev && (int) ((*prev)->expires - millis) <= 0;
prev = &(*prev)->next);
timer->next = *prev;
*prev = timer;
+ OsReleaseSignals();
return timer;
}
Bool
TimerForce(OsTimerPtr timer)
{
+ int rc = FALSE;
OsTimerPtr *prev;
+ OsBlockSignals();
for (prev = &timers; *prev; prev = &(*prev)->next) {
if (*prev == timer) {
DoTimer(timer, GetTimeInMillis(), prev);
- return TRUE;
+ rc = TRUE;
+ break;
}
}
- return FALSE;
+ OsReleaseSignals();
+ return rc;
}
void
@@ -480,12 +492,14 @@ TimerCancel(OsTimerPtr timer)
if (!timer)
return;
+ OsBlockSignals();
for (prev = &timers; *prev; prev = &(*prev)->next) {
if (*prev == timer) {
*prev = timer->next;
break;
}
}
+ OsReleaseSignals();
}
void
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c
index 53a6ca005..1685292ce 100644
--- a/xorg-server/os/connection.c
+++ b/xorg-server/os/connection.c
@@ -152,6 +152,7 @@ static Pid_t ParentProcess;
#endif
Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or
equivalent) will send SIGCONT back. */
+static char dynamic_display[7]; /* display name */
Bool PartialNetwork; /* continue even if unable to bind all addrs */
static Bool debug_conns = FALSE;
@@ -376,6 +377,10 @@ void
NotifyParentProcess(void)
{
#if !defined(WIN32)
+ if (dynamic_display[0]) {
+ write(displayfd, dynamic_display, strlen(dynamic_display));
+ close(displayfd);
+ }
if (RunFromSmartParent) {
if (ParentProcess > 1) {
kill(ParentProcess, SIGUSR1);
@@ -386,6 +391,18 @@ NotifyParentProcess(void)
#endif
}
+static Bool
+TryCreateSocket(int num, int *partial)
+{
+ char port[20];
+
+ snprintf(port, sizeof(port), "%d", num);
+
+ return (_XSERVTransMakeAllCOTSServerListeners(port, partial,
+ &ListenTransCount,
+ &ListenTransConns) >= 0);
+}
+
/*****************
* CreateWellKnownSockets
* At initialization, create the sockets to listen on for new clients.
@@ -396,7 +413,6 @@ CreateWellKnownSockets(void)
{
int i;
int partial;
- char port[20];
FD_ZERO(&AllSockets);
FD_ZERO(&AllClients);
@@ -412,31 +428,44 @@ CreateWellKnownSockets(void)
FD_ZERO(&WellKnownConnections);
- snprintf(port, sizeof(port), "%d", atoi(display));
-
- if ((_XSERVTransMakeAllCOTSServerListeners(port, &partial,
- &ListenTransCount,
- &ListenTransConns) >= 0) &&
- (ListenTransCount >= 1)) {
- if (!PartialNetwork && partial) {
- FatalError("Failed to establish all listening sockets");
+ /* display is initialized to "0" by main(). It is then set to the display
+ * number if specified on the command line, or to NULL when the -displayfd
+ * option is used. */
+ if (display) {
+ if (TryCreateSocket(atoi(display), &partial) &&
+ ListenTransCount >= 1)
+ if (!PartialNetwork && partial)
+ FatalError ("Failed to establish all listening sockets");
+ }
+ else { /* -displayfd */
+ Bool found = 0;
+ for (i = 0; i < 65535 - X_TCP_PORT; i++) {
+ if (TryCreateSocket(i, &partial) && !partial) {
+ found = 1;
+ break;
+ }
+ else
+ CloseWellKnownConnections();
}
- else {
- ListenTransFds = malloc(ListenTransCount * sizeof(int));
+ if (!found)
+ FatalError("Failed to find a socket to listen on");
+ snprintf(dynamic_display, sizeof(dynamic_display), "%d", i);
+ display = dynamic_display;
+ }
- for (i = ListenTransCount; i > 0; i--) {
- int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i-1]);
+ ListenTransFds = malloc(ListenTransCount * sizeof (int));
- ListenTransFds[i-1] = fd;
- FD_SET(fd, &WellKnownConnections);
+ for (i = ListenTransCount; i > 0; i--) {
+ int fd = _XSERVTransGetConnectionNumber (ListenTransConns[i-1]);
- if (!_XSERVTransIsLocal (ListenTransConns[i-1])) {
- int protocol = 0;
- if (!strcmp("inet", ListenTransConns[i-1]->transptr->TransName)) protocol = 4;
- else if (!strcmp("inet6", ListenTransConns[i-1]->transptr->TransName)) protocol = 6;
- DefineSelf (fd, protocol);
- }
- }
+ ListenTransFds[i-1] = fd;
+ FD_SET(fd, &WellKnownConnections);
+
+ if (!_XSERVTransIsLocal (ListenTransConns[i-1])) {
+ int protocol = 0;
+ if (!strcmp("inet", ListenTransConns[i-1]->transptr->TransName)) protocol = 4;
+ else if (!strcmp("inet6", ListenTransConns[i-1]->transptr->TransName)) protocol = 6;
+ DefineSelf (fd, protocol);
}
}
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index dbed76132..47bc7b5c3 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -687,6 +687,15 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
+ else if (strcmp(argv[i], "-displayfd") == 0) {
+ if (++i < argc) {
+ displayfd = atoi(argv[i]);
+ display = NULL;
+ nolock = TRUE;
+ }
+ else
+ UseMsg();
+ }
#ifdef DPMSExtension
else if (strcmp(argv[i], "dpms") == 0)
/* ignored for compatibility */ ;