Commit Graph

1256 Commits (bd008a170898e69beeb8bc0481b4bfd94de86c55)

Author SHA1 Message Date
Nat Goodspeed 218c0a1d4f Automated merge with ssh://bitbucket.org/nat_linden/viewer-llsingleton 2019-12-13 13:20:21 -05:00
Nat Goodspeed 24499ac66f Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-12-13 12:30:03 -05:00
Nat Goodspeed 55d7ac5e81 DRTVWR-494: Use std:🧵:id for LLThread::currentID().
LLThread::currentID() used to return a U32, a distinct unsigned value
incremented by explicitly constructing LLThread or by calling LLThread::
registerThreadID() early in a thread launched by other means. The latter
imposed an unobvious requirement on new code based on std::thread. Using
std:🧵:id instead delegates to the compiler/library the problem of
distinguishing threads launched by any means.

Change lots of explicit U32 declarations. Introduce LLThread::id_t typedef to
avoid having to run around fixing uses again if we later revisit this decision.

LLMutex, which stores an LLThread::id_t, wants a distinguished value meaning
NO_THREAD, and had an enum with that name. But as std:🧵:id promises
that the default-constructed value is distinct from every valid value,
NO_THREAD becomes unnecessary and goes away.

Because LLMutex now stores LLThread::id_t instead of U32, make llmutex.h
#include "llthread.h" instead of the other way around. This makes LLMutex an
incomplete type within llthread.h, so move LLThread::lockData() and
unlockData() to the .cpp file. Similarly, remove llrefcount.h's #include
"llmutex.h" to break circularity; instead forward-declare LLMutex.

It turns out that a number of source files assumed that #include "llthread.h"
would get the definition for LLMutex. Sprinkle #include "llmutex.h" as needed.

In the SAFE_SSL code in llcorehttp/httpcommon.cpp, there's an ssl_thread_id()
callback that returns an unsigned long to the SSL library. When LLThread::
currentID() was U32, we could simply return that. But std:🧵:id is very
deliberately opaque, and can't be reinterpret_cast to unsigned long.
Fortunately it can be hashed because std::hash is specialized with that type.
2019-12-06 16:31:49 -05:00
Nat Goodspeed 95c6b512e1 DRTVWR-476, SL-12197: Don't throw Stopping from main coroutine.
The new LLCoros::Stop exception is intended to terminate long-lived coroutines
-- not interrupt mainstream shutdown processing. Only throw it on an
explicitly-launched coroutine.

Make LLCoros::getName() (used by the above test) static. As with other LLCoros
methods, it might be called after the LLCoros LLSingleton instance has been
deleted. Requiring the caller to call instance() implies a possible need to
also call wasDeleted(). Encapsulate that nuance into a static method instead.
2019-11-22 11:58:27 -05:00
Nat Goodspeed a6cd80f8bf DRTVWR-476: Introduce LLCoprocedureManager::close(). Use in tests.
The new close(void) method simply acquires the logic from
~LLCoprocedureManager() (which now calls close()). It's useful, even if only
in test programs, to be able to shut down all existing LLCoprocedurePools
without having to name them individually -- and without having to destroy the
LLCoprocedureManager singleton instance. Deleting an LLSingleton should be
done only once per process, whereas test programs want to reset the
LLCoprocedureManager after each test.
2019-11-15 08:17:04 -05:00
Nat Goodspeed f967287f8f DRTVWR-476: Use LLThreadSafeQueue, not boost::fibers::buffered_channel.
We've observed buffered_channel::try_push() hanging, which seems very odd. Try
our own LLThreadSafeQueue instead.
2019-11-14 16:45:39 -05:00
Nat Goodspeed f8807298a2 DRTVWR-476: Manually count items in LLCoprocedurePool's pending queue.
Reinstate LLCoprocedureManager::countPending() and count() methods. These were
removed because boost::fibers::buffered_channel has no size() method, but
since all users run within a single thread, it works to increment and
decrement a simple counter.

Add count information and max queue size to log messages.
2019-11-14 15:40:06 -05:00
AndreyL ProductEngine 84f3b2865f Merged in lindenlab/viewer-release 2019-11-12 00:39:07 +02:00
Nat Goodspeed 7ed993913c Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-11-11 16:45:37 -05:00
Nat Goodspeed 088b769094 DRTVWR-476: Use shared_ptr to manage lifespan of coprocedure queue.
Since the consuming coroutine LLCoprocedurePool::coprocedureInvokerCoro() has
been observed to outlive the LLCoprocedurePool instance that owns the
CoprocQueue_t, closing that queue isn't enough to keep the coroutine from
crashing at shutdown: accessing a deleted CoprocQueue_t is fatal whether or
not it's been closed.

