FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Revert "ensure quit event is always delivered during shutdown" · UXScripts/rstudio@fe5ed7f · GitHub

forked from rstudio/rstudio

Commit fe5ed7f

Browse files
committed
Revert "ensure quit event is always delivered during shutdown"
This reverts commit 0e5d0e9.
1 parent 26d7aae commit fe5ed7f

1 file changed

Lines changed: 9 additions & 38 deletions

File tree

‎src/cpp/session/SessionClientEventService.cpp‎

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,12 @@ namespace session {
3838

3939
namespace {
4040

41-
const int kLastChanceWaitSecs = 4;
42-
4341
bool hasEventIdLessThanOrEqualTo(const json::Value& event, int targetId)
4442
{
4543
const json::Object& eventJSON = event.get_obj();
4644
int eventId = eventJSON.find("id")->second.get_int();
4745
return eventId <= targetId;
4846
}
49-
50-
boost::shared_ptr<HttpConnection> waitForConnection(int seconds)
51-
{
52-
return httpConnectionListener().eventsConnectionQueue().dequeConnection(
53-
boost::posix_time::seconds(seconds));
54-
}
55-
5647

5748
} // anonymous namespace
5849

@@ -97,11 +88,10 @@ void ClientEventService::stop()
9788
{
9889
serviceThread_.interrupt();
9990

100-
// wait forthe service thread to stop
101-
if (!serviceThread_.timed_join(
102-
boost::posix_time::seconds(kLastChanceWaitSecs + 1)))
91+
// wait for up to 3 seconds for the service thread to stop
92+
if (!serviceThread_.timed_join(boost::posix_time::seconds(3)))
10393
{
104-
LOG_WARNING_MESSAGE("ClientEventService didn't stop");
94+
LOG_WARNING_MESSAGE("ClientEventService didn't stop within 3 sec");
10595
}
10696

10797
serviceThread_.detach();
@@ -219,45 +209,26 @@ void ClientEventService::run()
219209
try
220210
{
221211
// wait for up to 1 second for a connection
222-
ptrConnection = waitForConnection(1);
212+
ptrConnection =
213+
httpConnectionListener().eventsConnectionQueue().dequeConnection(
214+
boost::posix_time::seconds(1));
223215

224216
// if we didn't get one then check for interruption requested
225217
// and then continue waiting
226218
if (!ptrConnection)
227219
{
228220
// check for interruption and set stopServer flag if we were
229221
if (boost::this_thread::interruption_requested())
230-
{
231222
stopServer = true;
232223

233-
// last chance listen
234-
if (clientEventQueue.hasEvents())
235-
ptrConnection = waitForConnection(kLastChanceWaitSecs);
236-
237-
if (!ptrConnection)
238-
continue;
239-
}
240-
else
241-
{
242-
// accept next request
243-
continue;
244-
}
224+
// accept next request (assuming we weren't interrupted)
225+
continue;
245226
}
246227
}
247228
catch(const boost::thread_interrupted&)
248229
{
249-
if (stopServer)
250-
continue;
251-
252230
stopServer = true;
253-
254-
// last chance listen (no try catch to keep code simpler -
255-
// we would never interrupt the thread twice)
256-
if (clientEventQueue.hasEvents())
257-
ptrConnection = waitForConnection(kLastChanceWaitSecs);
258-
259-
if (!ptrConnection)
260-
continue;
231+
continue;
261232
}
262233

263234
// parse the json rpc request

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL