Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rstudio/rstudio
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Jun 7, 2011
2 parents 9743b47 + 76c3de3 commit 557abf7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
6 changes: 3 additions & 3 deletions package/linux/debian-control/postinst.in
Expand Up @@ -9,11 +9,11 @@ sudo useradd -r rstudio-server
# create softlink to admin script in /usr/sbin
sudo ln -f -s ${CMAKE_INSTALL_PREFIX}/bin/rstudio-server /usr/sbin/rstudio-server

# write installed indicator then cooperatively suspend active sessions
# (so they have a chance to get the update)
# write installed indicator then force suspend active sessions
# (so that the new client is never paired against the old server)
sudo mkdir -p /etc/rstudio
sudo sh -c "echo `date +%s` > /etc/rstudio/installed"
sudo rstudio-server suspend-all
sudo rstudio-server force-suspend-all

# add apparmor profile
if test -e /etc/apparmor.d/
Expand Down
6 changes: 3 additions & 3 deletions package/linux/rpm-script/postinst.sh.in
Expand Up @@ -9,11 +9,11 @@ useradd -r rstudio-server
# create softlink to admin script in /usr/sbin
ln -f -s ${CMAKE_INSTALL_PREFIX}/bin/rstudio-server /usr/sbin/rstudio-server

# write installed indicator then cooperatively suspend active sessions
# (so they have a chance to get the update)
# write installed indicator then force suspend active sessions
# (so that the new client is never paired against the old server)
mkdir -p /etc/rstudio
sh -c "echo `date +%s` > /etc/rstudio/installed"
rstudio-server suspend-all
rstudio-server force-suspend-all

# add and register init.d script and (re) start the server
cp ${CMAKE_INSTALL_PREFIX}/extras/init.d/redhat/rstudio-server /etc/init.d/
Expand Down
31 changes: 21 additions & 10 deletions src/cpp/session/SessionMain.cpp
Expand Up @@ -127,7 +127,7 @@ bool s_sessionInitialized = false;
bool s_rSessionResumed = false;

// manage global state indicating whether R is processing input
bool s_rProcessingInput = false;
volatile sig_atomic_t s_rProcessingInput = 0;

// did we fail to coerce the charset to UTF-8
bool s_printCharsetWarning = false;
Expand All @@ -150,6 +150,7 @@ bool disallowSuspend() { return false; }
// request suspends (cooperative and forced) using interrupts
volatile sig_atomic_t s_suspendRequested = 0;
volatile sig_atomic_t s_forceSuspend = 0;
volatile sig_atomic_t s_forceSuspendInterruptedR = 0;

// cooperative suspend -- the http server is forced to timeout and a flag
// indicating that we should suspend at ourfirst valid opportunity is set
Expand All @@ -164,9 +165,13 @@ void handleUSR1(int unused)
// and the 'force' flag is set
void handleUSR2(int unused)
{
// set the r interrupt flag in case we are in the middle of processing
// note whether R was interrupted
if (s_rProcessingInput)
s_forceSuspendInterruptedR = 1;

// set the r interrupt flag (always)
r::exec::setInterruptsPending(true);

// note that a suspend is being forced.
s_forceSuspend = 1;
}
Expand Down Expand Up @@ -732,14 +737,20 @@ void suspendIfRequested(const boost::function<bool()>& allowSuspend)
// hammering away on the failure case)
s_forceSuspend = false;

// notify user
r::session::reportAndLogWarning(
"Session forced to suspend due to system restart, maintenance, "
"or other issue. Your session data will be saved however running "
"computations may have been interrupted and transient state such as "
"open connections or graphics devices will not be preserved.");
// did this force suspend interrupt R?
if (s_forceSuspendInterruptedR)
{
// reset flag
s_forceSuspendInterruptedR = false;

// notify user
r::session::reportAndLogWarning(
"Session forced to suspend due to system upgrade, restart, maintenance, "
"or other issue. Your session data was saved however running "
"computations may have been interrupted.");
}

// execute the forced suspend (doesb not return)
// execute the forced suspend (does not return)
suspendSession(true);
}

Expand Down

0 comments on commit 557abf7

Please sign in to comment.