Make LLCoprocedurePool store a shared_ptr to a heap CoprocQueue_t instance,
and pass that shared_ptr by value to consuming coroutines. That way the
CoprocQueue_t instance is guaranteed to live as long as the last interested
party.
2019-10-25 16:10:56 -04:00
Nat Goodspeed 24d4f87afb DRTVWR-476: Back out changeset 40c0c6a8407d ("final" LLApp listener) 2019-10-24 16:05:37 -04:00
Nat Goodspeed 33c4170336 DRTVWR-476: Pump coroutines a few more times when we start quitting.
By the time "LLApp" listeners are notified that the app is quitting, the
mainloop is no longer running. Even though those listeners do things like
close work queues and inject exceptions into pending promises, any coroutines
waiting on those resources must regain control before they can notice and shut
down properly. Add a final "LLApp" listener that resumes ready coroutines a
few more times.

Make sure every other "LLApp" listener is positioned before that new one.
2019-10-24 12:54:38 -04:00
Nat Goodspeed d24a3d4fcc DRTVWR-476: Terminate long-lived coroutines to avoid shutdown crash.
Add LLCoros::TempStatus instances around known suspension points so
printActiveCoroutines() can report what each suspended coroutine is waiting
for.

Similarly, sprinkle checkStop() calls at known suspension points.

Make LLApp::setStatus() post an event to a new LLEventPump "LLApp" with a
string corresponding to the status value being set, but only until
~LLEventPumps() -- since setStatus() also gets called very late in the
application's lifetime.

Make postAndSuspendSetup() (used by postAndSuspend(), suspendUntilEventOn(),
postAndSuspendWithTimeout(), suspendUntilEventOnWithTimeout()) add a listener
on the new "LLApp" LLEventPump that pushes the new LLCoros::Stopping exception
to the coroutine waiting on the LLCoros::Promise. Make it return the new
LLBoundListener along with the previous one.

Accordingly, make postAndSuspend() and postAndSuspendWithTimeout() store the
new LLBoundListener returned by postAndSuspendSetup() in a LLTempBoundListener
(as with the previous one) so it will automatically disconnect once the wait
is over.

Make each LLCoprocedurePool instance listen on "LLApp" with a listener that
closes the queue on which new work items are dispatched. Closing the queue
causes the waiting dispatch coroutine to terminate. Store the connection in an
LLTempBoundListener on the LLCoprocedurePool so it will disconnect
automatically on destruction.

Refactor the loop in coprocedureInvokerCoro() to instantiate TempStatus around
the suspending call.

Change a couple spammy LL_INFOS() calls to LL_DEBUGS(). Give all logging calls
in that module a "CoProcMgr" tag to make it straightforward to re-enable the
LL_DEBUGS() calls as desired.
2019-10-22 17:14:26 -04:00
Nat Goodspeed 44ce972fc4 DRTVWR-476: Re-enable an llcoproceduremanager_test case.
Use new Sync class to make the driving logic wait for the coprocedure to run.
2019-09-19 16:36:41 -04:00
andreykproductengine 37eb735ba7 Merged in lindenlab/viewer-release 2019-09-10 20:30:25 +03:00
Nat Goodspeed 24c7d14199 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-09-10 11:54:43 -04:00
andreykproductengine e1451bb1d1 DRTVWR-493 Do not recreate proxy only to destroy it 2019-09-04 20:56:45 +03:00
Nat Goodspeed 5a72d34b76 Automated merge with file:///Users/nat/linden/viewer-catch 2019-08-12 09:58:08 -04:00
Nat Goodspeed f0fa4f94a5 DRTVWR-493: Make catch_llerrs() a member of WrapLLErrs. 2019-08-12 08:26:51 -04:00
Nat Goodspeed adb3f447b3 DRTVWR-493: Introduce test catch_what(), catch_llerrs() functions.
Use them in place of awkward try/catch test boilerplate.
2019-08-10 20:33:59 -04:00
andreykproductengine 87be5f7997 SL-4150 Rename htonmemcpy 2019-07-24 16:58:24 +03:00
andreykproductengine 779b5627c5 DRTVWR-493 LLAvatarNameCache to singletone 2019-07-03 20:06:47 +03:00
Anchor 769d2480c5 [DRTVWR-476] - temp fix to test. comment it out. access violation in release 2019-07-02 21:22:10 -07:00
Anchor 373c66e493 [DRTVWR-476] - temp fix to a test 2019-07-01 15:30:09 -07:00
Anchor affc44c3d5 Merge 2019-06-26 14:16:29 -07:00
Anchor 2c2bdcf348 [DRTVWR-476] - fix compiler errors 32 bit windows build 2019-06-10 15:56:44 -07:00
Nicky 2377531707 General cleanup. Delete commented out code. 2019-06-07 11:26:55 +02:00
Nicky 6f359f1bb7 Replace boost::fibers::unbuffered_channel with boost::fibers::buffered_channel.
Using boost::fibers::unbuffered_channel can block the mainthread when calling mPendingCoprocs.push (LLCoprocedurePool::enqueueCoprocedure)
From the documentation:
- If a fiber attempts to send a value through an unbuffered channel and no fiber is waiting to receive the value, the channel will block the sending fiber.

This can happen if LLCoprocedurePool::coprocedureInvokerCoro is running a coroutine and this coroutine calls yield, resuming the viewers main loop. If inside
the main loop someone calls LLCoprocedurePool::enqueueCoprocedure now push will block, as there's no one waiting for a result right now.
The wait would be in LLCoprocedurePool::coprocedureInvokerCoro at the start of the while loop, but we have not reached that yet again as LLCoprocedurePool::coprocedureInvokerCoro
did yield before reaching pop_wait_for.
The result is a deadlock.

boost::fibers::buffered_channel will not block as long as there's space in the channel. A size of 4096 (DEFAULT_QUEUE_SIZE) should be plenty enough for this.
2019-06-07 11:11:56 +02:00
Nicky 1625a896d5 Do not use string/chrono literals, sadly that won't work with GCC (4.9) 2019-06-06 20:59:54 +02:00
Anchor 48caa3c3da [DRTVWR-476] - update cef, fix merge 2019-06-06 01:51:38 -07:00
Nat Goodspeed ebcfbf277e Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2019-06-05 14:15:15 -04:00
Anchor 20051e9906 [DRTVWR-476] - conflicts with a mac macro 2019-05-20 05:13:02 -07:00
Brad Kittenbrink 44fe16c6b8 Implemented some code review suggested cleanups. 2019-05-01 15:35:56 -07:00
Brad Kittenbrink 295ed138d4 Improved aggregate init syntax for DefaultPoolSizes map. 2019-04-18 15:27:40 -07:00
AndreyL ProductEngine 59457cfcfe Merged in lindenlab/viewer-release (EAM) 2019-04-17 16:26:45 +03:00
Brad Kittenbrink c686784d20 Improved shutdown behavior of LLCoprocedureManager 2019-03-14 11:55:42 -07:00
Brad Kittenbrink 46466e339f First draft of boost::fibers::unbuffered_channel based implementation of LLCoprocedureManager 2019-03-11 17:42:39 -07:00
Brad Kittenbrink 5d01c940cf Lint fixes on new test file. 2019-03-05 17:09:38 -08:00
Brad Kittenbrink 848324a4be Attempt to close LLEventCoro's LLBoundListener connection when promise has been fulfilled. 2019-03-04 13:00:52 -08:00
Brad Kittenbrink 017b2c903e Merged with nat_linden/viewer-fiber. 2019-02-27 17:56:38 -08:00
Brad Kittenbrink 8caa683afd Began work for adding a test covering LLCoprocedureManager 2019-02-27 17:43:31 -08:00
AndreyL ProductEngine 36cb6933e6 Merged in lindenlab/viewer-release 2019-03-01 02:24:00 +02:00
andreykproductengine fa15830e02 SL-10291 Replace apr_atomic with standard C++11 functionality 2019-01-15 18:31:17 +02:00
andreykproductengine 346fc435f1 SL-10291 cleanup-mutex 2019-01-17 01:53:27 +02:00
andreykproductengine 26fae750ba SL-10291 Replace apr_mutex with standard C++11 functionality 2019-01-14 22:04:44 +02:00
AndreyL ProductEngine e4f6e7d842 Merged in lindenlab/viewer-release and incremented viewer version to 6.2.0 2019-03-01 20:03:14 +02:00
Nat Goodspeed d2c581c344 Automated merge with ssh://bitbucket.org/lindenlab/viewer-release 2018-12-28 14:46:49 -05:00
Nat Goodspeed c4096f670c SL-10153: Review and rationalize fetching paths from environment.
Use LLStringUtil::getenv() or getoptenv() whenever we fetch a string that will
be used as a pathname.

Use LLFile::tmpdir() instead of getenv("TEMP").

As an added extra-special bonus, finally clean up $TMP/llcontrol-test-zzzzzz
directories that have been accumulating every time we run a local build!
2018-12-14 15:38:13 -05:00
AndreyL ProductEngine 88605685b0 Merged in lindenlab/viewer-release 2018-11-14 22:52:16 +02:00
Brad Payne (Vir Linden) a84ee929a5 merge 2018-09-27 19:54:10 +01:00