Compare commits

..

189 Commits

Author SHA1 Message Date
Siana Gearz
f8c2087d74 Preliminary Windows support for curlthreading 2012-07-29 22:47:19 +02:00
Siana Gearz
7adc0e24ab Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-29 21:32:24 +02:00
Aleric Inglewood
ba65f29a72 Fix draining of wake up pipe.
This is a bug fix, although not one we'd ever run into as normally
there is always just one byte to read, never an EAGAIN and certainly
never more than 256 bytes. Anyway, also those cases should work now.
2012-07-29 21:12:45 +02:00
Aleric Inglewood
76eef6fe59 Avoid crash on exit. 2012-07-29 18:38:59 +02:00
Aleric Inglewood
fe38f59bbb Bug fix 2012-07-29 01:30:10 +02:00
Siana Gearz
2bcabce1d6 Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-28 17:28:18 +02:00
Aleric Inglewood
ed4c6b7c92 Removed dead code.
This code has been in the viewer source for a long time,
and hasn't been used for a long time (furtherest back that
I checked was Snowglobe 1.4).

Most notably, this removes LLContextURLExtractor and code
that used it because that required an API where AICurlEasyHandle
is created before an url is known, which gets in the way of
reusing connections.
2012-07-23 18:15:11 +02:00
Aleric Inglewood
785729abdf Merge branch 'master' into curlthreading2 2012-07-22 04:17:34 +02:00
Aleric Inglewood
2830b35aa6 Avoid dead lock in LLQueuedThread::generateHandle / LLTextureFetchWorker::callbackDecoded
Thead 1:

indra/llcommon/llqueuedthread.cpp:456:

452                     if (complete)
453                     {
454                             lockData();             // This locks LLThread::mRunCondition
455                             req->setStatus(STATUS_COMPLETE);
456                             req->finishRequest(true);

LLImageDecodeThread::ImageRequest::finishRequest calls:
    mResponder->completed(success, mDecodedImageRaw, mDecodedImageAux);

LLTextureFetchWorker::DecodeResponder::completed calls:
    worker->callbackDecoded(success, raw, aux);

LLTextureFetchWorker::callbackDecoded calls:
    LLMutexLock lock(&mWorkMutex);                      // This locks LLTextureFetchWorker::mWorkMutex

Thread 2:

LLTextureFetchWorker::doWork calls:
    LLMutexLock lock(&mWorkMutex);                      // This locks LLTextureFetchWorker::mWorkMutex
    .
    .
    .
    mDecodeHandle = mFetcher->mImageDecodeThread->decodeImage(mFormattedImage, image_priority, discard, mNeedsAux, new DecodeResponder(mFetcher, mID, this));

LLImageDecodeThread::decodeImage calls:
    handle_t handle = generateHandle();

LLQueuedThread::generateHandle calls:
    lockData();                                         // This locks LLThread::mRunCondition
2012-07-22 04:13:23 +02:00
Aleric Inglewood
fb38f6adea Always write curl I/O debug info for the login attempt. 2012-07-21 21:51:24 +02:00
Aleric Inglewood
3a30f1dc71 This is called when LLApp::sStatus == LLApp::APP_STATUS_STOPPED too. 2012-07-21 03:57:58 +02:00
Siana Gearz
8802d5033f Merge branch 'master' into curlthreading
Conflicts:
	indra/newview/viewer_manifest.py
2012-07-20 00:37:58 +02:00
Siana Gearz
3d39564605 Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-20 00:35:43 +02:00
Siana Gearz
a8a30ae3b9 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-07-19 22:19:52 +02:00
Lirusaito
15af410e6f Fix typo in outbox icon name, when closed. 2012-07-19 14:02:11 -04:00
Aleric Inglewood
9e5cbf330f Bug fix for windows code found with previous commit. 2012-07-19 17:28:45 +02:00
Aleric Inglewood
2fa9334090 Debug code to test the windows code path on linux 2012-07-19 17:27:37 +02:00
Aleric Inglewood
fcdf5d377e Move PollSet out of the header file 2012-07-19 17:26:02 +02:00
Shyotl
756a284048 Don't ever halt stalled fmodex streams, as they don't seem to truly 'stall'. Decrease delay between leaving starvation and unmuting down to 1 second (from 5). 2012-07-19 02:32:16 -05:00
Lirusaito
32e2b584b9 Translation Fix 2012-07-19 02:12:51 -04:00
Lirusaito
add52b4d57 Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer 2012-07-18 23:41:23 -04:00
Siana Gearz
a4d2cb3d12 Some fighting with Shyotl over FMOD Ex 2012-07-19 05:35:17 +02:00
Lirusaito
72fbb3f63e Merge branch 'master' of https://github.com/DamianZhaoying/SingularityViewer 2012-07-18 22:58:52 -04:00
Siana Gearz
c62290accb Merge branch 'master' of git://github.com/Lirusaito/SingularityViewer 2012-07-19 04:46:15 +02:00
Siana Gearz
8ad40c5d66 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer
Conflicts:
	indra/llaudio/llaudioengine_fmodex.cpp
2012-07-19 04:44:01 +02:00
Lirusaito
cd5a721c23 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-07-18 22:31:53 -04:00
Shyotl
643844c01d GCC being GCC-ey. Fix a couple errors and warnings 2012-07-18 21:27:46 -05:00
Lirusaito
c84f080fc8 Merge branch 'master' of git://github.com/Shyotl/SingularityViewer 2012-07-18 22:08:06 -04:00
Shyotl
5fcdbfdd9e FMODEx diagnostics.
SHFMODExStreamBufferSize added. Determines stream buffer size in ms. (stream restart required)
SHFMODExDecodeBufferSize added. Determines decode buffer size in ms. (stream restart required)
Streams will mute themselves if they are starving, until they are free of starvation for 5 full seconds.
Streams that fail to accumulate any buffer progress while starving for 10 full updates will be stopped.
Stream buffer progress(buffer percent) is llinfos spewed every update. (temporary)
Doubled default stream buffer size
Increased default decode buffer size to 1000ms (from 400)
Temporarily using FMOD::Memory_Initialize to display raw stream/decode buffer sizes via llinfos.
Added llwarns messages for SigmaTel hardware or bad audio acceleration configuration.
2012-07-18 21:05:24 -05:00
Siana Gearz
96fa4af939 Initialize FMOD Ex with 44100 Hz, like FMOD 2012-07-19 03:26:02 +02:00
Siana Gearz
2334793554 Build SLPLugin.exe without tcmalloc, for SkyDrive 2012-07-19 03:24:44 +02:00
Lirusaito
20e445b4be Added icons for folders from phoenix, and created outbox folder icon for future use. 2012-07-18 20:26:19 -04:00
Aleric Inglewood
051263117d Don't force TLS v1 unless needed and then warn about it. 2012-07-19 00:13:43 +02:00
Lirusaito
085db93fc8 menu_inventory.xml translations update.
Brought the French up to date, translations on my own..
Brought the Spanish up to standard.
2012-07-18 16:04:12 -04:00
Damian Zhaoying
8fe6925414 New Spanish Translations 2012-07-18 15:30:03 -03:00
Damian Zhaoying
57ad7e62d2 Merge remote-tracking branch 'upstream/master' 2012-07-18 08:57:45 -03:00
Lirusaito
03608103b8 Tiny French Translation update
~Thanks Nomade~
2012-07-18 03:57:07 -04:00
Damian Zhaoying
675d171104 Merge remote-tracking branch 'upstream/master' 2012-07-18 03:16:39 -03:00
Lirusaito
405af67f45 Merge branch 'AltCompilers' 2012-07-17 22:30:48 -04:00
Aleric Inglewood
f772cbee51 Don't crash upon exit if we fail to cleanup. 2012-07-18 03:13:33 +02:00
Shyotl
72d93b8723 Merge branch 'V2MultiWear' 2012-07-17 19:46:56 -05:00
Aleric Inglewood
7f78870295 Merge remote-tracking branch 'siana/master' into curlthreading2
Conflicts:
	indra/llcommon/llstring.cpp
	indra/llmessage/llcurl.cpp
	indra/newview/llviewertexturelist.cpp
	indra/newview/viewer_manifest.py
	install.xml

Resolved:
	indra/llcommon/llstring.cpp :
		two different ways to work around compile error.
	indra/llmessage/llcurl.cpp :
		this file is no longer used.. I deleted huge
		parts to mark that I implemented that. Siana
		apparently made a few changes in those parts.
	indra/newview/llviewertexturelist.cpp :
		manually copied patch. Mine also removed trailing
		spaces, keeping that.
	indra/newview/viewer_manifest.py:
		Collision with changes from Liru, which have been
		ignored (kept siana/master).
	install.xml:
		Collision with an earlier screw up. I kept the
		fix from siana/master.
2012-07-18 02:08:31 +02:00
Aleric Inglewood
706b9c55c2 Moving stuff around a bit... 2012-07-18 01:41:36 +02:00
Shyotl
48ae0d003d Made the Visual Studio compiler a bit more happy with aicurl. 2012-07-17 18:04:48 -05:00
Damian Zhaoying
51c5933b76 Merge remote-tracking branch 'upstream/master' 2012-07-17 19:49:33 -03:00
Aleric Inglewood
0204d09a89 If curl thread is already awake, then don't write something to the pipe. 2012-07-17 23:39:44 +02:00
Lirusaito
465c6b9ed6 Bring back ASCENDED_DEVELOPER, and give it extra meaning! 2012-07-17 16:42:43 -04:00
Drake Arconis
39847c4688 Merge remote-tracking branch 'liruhub/master' into AltCompilers 2012-07-17 16:08:10 -04:00
Drake Arconis
7721c6e3da Resolved issue with glibc 2.16
Resolved issues introduced by changes made in glibc 2.16 removing the undocumented definition of struct siginfo from bits/siginfo.h
2012-07-17 16:06:31 -04:00
Aleric Inglewood
648ed00ce2 Don't call gSavedSettings.getU32() and calc_clock_frequency() so often anymore. 2012-07-17 19:58:34 +02:00
Aleric Inglewood
87c9358813 Add back erroneously removed comments. 2012-07-17 19:33:12 +02:00
Aleric Inglewood
64b968b262 process is no longer processing 2012-07-17 19:27:14 +02:00
Lirusaito
c0fbf4bf55 Merge branch 'master' of https://github.com/DamianZhaoying/SingularityViewer 2012-07-17 12:17:32 -04:00
Aleric Inglewood
900e533b4b Remove unused call to process(). 2012-07-17 08:01:06 +02:00
Damian Zhaoying
01818582cf Merge remote-tracking branch 'upstream/master' 2012-07-16 21:07:25 -03:00
Lirusaito
9a0620f140 Add Voodoo to tags. 2012-07-16 19:33:44 -04:00
Drake Arconis
0216925e05 Merge remote-tracking branch 'siana/master' into AltCompilers 2012-07-16 17:20:57 -04:00
Drake Arconis
32b24a98ca Merge remote-tracking branch 'shyotl/V2MultiWear' into AltCompilers 2012-07-16 17:20:47 -04:00
Drake Arconis
93d7a4938a Merge remote-tracking branch 'liru/master' into AltCompilers 2012-07-16 17:19:58 -04:00
Drake Arconis
56265b78ec Merge remote-tracking branch 'liru/V2MultiWear' into AltCompilers 2012-07-16 17:19:45 -04:00
Lirusaito
6ee76aa6f7 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-07-16 17:11:44 -04:00
Lirusaito
32d6aefe00 Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer 2012-07-16 17:10:01 -04:00
Lirusaito
84795863e5 Translations updated
Updated French Translation from Nomade's Zip for MultiWear.
Updated Translations to use basically the same format, and not have some cruft.
Abouts updated to include Spanish translators: Damian Zhaoying, and Franxizco Romano.
2012-07-16 17:07:22 -04:00
Aleric Inglewood
9deb3e433c LLCurlRequest time out fixes.
Also some more cleanup on exit improvements.
2012-07-16 22:35:04 +02:00
Drake Arconis
92a5b14347 Linux64 libs and fixes 2012-07-16 16:10:15 -04:00
Siana Gearz
891a330955 Version 1.7.0 2012-07-16 12:19:22 +02:00
Shyotl
3cee90fe8b Lets not call glDeleteTextures any more, since the glGenTextures/glDeleteTextures paradigm has gone away. 2012-07-16 01:00:55 -05:00
Drake Arconis
2bb58bac2e Corrected annoyance and inconsistencies for OSX 2012-07-15 23:32:12 -04:00
Damian Zhaoying
9dc1897b35 Fix English Inventory UI To translate other languages 2012-07-15 23:56:58 -03:00
Drake Arconis
7a7da24df5 Merge remote-tracking branch 'shyotl/V2MultiWear' into AltCompilers 2012-07-15 22:22:01 -04:00
Shyotl
46f7250f08 Fixup multisample rbos. Samplecount validation all done in LLMultisampleBuffer::allocate, and falls back to non-multisample safely if multisampled rbos cannot/shouldn't be used. 2012-07-15 21:12:31 -05:00
Drake Arconis
58bfe23e5a Merge remote-tracking branch 'shyotl/V2MultiWear' into AltCompilers 2012-07-15 17:46:51 -04:00
Drake Arconis
ccb914ea83 General cleanup of OSX support - not done
Updated with new cursors from LL
Corrected mispackaged OSX Libs
Corrected mouse flicker on menus

Signed-off-by: Drake Arconis <lightdrake@gmail.com>
2012-07-15 17:45:50 -04:00
Shyotl
10fe67f4a6 FBO tweaks. Release multisample fbo in LLPipeline::releaseScreenBuffers, and fixed LLRenderBuffer::mInternalFormat falling out of sync with LLRenderBuffer::mTex. 2012-07-15 16:41:31 -05:00
Aleric Inglewood
a34247ebf4 Bug fix.
Don't test on something that belongs in an assert.
is_main_thread() doesn't even exist unless --type=Debug.
2012-07-15 23:08:07 +02:00
Aleric Inglewood
53e96b02c0 Bug fix. Forgot to actually make it virtual. 2012-07-15 22:59:29 +02:00
Aleric Inglewood
7c022d6061 Don't crash on exit.
When a new state machine was just created, so run() had already
been called but it never did really run yet so running() would
return false; then abort() wasn't called in flush(), causing
the subsequent mainloop call to actually try and startup the
state machine, which then crashed because Debug Settings
mechanism is already destroyed at that point (and in general,
we really don't want anything to run: it does unpredictable
things).

With this fix, also state machines that were just created are
aborted, resulting actuall in a kill without delete, and subsequently
a clean delete from the mainloop.
2012-07-15 22:51:14 +02:00
Aleric Inglewood
14e5b46687 Fixed and adjusted remainders of isValid() code.
Note that in the code, and still, has_curl_request was always false.
However, instead of deleting all code paths that are only executed
when has_curl_request would be true, I fixed the code to work as
intended with my current implementation; which also results in
LLCurlRequests to never expire. This way things won't break
unexpectedly when this ever changes.

Since on this branch isValid was only called still (the rest was
removed already) to check if the curl download expired, I took
the liberty to rename isValid to hasNotExpired.
2012-07-15 22:46:38 +02:00
Lirusaito
0243c61ea1 Spanish Translation is complete, add it to the completed combo_box area, and keep to alphabetical order. 2012-07-15 15:23:53 -04:00
Lirusaito
d73d4e9d48 Merge branch 'master' of git://github.com/TighMacFanatic/SingularityViewer 2012-07-15 15:10:40 -04:00
Lirusaito
3d60d9e3c5 Merge branch 'V2MultiWear' of https://github.com/DamianZhaoying/SingularityViewer 2012-07-15 15:10:09 -04:00
TighMacFanatic
329b708aaf Fix History button in IM panel not working for non-Windows users. 2012-07-15 15:07:05 -04:00
Lirusaito
59e0367dd4 Merge branch 'master' of git://github.com/TighMacFanatic/SingularityViewer 2012-07-15 14:52:46 -04:00
TighMacFanatic
56c85813ee Fix History button on local chat not working for non-Windows users. 2012-07-15 14:25:10 -04:00
Aleric Inglewood
a6bb2604f6 Use our API, which makes more sense. 2012-07-15 16:58:47 +02:00
Aleric Inglewood
b2c71c099f Fixed typo in comment 2012-07-15 16:57:47 +02:00
Drake Arconis
102eca7d65 Merge remote-tracking branch 'siana/master' into AltCompilers 2012-07-15 10:37:06 -04:00
Lirusaito
55a1d54b8e Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-07-15 09:56:04 -04:00
TighMacFanatic
0c313807ff Merge branch 'master' of https://github.com/siana/SingularityViewer 2012-07-15 05:56:19 -04:00
Siana Gearz
d5e685aaf2 Merge branch 'V2MultiWear' of https://github.com/Shyotl/SingularityViewer 2012-07-15 09:44:17 +02:00
TighMacFanatic
214fc0419d Merge branch 'V2MultiWear' of https://github.com/Shyotl/SingularityViewer 2012-07-15 00:01:53 -04:00
Lirusaito
1e24b889dd Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer 2012-07-14 21:47:43 -04:00
Shyotl
08dd79fafd Recent occlusion changes rearing their head again. Fix a crash when graphics set to low. 2012-07-14 20:42:47 -05:00
Lirusaito
988e2c3fdf Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer 2012-07-14 20:47:27 -04:00
Lirusaito
92dc20850d Added Terrain Scale ComboBox to graphics preferences panel.
Fixed up feature tables to use correct names, and to use the 7 for high TerrainScale.
2012-07-14 20:45:59 -04:00
Shyotl
fa9c366076 Fixed alpha textures not entering the alpha pool an alternative way. 2012-07-14 19:45:11 -05:00
Shyotl
08ab36a5d9 mPendingInventoryItemsIDs wasn't having entries removed. 2012-07-14 19:44:06 -05:00
Siana Gearz
c1c04b489c Revert "Possible fix for "No able to connect to SecondLife""
This reverts commit 66c95af093.
2012-07-15 02:29:00 +02:00
Siana Gearz
0caa321fe5 Merge branch 'V2MultiWear' of git://github.com/AlericInglewood/SingularityViewer 2012-07-14 22:02:06 +02:00
Lirusaito
3acaf773b8 Merge branch 'AltCompilers' of https://bitbucket.org/LightDrake/singularityviewer 2012-07-14 16:01:06 -04:00
Lirusaito
5080746fa0 Prevent build preferences from altering objects we've duplicated. Offer an off switch for build prefs.
Added LiruEnableBuildPrefs, for turning off, when users do not want to use their default build parameters for a few prims, but don't wish to reset them permanently.
    This should perhaps end up on the build floater somewhere... but for now, debug only.
Note some of this fix for duplication may be overly cautious, but better safe than sorry.
Added a check for physical default in during creation, so that building at great distances adheres a bit more to build preferences.
Added IsCOA into the build settings, since I'd forgotten, previously.
2012-07-14 15:54:36 -04:00
Aleric Inglewood
66c95af093 Possible fix for "No able to connect to SecondLife" 2012-07-14 20:57:55 +02:00
Aleric Inglewood
9241816a71 Include linden_common.h first. Needed for libcwd. 2012-07-14 20:04:55 +02:00
Drake Arconis
07e1f0e802 Added a terrain texture scale changer thing!
Need someone to add UI bits though >.<
2012-07-14 05:04:10 -04:00
Drake Arconis
340f8f1f17 MORE WINDLIGHTS! 2012-07-14 05:02:44 -04:00
Drake Arconis
0316b7ff9a OSX libwork
Started on osx libwork will need darwin builder to test
2012-07-14 04:10:09 -04:00
Aleric Inglewood
7416d2aaf1 Timer, time out, and clean up improvements. 2012-07-14 04:29:37 +02:00
Siana Gearz
cb61342e58 Merge branch 'V2MultiWear' of https://github.com/Shyotl/SingularityViewer 2012-07-13 13:45:02 +02:00
Siana Gearz
d99de40b2b Suppress error prevalent on OSGrid 2012-07-13 13:44:46 +02:00
Lirusaito
533675416c Merge branch 'V2MultiWear'
Conflicts:
	indra/newview/app_settings/settings.xml - Removed SinguMuteGestures, since it's EnableGestureSounds now.
		~removed in llviewermessage.cpp as well.
2012-07-13 05:44:38 -04:00
Damian Zhaoying
8baceee06c Add Spanish Translation 2012-07-13 06:23:37 -03:00
Lirusaito
f7bf5c33bc Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer into V2MultiWear 2012-07-12 17:43:53 -04:00
Shyotl
f8445030c7 Avoid making duplicate copies in item inventory when no-mod texture is dragged onto faces. 2012-07-12 16:33:05 -05:00
Shyotl
1d60131df7 Avoid switch statement in shaders on nvidia hardware, since some driver versions don't behave properly, apparently.. 2012-07-12 16:25:27 -05:00
Shyotl
539b6410fa Brought back the inventory item count display after loading has completed. 2012-07-12 16:09:42 -05:00
Lirusaito
75f067d5c9 Added crossfade checkbox to Windlight remote panel. 2012-07-12 13:35:56 -04:00
Lirusaito
518e9b7513 Merge branch 'master' of git://github.com/siana/SingularityViewer into V2MultiWear 2012-07-12 12:40:41 -04:00
Siana Gearz
0314bb4d38 Apparently Laika Tungsten's name is nhede Core 2012-07-12 18:34:49 +02:00
Siana Gearz
ddfe004204 Restore function of day cycle editor 2012-07-12 18:33:10 +02:00
Siana Gearz
07375e7a39 Merge branch 'V2MultiWear' of https://github.com/Shyotl/SingularityViewer
Conflicts:
	indra/llrender/llvertexbuffer.h
2012-07-12 08:30:35 +02:00
Lirusaito
44b69f3d3e Merge branch 'V2MultiWear' of git://github.com/Shyotl/SingularityViewer into V2MultiWear
Conflicts:
	indra/llrender/llvertexbuffer.h Chose Shyotl's.
2012-07-11 23:23:31 -04:00
Shyotl
bca4cf8584 Revert LLs recent VBO alterations, as they aren't proving to be all that great.. 2012-07-11 17:13:37 -05:00
Shyotl
4f3f503953 Recreate mDeferredVB on vertexbuffer reset.
Shuffled some code from LLVOPartGroup::restoreGL() to LLVOPartGroup::destroyGL(), as it makes more sense there.
Bind the correct shader in wireframe..
glLineStipple call managed to sneak into no-fixed-function mode.
LLViewerWindow::initFonts was called frequently and redundantly during destroygl->restoregl transition.
2012-07-11 17:12:40 -05:00
Lirusaito
1df635a164 Merge branch 'master' of git://github.com/siana/SingularityViewer into V2MultiWear 2012-07-11 12:44:41 -04:00
Siana Gearz
f3ae5789be Fix mute in voice 2012-07-11 18:43:31 +02:00
Lirusaito
cf7cd21474 Merge branch 'master' of git://github.com/siana/SingularityViewer into V2MultiWear 2012-07-11 12:37:37 -04:00
Lirusaito
0f8fbcfcc1 Disallow the user from self-muting and remove them from the mutelist if this was the case.
Works around other viewers allowing the user to mute themself.
2012-07-11 10:47:40 -04:00
Siana Gearz
a1f9109392 Don't try to HTTP inventory fetch when we can't 2012-07-11 14:54:20 +02:00
Siana Gearz
c648be6410 Merge branch 'AltCompilers' of bitbucket.org:LightDrake/singularityviewer 2012-07-11 07:38:58 +02:00
Lirusaito
6fa0b668ba Merge branch 'master' of git://github.com/TighMacFanatic/SingularityViewer into V2MultiWear 2012-07-10 19:51:45 -04:00
TighMacFanatic
1925b24512 Fix "Enable highlighting of selected prims" so it actually does something. 2012-07-10 19:48:11 -04:00
Drake Arconis
1101b4075a Merge remote-tracking branch 'siana/master' into AltCompilers 2012-07-10 14:16:24 -04:00
Drake Arconis
edb144bd1d Fixed ugly workaround for compiler detection
Corrected ugly workaround for compiler detection in code with
correct definition in llpreprocessor.h and updated various #if
to reflect this.
2012-07-10 14:15:59 -04:00
Drake Arconis
bcefad1a97 Massive windlight preset cleanup and updates
Cleaned up all duplicate windlight presets
Renamed windlight presets under correct current prefixes
Imported new presets from FS and Alchemy
2012-07-10 14:14:31 -04:00
Aleric Inglewood
0419f8bee9 Add an AITimer to AICurlEasyRequestStateMachine.
Fixes AIStateMachine to work thread-safe with the timer.
2012-07-10 05:09:08 +02:00
Drake Arconis
a67fe755cd Fixed line endings
Fixed the line endings of the windlight files to unix
2012-07-09 12:32:34 -04:00
Aleric Inglewood
f012f664d2 Threading voodoo: allow multiple concurrent calls to set_state().
This patch prepares AIStateMachine for the use of AITimer together
with calls to set_state() from other threads. The extra problem
in this case is that the main-thread CAN start running the state
machine again (when the timer times out), while before it was
assumed to be idle until a thread called set_state.

This also takes into account that a thread might call set_state()
and then AGAIN call set_state() before the main thread gets the
chance to call idle() inbetween.
2012-07-09 04:19:28 +02:00
Aleric Inglewood
744563a150 Use a newer libcurl version for linux. 2012-07-07 23:22:48 +02:00
Aleric Inglewood
389074d1e9 Fail at configure time when openGL is not found 2012-07-07 23:17:22 +02:00
Aleric Inglewood
93778eccbb Compile fix for g++ 4.7 2012-07-07 18:29:55 +02:00
Aleric Inglewood
f46d8e8a10 Try to be smart about not printing garbage (binary) received from the server. 2012-07-05 23:50:03 +02:00
Siana Gearz
f5bfab139c Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-05 06:06:04 +02:00
Aleric Inglewood
df20f918ba New libcwd channel 'curlio'.
Enable printing of libcurl 'IO' debug messages when libcwd channel
'curlio' is turned on (added to .libcwdrc). Avoiding a recompile.
2012-07-05 03:10:16 +02:00
Aleric Inglewood
b8fc1f634e Print the curl library found during configure.
Prints something like:
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.25.0")
2012-07-05 01:41:01 +02:00
Aleric Inglewood
ae9dadb5d8 Improved layout of curl stats print out. 2012-07-04 16:56:33 +02:00
Siana Gearz
d31c062693 Fix building with libcwd 2012-07-04 12:44:05 +02:00
Siana Gearz
544928a039 Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading 2012-07-04 10:45:48 +02:00
Aleric Inglewood
14276b3cf8 Bug fix 2012-07-04 08:44:22 +02:00
Aleric Inglewood
07e7eeedd1 Added some windows code.
Iterating directly over the elements of fd_set::fd_array in
windows is faster than using FD_ISSET.
2012-07-04 07:32:24 +02:00
Aleric Inglewood
125a10bb44 Code hardening, review, bug fixes, documentation, curl stats and cleanup.
Bug fixes:
AICurlEasyRequestStateMachine didn't delete itself.
curl_multi_socket_action calls were made for potentional removed sockets.
The curl thread wasn't terminated.
2012-07-04 00:10:43 +02:00
Aleric Inglewood
9b8e5c8719 Merge branch 'V2MultiWear' into curlthreading2
I picked a few non-curl related patches from curlthreading2
and applied them to V2MultiWear. Now merging back to avoid
collisions for others.
2012-07-03 14:27:12 +02:00
Aleric Inglewood
a803507d67 Use correct way to check if we logged in yet or not.
Without this fix, we trigger an assert, in debug mode, that was added
to Singularity exactly to find out if we called functions like
getExpandedFilename(LL_PATH_PER_SL_ACCOUNT ...) before logging in.
Checking if THAT function returns empty() is clearly not safe, but
very error prone.
2012-07-01 22:15:03 +02:00
Aleric Inglewood
cb5efad026 Turn llassert[_always] into a (single) statement and print line nr in decimal. 2012-06-30 21:14:18 +02:00
Aleric Inglewood
26922a1578 Merge remote-tracking branch 'lirusaito/curlthreading2' into curlthreading2 2012-06-29 05:28:58 +02:00
Aleric Inglewood
90493b6571 Add support for libopenSSL older than version 1.0.0. 2012-06-29 05:20:24 +02:00
Aleric Inglewood
2dee921cd5 Fix libcurl version check. 2012-06-29 01:33:38 +02:00
Lirusaito
433c7c3f99 Spelling fixes and stuff like that to AICurl* and llproxy.* documentations
Also removes a duplicate include from llares.cpp

Conflicts:
	indra/llmessage/aicurl.cpp
2012-06-28 04:08:25 -04:00
Lirusaito
fef461fd13 Grabbed openSSL-1.0.0d from upstream for linux, necessary for non-standalone compiles.
Also brought in linux64 version I had sitting around, collecting dust.
2012-06-28 03:46:22 -04:00
Aleric Inglewood
1f56645b69 Always set proxy settings for every HTTP curl connection.
Move applyProxySettings to CurlEasyRequest and call it from
applyDefaultOptions.

Use AIThreadSafe for LLProxy for a more robust threadsafeness.
(This forces correct locking, checks that the unshared vars
are indeed unshared and made it easy to use read/write locking,
which might be important in this case (we do a lot of read-only
accesses to it).
2012-06-28 05:56:21 +02:00
Aleric Inglewood
69ca6cd5b2 WIP: Make curl thread code robust and flexible.
Conflicts:

	indra/llmessage/llcurl.cpp
	indra/llmessage/llcurl.h
	indra/newview/app_settings/settings.xml
	indra/newview/llappviewer.cpp
	indra/newview/llmeshrepository.cpp

Resolved:

	indra/llmessage/llcurl.cpp:

	  Basically removed (not used anyway)

	indra/llmessage/llcurl.h:

	  Basically removed (just includes aiculr.h now)

	indra/newview/app_settings/settings.xml:

	  CurlUseMultipleThreads was remvoved.
	  CurlMaximumNumberOfHandles and CurlRequestTimeOut
	  are still in there, but unused at the moment.

	indra/newview/llappviewer.cpp:

	  CurlMaximumNumberOfHandles and CurlRequestTimeOut
	  are unused at the moment.

	indra/newview/llmeshrepository.cpp:

	  Lock mSignal always (is unlocked inside wait()).
	  Use mSignal lock to see if we are waiting; remove mWaiting.
	  Return false from the MeshFetch functions iff we have to retry
	  a HTTP fetch. Catch the error exception thrown by getByteRange
	  instead of using it's return value (always returns true
	  anyway).
2012-06-28 01:30:46 +02:00
Lirusaito
8805e3fb27 Nomade Zhao's 4 fixes for translation. Re: Issue 340 2012-03-28 00:00:42 -04:00
Lirusaito
64d8397ea5 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-27 19:48:05 -04:00
Lirusaito
4d4496fc4d Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-27 19:29:24 -04:00
Lirusaito
af67342969 Merge branch 'master' of git://github.com/siana/SingularityViewer
Conflicts:
	indra/llrender/llvertexbuffer.cpp
Also, reverts indra/newview/skins/default/xui/en-us/panel_audio.xml to before mute-gesture button (For now can be toggled through SinguMuteGestures debug setting)
2012-03-27 07:15:48 -04:00
Lirusaito
d9cbd52ea8 Fix for compiler warning in LLVertexBuffer::setupVertexArray. 2012-03-23 22:45:55 -04:00
Lirusaito
8b25d44bcf Replaced a tab with a space in XML so Windows doesn't show an awkward square there. 2012-03-23 17:21:50 -04:00
Lirusaito
3d6733bed8 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-23 17:20:04 -04:00
Lirusaito
c3f3db518b Fixed Issue 340, multiple instances of same name breaking translation.
Applies to advanced chat preferences only.
2012-03-19 18:08:17 -04:00
Lirusaito
385ec62e53 Added scale_image="false" to all mute buttons.
This will allow the mute icons to retain their normal look,
with Shyotl's changes to the UI code.
2012-03-14 08:55:10 -04:00
Lirusaito
881524831f Merge branch 'master' of https://bitbucket.org/Lirusaito/singularityviewer 2012-03-14 02:58:45 -04:00
Lirusaito
376be8b990 Spelling fix in a comment. 2012-03-14 02:53:44 -04:00
Lirusaito
96ddbf2a8b Added scale_image="false" to the gesture mute button so it won't span the width of the button. 2012-03-03 01:38:53 -05:00
Lirusaito
c2ee420917 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-03-01 18:16:39 -05:00
Lirusaito
74a1ba0d1e Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-29 10:52:26 -05:00
Lirusaito
0dc05a39e6 Use Ctrl-shift-D for creating a landmarks, instead, and fix previous misplacement of the shortcut. 2012-02-28 13:05:06 -05:00
Lirusaito
72fe406f64 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-24 18:39:25 -05:00
Lirusaito
90ac174260 Added Ctrl-D for creating a landmark
Most browsers use this for creating bookmarks, landmarks are pretty much
the same.
2012-02-24 14:07:58 -05:00
Lirusaito
b555e02220 Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-23 16:27:46 -05:00
Lirusaito
507c94c24c Merge branch 'master' of git://github.com/siana/SingularityViewer 2012-02-22 17:20:21 -05:00
Lirusaito
2699fa8cf9 Merge branch 'master' of https://github.com/LightDrake/SingularityViewer 2012-02-22 11:23:59 -05:00
Lirusaito
513002416c Corrected text to say viewer's website, since we are not Imprudence. 2012-02-22 09:50:19 -05:00
Lirusaito
22530cd77e Prevent snapshot resolution from going over window size, when showing UI or HUD in snapshots is enabled.
Otherwise snapshots do not have UI/HUD shown, despite enabling RenderUIInSnapshot or RenderHUDInSnapshot.
2012-02-22 09:23:09 -05:00
Lirusaito
81521b98fd Added gesture_muted icon, reworked the panel_audio to look better, and have mute gesture look more like the rest of the panel. 2012-02-22 06:22:05 -05:00
Lirusaito
73c2feee97 Merge branch 'master' of git://github.com/AlericInglewood/SingularityViewer 2012-02-21 16:46:22 -05:00
Lirusaito
d4212d390d Merge branch 'master' of git://github.com/TighMacFanatic/SingularityViewer 2012-02-20 17:27:52 -05:00
Lirusaito
2b8a55f396 Add DisableCameraConstraints to the "Camera Options:" checkboxes on Input & Camera Preferences(panel_preferences_input.xml) 2012-02-20 17:13:35 -05:00
Lirusaito
f253da09ec Added gesture muting feature, like phoenix has. 2012-02-20 16:02:56 -05:00
Lirusaito
e232abdab2 Merge branch 'master' of git://github.com/siana/SingularityViewer
Conflicts:
	indra/newview/skins/dark/colors_base.xml
	indra/newview/skins/gemini/colors_base.xml
	indra/newview/skins/pslgreen/colors_base.xml
	indra/newview/skins/pslpurple/colors_base.xml
	indra/newview/skins/sapphire/colors_base.xml
2012-02-20 00:01:04 -05:00
Lirusaito
fae40e0bdf Fix to "Replace all NotifyCautionBoxColor's and AlertCautionBoxColor's that were using tan with black"(0fef1407e3), to only apply to skins where the tan background was too similar to the font color.
Also, for skins now using this black background, adjust foreground color to show up and match the skin, in cases where it was black.
2012-02-19 19:58:34 -05:00
991 changed files with 64279 additions and 46166 deletions

View File

@@ -130,7 +130,6 @@ if (LINUX)
add_definitions(-DLL_IGNORE_SIGCHLD) add_definitions(-DLL_IGNORE_SIGCHLD)
if(${CMAKE_C_COMPILER} MATCHES "gcc*") if(${CMAKE_C_COMPILER} MATCHES "gcc*")
find_program(GXX g++) find_program(GXX g++)
mark_as_advanced(GXX) mark_as_advanced(GXX)
@@ -183,9 +182,6 @@ if (LINUX)
# End of hacks. # End of hacks.
#GCC Specific
add_definitions(-DCC_GCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
if (NOT STANDALONE) if (NOT STANDALONE)
@@ -217,7 +213,6 @@ if (LINUX)
mark_as_advanced(CLANGXX) mark_as_advanced(CLANGXX)
add_definitions( add_definitions(
-DCC_CLANG
-D_FORTIFY_SOURCE=2 -D_FORTIFY_SOURCE=2
) )
@@ -237,12 +232,10 @@ if (LINUX)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
elseif(${CMAKE_C_COMPILER} MATCHES "icc*" AND ${CMAKE_CXX_COMPILER} MATCHES "icpc*") elseif(${CMAKE_C_COMPILER} MATCHES "icc*" AND ${CMAKE_CXX_COMPILER} MATCHES "icpc*")
find_program(ICC icc) find_program(ICC icc)
mark_as_advanced(ICC) mark_as_advanced(ICC)
add_definitions( add_definitions(
-DCC_ICC
-D_FORTIFY_SOURCE=2 -D_FORTIFY_SOURCE=2
) )
@@ -276,14 +269,23 @@ if (DARWIN)
add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE) add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE)
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first") set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch") if(${CMAKE_C_COMPILER} MATCHES "gcc*")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
# NOTE: it's critical that the optimization flag is put in front. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch")
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered. # NOTE: it's critical that the optimization flag is put in front.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}") # NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
elseif(${CMAKE_C_COMPILER} MATCHES "clang*")
# NOTE: it's critical that the optimization flag is put in front.
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3")
endif()
endif (DARWIN) endif (DARWIN)

View File

@@ -33,8 +33,8 @@ else (STANDALONE)
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib
) )
set(APRUTIL_LIBRARIES set(APRUTIL_LIBRARIES
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.0.dylib debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.dylib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.dylib optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.dylib
) )
set(APRICONV_LIBRARIES iconv) set(APRICONV_LIBRARIES iconv)
else (WINDOWS) else (WINDOWS)

View File

@@ -40,10 +40,10 @@ else (STANDALONE)
debug libboost_regex-vc${MSVC_SUFFIX}-${BOOST_DEBUG_SUFFIX}-${BOOST_VERSION}) debug libboost_regex-vc${MSVC_SUFFIX}-${BOOST_DEBUG_SUFFIX}-${BOOST_VERSION})
elseif (DARWIN) elseif (DARWIN)
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt) set(BOOST_FILESYSTEM_LIBRARY boost_filesystem)
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt) set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options)
set(BOOST_REGEX_LIBRARY boost_regex-mt) set(BOOST_REGEX_LIBRARY boost_regex)
set(BOOST_SYSTEM_LIBRARY boost_system-mt) set(BOOST_SYSTEM_LIBRARY boost_system)
elseif (LINUX) elseif (LINUX)
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt) set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt) set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)

View File

@@ -1,7 +1,7 @@
# -*- cmake -*- # -*- cmake -*-
include(Prebuilt) include(Prebuilt)
set(CURL_FIND_QUIETLY ON) set(CURL_FIND_QUIETLY OFF)
set(CURL_FIND_REQUIRED ON) set(CURL_FIND_REQUIRED ON)
if (STANDALONE) if (STANDALONE)
@@ -14,6 +14,9 @@ else (STANDALONE)
optimized libcurl) optimized libcurl)
else (WINDOWS) else (WINDOWS)
set(CURL_LIBRARIES curl) set(CURL_LIBRARIES curl)
if(LINUX AND WORD_SIZE EQUAL 64)
list(APPEND CURL_LIBRARIES idn)
endif(LINUX AND WORD_SIZE EQUAL 64)
endif (WINDOWS) endif (WINDOWS)
set(CURL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) set(CURL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
endif (STANDALONE) endif (STANDALONE)

View File

@@ -18,7 +18,7 @@ if (NOT FMODEX_LIBRARY)
set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.") set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.")
if (FMODEX_SDK_DIR) if (FMODEX_SDK_DIR)
find_library(FMODEX_LIBRARY find_library(FMODEX_LIBRARY
fmodex fmodex_vc fmodexL_vc fmodex_vc fmodexL_vc fmodex fmodexL fmodex64 fmodexL64
PATHS PATHS
${FMODEX_SDK_DIR}/api/lib ${FMODEX_SDK_DIR}/api/lib
${FMODEX_SDK_DIR}/api ${FMODEX_SDK_DIR}/api

View File

@@ -1,12 +1,16 @@
# -*- cmake -*- # -*- cmake -*-
include(Prebuilt) include(Prebuilt)
if(WORD_SIZE EQUAL 64)
set(DISABLE_TCMALLOC TRUE)
endif(WORD_SIZE EQUAL 64)
if (STANDALONE) if (STANDALONE)
include(FindGooglePerfTools) include(FindGooglePerfTools)
else (STANDALONE) else (STANDALONE)
if (LINUX OR WINDOWS) if (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
use_prebuilt_binary(gperftools) use_prebuilt_binary(gperftools)
endif (LINUX OR WINDOWS) endif (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
if (WINDOWS) if (WINDOWS)
set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib) set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib)
set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"") set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"")

View File

@@ -6,7 +6,7 @@ if (STANDALONE)
else (STANDALONE) else (STANDALONE)
use_prebuilt_binary(hunspell) use_prebuilt_binary(hunspell)
set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/hunspell) set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/hunspell)
if (LINUX OR DARWIN) if (LINUX OR DARWIN)
set(HUNSPELL_LIBRARY hunspell-1.3) set(HUNSPELL_LIBRARY hunspell-1.3)

View File

@@ -13,8 +13,8 @@ else (STANDALONE)
set(JPEG_LIBRARIES jpeg) set(JPEG_LIBRARIES jpeg)
elseif (DARWIN) elseif (DARWIN)
set(JPEG_LIBRARIES set(JPEG_LIBRARIES
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/liblljpeg.a optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a
debug ${ARCH_PREBUILT_DIRS_DEBUG}/liblljpeg.a debug ${ARCH_PREBUILT_DIRS_DEBUG}/libjpeg.a
) )
elseif (WINDOWS) elseif (WINDOWS)
set(JPEG_LIBRARIES jpeglib) set(JPEG_LIBRARIES jpeglib)

View File

@@ -14,7 +14,7 @@ else (STANDALONE)
debug json_vc${MSVC_SUFFIX}d debug json_vc${MSVC_SUFFIX}d
optimized json_vc${MSVC_SUFFIX}) optimized json_vc${MSVC_SUFFIX})
elseif (DARWIN) elseif (DARWIN)
set(JSONCPP_LIBRARIES json_mac-universal-gcc_libmt) set(JSONCPP_LIBRARIES json_linux-gcc-4.0.1_libmt)
elseif (LINUX) elseif (LINUX)
set(JSONCPP_LIBRARIES jsoncpp) set(JSONCPP_LIBRARIES jsoncpp)
endif (WINDOWS) endif (WINDOWS)

View File

@@ -18,7 +18,11 @@ else (STANDALONE)
use_prebuilt_binary(SDL) use_prebuilt_binary(SDL)
set (SDL_FOUND TRUE) set (SDL_FOUND TRUE)
set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}) set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR})
set (SDL_LIBRARY SDL directfb fusion direct) if(WORD_SIZE EQUAL 64)
set (SDL_LIBRARY SDL)
else(WORD_SIZE EQUAL 64)
set (SDL_LIBRARY SDL directfb fusion direct)
endif(WORD_SIZE EQUAL 64)
endif (LINUX) endif (LINUX)
endif (STANDALONE) endif (STANDALONE)

View File

@@ -10,9 +10,9 @@ if (NOT STANDALONE)
set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS}) set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS})
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS}) set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS})
elseif (DARWIN) elseif (DARWIN)
set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release) set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib)
set(ARCH_PREBUILT_DIRS ${ARCH_PREBUILT_DIRS_RELEASE}) set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release)
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS_RELEASE}) set(ARCH_PREBUILT_DIRS_DEBUG ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/debug)
endif (WINDOWS) endif (WINDOWS)
endif (NOT STANDALONE) endif (NOT STANDALONE)

View File

@@ -16,8 +16,6 @@ else (STANDALONE)
set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include) set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
endif (STANDALONE) endif (STANDALONE)
if (LINUX) if (LINUX OR DARWIN)
set(CRYPTO_LIBRARIES crypto) set(CRYPTO_LIBRARIES crypto)
elseif (DARWIN) endif (LINUX OR DARWIN)
set(CRYPTO_LIBRARIES llcrypto)
endif (LINUX)

View File

@@ -76,37 +76,36 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(DARWIN 1) set(DARWIN 1)
#SDK Compiler and Deployment targets for XCode if(${CMAKE_GENERATOR} MATCHES Xcode)
if (${XCODE_VERSION} VERSION_LESS 4.0.0) #SDK Compiler and Deployment targets for XCode
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk) if (${XCODE_VERSION} VERSION_LESS 4.0.0)
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2") set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
else (${XCODE_VERSION} VERSION_LESS 4.0.0) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2")
else (${XCODE_VERSION} VERSION_LESS 4.0.0)
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
endif (${XCODE_VERSION} VERSION_LESS 4.0.0)
else()
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk) set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.6.sdk)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42") set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
endif (${XCODE_VERSION} VERSION_LESS 4.0.0) endif(${CMAKE_GENERATOR} MATCHES Xcode)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5) ## We currently support only 32-bit i386 builds, so use these:
set(CMAKE_OSX_ARCHITECTURES i386)
set(ARCH i386)
set(WORD_SIZE 32)
# NOTE: To attempt an i386/PPC Universal build, add this on the configure line: ## But if you want to compile for mixed 32/64 bit, try these:
# -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc' # set(CMAKE_OSX_ARCHITECTURES i386;x86_64)
# Build only for i386 by default, system default on MacOSX 10.6 is x86_64 # set(ARCH universal)
if (NOT CMAKE_OSX_ARCHITECTURES) # set(WORD_SIZE 64)
set(CMAKE_OSX_ARCHITECTURES i386)
endif (NOT CMAKE_OSX_ARCHITECTURES)
if (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
set(ARCH universal)
else (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
set(ARCH ppc)
else (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
set(ARCH i386)
endif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
endif (CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
## Finally, set up the build output directories
set(LL_ARCH ${ARCH}_darwin) set(LL_ARCH ${ARCH}_darwin)
set(LL_ARCH_DIR universal-darwin) set(LL_ARCH_DIR universal-darwin)
set(WORD_SIZE 32)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

View File

@@ -173,6 +173,8 @@ void stop_recording_backtraces(void)
channel_ct backtrace DDCN("BACKTRACE"); //!< This debug channel is used for backtraces. channel_ct backtrace DDCN("BACKTRACE"); //!< This debug channel is used for backtraces.
channel_ct statemachine DDCN("STATEMACHINE"); //!< This debug channel is used for output related to class AIStateMachine. channel_ct statemachine DDCN("STATEMACHINE"); //!< This debug channel is used for output related to class AIStateMachine.
channel_ct caps DDCN("CAPS"); //!< This debug channel is used for output related to Capabilities. channel_ct caps DDCN("CAPS"); //!< This debug channel is used for output related to Capabilities.
channel_ct curl DDCN("CURL"); //!< This debug channel is used for output related to Curl.
channel_ct curlio DDCN("CURLIO"); //!< This debug channel is used to print debug output of libcurl.
} // namespace dc } // namespace dc
} // namespace DEBUGCHANNELS } // namespace DEBUGCHANNELS

View File

@@ -118,6 +118,8 @@ extern CWD_API channel_ct sdl;
extern CWD_API channel_ct backtrace; extern CWD_API channel_ct backtrace;
extern CWD_API channel_ct statemachine; extern CWD_API channel_ct statemachine;
extern CWD_API channel_ct caps; extern CWD_API channel_ct caps;
extern CWD_API channel_ct curl;
extern CWD_API channel_ct curlio;
#endif #endif

View File

@@ -95,6 +95,28 @@ inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string)
return true; return true;
} }
void* F_STDCALL decode_alloc(unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
if(type & FMOD_MEMORY_STREAM_DECODE)
{
llinfos << "Decode buffer size: " << size << llendl;
}
else if(type & FMOD_MEMORY_STREAM_FILE)
{
llinfos << "Strean buffer size: " << size << llendl;
}
return new char[size];
}
void* F_STDCALL decode_realloc(void *ptr, unsigned int size, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
memset(ptr,0,size);
return ptr;
}
void F_STDCALL decode_dealloc(void *ptr, FMOD_MEMORY_TYPE type, const char *sourcestr)
{
delete[] (char*)ptr;
}
bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata) bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
{ {
@@ -108,6 +130,10 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
LL_DEBUGS("AppInit") << "LLAudioEngine_FMODEX::init() initializing FMOD" << LL_ENDL; LL_DEBUGS("AppInit") << "LLAudioEngine_FMODEX::init() initializing FMOD" << LL_ENDL;
result = FMOD::Memory_Initialize(NULL, 0, &decode_alloc, &decode_realloc, &decode_dealloc, FMOD_MEMORY_STREAM_DECODE | FMOD_MEMORY_STREAM_FILE);
if(Check_FMOD_Error(result, "FMOD::Memory_Initialize"))
return false;
result = FMOD::System_Create(&mSystem); result = FMOD::System_Create(&mSystem);
if(Check_FMOD_Error(result, "FMOD::System_Create")) if(Check_FMOD_Error(result, "FMOD::System_Create"))
return false; return false;
@@ -124,54 +150,8 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
<< ")! You should be using FMOD Ex" << FMOD_VERSION << LL_ENDL; << ")! You should be using FMOD Ex" << FMOD_VERSION << LL_ENDL;
} }
#if LL_WINDOWS result = mSystem->setSoftwareFormat(44100, FMOD_SOUND_FORMAT_PCM16, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
int numdrivers; Check_FMOD_Error(result,"FMOD::System::setSoftwareFormat");
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
char name[256];
//Is this block applicable to linux?
{
result = mSystem->getNumDrivers(&numdrivers);
Check_FMOD_Error(result, "FMOD::System::getNumDrivers");
if (numdrivers == 0)
{
result = mSystem->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
Check_FMOD_Error(result, "FMOD::System::setOutput");
}
else
{
result = mSystem->getDriverCaps(0, &caps, 0, &speakermode);
Check_FMOD_Error(result,"FMOD::System::getDriverCaps");
/*
Set the user selected speaker mode.
*/
result = mSystem->setSpeakerMode(speakermode);
Check_FMOD_Error(result, "FMOD::System::setSpeakerMode");
if (caps & FMOD_CAPS_HARDWARE_EMULATED)
{
/*
The user has the 'Acceleration' slider set to off! This is really bad
for latency! You might want to warn the user about this.
*/
result = mSystem->setDSPBufferSize(1024, 10);
Check_FMOD_Error(result, "FMOD::System::setDSPBufferSize");
}
result = mSystem->getDriverInfo(0, name, 256, 0);
Check_FMOD_Error(result, "FMOD::System::getDriverInfo");
if (strstr(name, "SigmaTel"))
{
/*
Sigmatel sound devices crackle for some reason if the format is PCM 16bit.
PCM floating point output seems to solve it.
*/
result = mSystem->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
Check_FMOD_Error(result,"FMOD::System::setSoftwareFormat");
}
}
}
#endif //LL_WINDOWS
// In this case, all sounds, PLUS wind and stream will be software. // In this case, all sounds, PLUS wind and stream will be software.
result = mSystem->setSoftwareChannels(num_channels + 2); result = mSystem->setSoftwareChannels(num_channels + 2);
@@ -297,6 +277,19 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
LL_INFOS("AppInit") << "LLAudioEngine_FMODEX::init() FMOD Ex initialized correctly" << LL_ENDL; LL_INFOS("AppInit") << "LLAudioEngine_FMODEX::init() FMOD Ex initialized correctly" << LL_ENDL;
int r_numbuffers, r_samplerate, r_channels, r_bits;
unsigned int r_bufferlength;
char r_name[256];
mSystem->getDSPBufferSize(&r_bufferlength, &r_numbuffers);
mSystem->getSoftwareFormat(&r_samplerate, NULL, &r_channels, NULL, NULL, &r_bits);
mSystem->getDriverInfo(0, r_name, 255, 0);
r_name[255] = '\0';
int latency = 1000.0 * r_bufferlength * r_numbuffers /r_samplerate;
LL_INFOS("AppInit") << "FMOD device: "<< r_name << "\n"
<< "FMOD Ex parameters: " << r_samplerate << " Hz * " << r_channels << " * " <<r_bits <<" bit\n"
<< "\tbuffer " << r_bufferlength << " * " << r_numbuffers << " (" << latency <<"ms)" << LL_ENDL;
mInited = true; mInited = true;
return true; return true;

View File

@@ -58,6 +58,9 @@ class LLStreamingAudioInterface
virtual const LLSD *getMetaData() = 0; virtual const LLSD *getMetaData() = 0;
virtual bool supportsWaveData() = 0; virtual bool supportsWaveData() = 0;
virtual bool getWaveData(float* arr, S32 count, S32 stride = 1) = 0; virtual bool getWaveData(float* arr, S32 count, S32 stride = 1) = 0;
virtual bool supportsAdjustableBufferSizes(){return false;}
virtual void setBufferSizes(U32 streambuffertime, U32 decodebuffertime){};
}; };
#endif // LL_STREAMINGAUDIO_H #endif // LL_STREAMINGAUDIO_H

View File

@@ -50,7 +50,7 @@ public:
const std::string& getURL() { return mInternetStreamURL; } const std::string& getURL() { return mInternetStreamURL; }
FMOD_OPENSTATE getOpenState(); FMOD_OPENSTATE getOpenState(unsigned int* percentbuffered=NULL, bool* starving=NULL, bool* diskbusy=NULL);
protected: protected:
FMOD::System* mSystem; FMOD::System* mSystem;
FMOD::Channel* mStreamChannel; FMOD::Channel* mStreamChannel;
@@ -74,7 +74,7 @@ LLStreamingAudio_FMODEX::LLStreamingAudio_FMODEX(FMOD::System *system) :
{ {
// Number of milliseconds of audio to buffer for the audio card. // Number of milliseconds of audio to buffer for the audio card.
// Must be larger than the usual Second Life frame stutter time. // Must be larger than the usual Second Life frame stutter time.
const U32 buffer_seconds = 5; //sec const U32 buffer_seconds = 10; //sec
const U32 estimated_bitrate = 128; //kbit/sec const U32 estimated_bitrate = 128; //kbit/sec
mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES); mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES);
@@ -145,7 +145,10 @@ void LLStreamingAudio_FMODEX::update()
return; return;
} }
FMOD_OPENSTATE open_state = mCurrentInternetStreamp->getOpenState(); unsigned int progress;
bool starving;
bool diskbusy;
FMOD_OPENSTATE open_state = mCurrentInternetStreamp->getOpenState(&progress, &starving, &diskbusy);
if (open_state == FMOD_OPENSTATE_READY) if (open_state == FMOD_OPENSTATE_READY)
{ {
@@ -158,6 +161,7 @@ void LLStreamingAudio_FMODEX::update()
// Reset volume to previously set volume // Reset volume to previously set volume
setGain(getGain()); setGain(getGain());
mFMODInternetStreamChannelp->setPaused(false); mFMODInternetStreamChannelp->setPaused(false);
mLastStarved.stop();
} }
} }
else if(open_state == FMOD_OPENSTATE_ERROR) else if(open_state == FMOD_OPENSTATE_ERROR)
@@ -168,6 +172,7 @@ void LLStreamingAudio_FMODEX::update()
if(mFMODInternetStreamChannelp) if(mFMODInternetStreamChannelp)
{ {
//llinfos << "progress = " << progress << llendl;
if(!mMetaData) if(!mMetaData)
mMetaData = new LLSD; mMetaData = new LLSD;
@@ -237,12 +242,29 @@ void LLStreamingAudio_FMODEX::update()
} }
} }
} }
if(starving)
{
if(!mLastStarved.getStarted())
{
llinfos << "Stream starvation detected! Muting stream audio until it clears." << llendl;
llinfos << " (diskbusy="<<diskbusy<<")" << llendl;
llinfos << " (progress="<<progress<<")" << llendl;
mFMODInternetStreamChannelp->setMute(true);
}
mLastStarved.start();
}
else if(mLastStarved.getStarted() && mLastStarved.getElapsedTimeF32() > 1.f)
{
mLastStarved.stop();
mFMODInternetStreamChannelp->setMute(false);
}
} }
} }
} }
void LLStreamingAudio_FMODEX::stop() void LLStreamingAudio_FMODEX::stop()
{ {
mLastStarved.stop();
if(mMetaData) if(mMetaData)
{ {
delete mMetaData; delete mMetaData;
@@ -341,6 +363,11 @@ void LLStreamingAudio_FMODEX::setGain(F32 vol)
if(!mFMODInternetStreamChannelp || !mCurrentInternetStreamp) if(!mFMODInternetStreamChannelp || !mCurrentInternetStreamp)
return false; return false;
bool muted=false;
mFMODInternetStreamChannelp->getMute(&muted);
if(muted)
return false;
static std::vector<float> local_array(count); //Have to have an extra buffer to mix channels. Bleh. static std::vector<float> local_array(count); //Have to have an extra buffer to mix channels. Bleh.
if(count > (S32)local_array.size()) //Expand the array if needed. Try to minimize allocation calls, so don't ever shrink. if(count > (S32)local_array.size()) //Expand the array if needed. Try to minimize allocation calls, so don't ever shrink.
local_array.resize(count); local_array.resize(count);
@@ -442,9 +469,19 @@ bool LLAudioStreamManagerFMODEX::stopStream()
} }
} }
FMOD_OPENSTATE LLAudioStreamManagerFMODEX::getOpenState() FMOD_OPENSTATE LLAudioStreamManagerFMODEX::getOpenState(unsigned int* percentbuffered, bool* starving, bool* diskbusy)
{ {
FMOD_OPENSTATE state; FMOD_OPENSTATE state;
mInternetStream->getOpenState(&state,NULL,NULL,NULL); mInternetStream->getOpenState(&state,percentbuffered,starving,diskbusy);
return state; return state;
} }
void LLStreamingAudio_FMODEX::setBufferSizes(U32 streambuffertime, U32 decodebuffertime)
{
mSystem->setStreamBufferSize(streambuffertime/1000*128*128, FMOD_TIMEUNIT_RAWBYTES);
FMOD_ADVANCEDSETTINGS settings;
memset(&settings,0,sizeof(settings));
settings.cbsize=sizeof(settings);
settings.defaultDecodeBufferSize = decodebuffertime;//ms
mSystem->setAdvancedSettings(&settings);
}

View File

@@ -37,6 +37,7 @@
#include "stdtypes.h" // from llcommon #include "stdtypes.h" // from llcommon
#include "llstreamingaudio.h" #include "llstreamingaudio.h"
#include "lltimer.h"
//Stubs //Stubs
class LLAudioStreamManagerFMODEX; class LLAudioStreamManagerFMODEX;
@@ -66,6 +67,8 @@ class LLStreamingAudio_FMODEX : public LLStreamingAudioInterface
/*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing. /*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing.
/*virtual*/ bool supportsWaveData(){return true;} /*virtual*/ bool supportsWaveData(){return true;}
/*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1); /*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1);
/*virtual*/ bool supportsAdjustableBufferSizes(){return true;}
/*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime);
private: private:
FMOD::System *mSystem; FMOD::System *mSystem;
@@ -76,6 +79,8 @@ private:
std::string mURL; std::string mURL;
F32 mGain; F32 mGain;
LLTimer mLastStarved;
LLSD *mMetaData; LLSD *mMetaData;
}; };

View File

@@ -297,6 +297,20 @@ void LLApp::startErrorThread()
} }
} }
void LLApp::stopErrorThread()
{
LLApp::setStopped(); // Signal error thread that we stopped.
int count = 0;
while (mThreadErrorp && !mThreadErrorp->isStopped() && ++count < 100)
{
ms_sleep(10);
}
if (mThreadErrorp && !mThreadErrorp->isStopped())
{
llwarns << "Failed to stop Error Thread." << llendl;
}
}
void LLApp::setErrorHandler(LLAppErrorHandler handler) void LLApp::setErrorHandler(LLAppErrorHandler handler)
{ {
LLApp::sErrorHandler = handler; LLApp::sErrorHandler = handler;

View File

@@ -43,10 +43,14 @@ template <typename Type> class LLAtomic32;
typedef LLAtomic32<U32> LLAtomicU32; typedef LLAtomic32<U32> LLAtomicU32;
class LLErrorThread; class LLErrorThread;
class LLLiveFile; class LLLiveFile;
#if LL_LINUX #if LL_LINUX
typedef struct siginfo siginfo_t; #include <signal.h>
//typedef struct siginfo siginfo_t; //Removed as per changes in glibc 2.16 - Drake Arconis
#endif #endif
typedef void (*LLAppErrorHandler)(); typedef void (*LLAppErrorHandler)();
typedef void (*LLAppChildCallback)(int pid, bool exited, int status); typedef void (*LLAppChildCallback)(int pid, bool exited, int status);
@@ -260,6 +264,10 @@ protected:
* @ brief This method is called once as soon as logging is initialized. * @ brief This method is called once as soon as logging is initialized.
*/ */
void startErrorThread(); void startErrorThread();
/**
* @brief This method is called at the end, just prior to deinitializing curl.
*/
void stopErrorThread();
private: private:
void setupErrorHandling(); // Do platform-specific error-handling setup (signals, structured exceptions) void setupErrorHandling(); // Do platform-specific error-handling setup (signals, structured exceptions)

View File

@@ -114,7 +114,7 @@ const int LL_ERR_PRICE_MISMATCH = -23018;
: liru_slashpos2 == std::string::npos ? std::string(__FILE__)/*Apparently, we're in / or perhaps the top of the drive, print as is*/\ : liru_slashpos2 == std::string::npos ? std::string(__FILE__)/*Apparently, we're in / or perhaps the top of the drive, print as is*/\
: std::string(__FILE__).substr(1+liru_slashpos2))/*print foo/bar.cpp or perhaps foo\bar.cpp*/ : std::string(__FILE__).substr(1+liru_slashpos2))/*print foo/bar.cpp or perhaps foo\bar.cpp*/
#define llassert_always(func) if (LL_UNLIKELY(!(func))) llerrs <<"\nASSERT(" #func ")\nfile:"<<liru_assert_strip<<" line:"<<__LINE__ << llendl; #define llassert_always(func) do { if (LL_UNLIKELY(!(func))) llerrs << "\nASSERT(" #func ")\nfile:" << liru_assert_strip << " line:" << std::dec << __LINE__ << llendl; } while(0)
#ifdef SHOW_ASSERT #ifdef SHOW_ASSERT
#define llassert(func) llassert_always(func) #define llassert(func) llassert_always(func)

View File

@@ -194,17 +194,17 @@ void LLErrorThread::run()
if (LLApp::isError()) if (LLApp::isError())
{ {
// The app is in an error state, run the application's error handler. // The app is in an error state, run the application's error handler.
//llinfos << "thread_error - An error has occurred, running error callback!" << llendl; Dout(dc::notice, "thread_error - An error has occurred, running error callback!");
// Run the error handling callback // Run the error handling callback
LLApp::runErrorHandler(); LLApp::runErrorHandler();
} }
else else
{ {
// Everything is okay, a clean exit. // Everything is okay, a clean exit.
//llinfos << "thread_error - Application exited cleanly" << llendl; Dout(dc::notice, "thread_error - Application exited cleanly");
} }
//llinfos << "thread_error - Exiting" << llendl; Dout(dc::notice, "thread_error - Exiting");
LLApp::sErrorThreadRunning = FALSE; LLApp::sErrorThreadRunning = FALSE;
} }

View File

@@ -39,17 +39,13 @@
#include <hash_map> #include <hash_map>
#include <algorithm> #include <algorithm>
#elif LL_DARWIN || LL_LINUX #elif LL_DARWIN || LL_LINUX
#if CC_GCC || CC_ICC #if GCC_VERSION >= 40300 || LL_ICC// gcc 4.3 or icc 11 and up
# if GCC_VERSION >= 40300 || CC_ICC// gcc 4.3 or icc 11 and up # include <backward/hashtable.h>
# include <backward/hashtable.h> #elif GCC_VERSION >= 30400 // gcc 3.4 and up
# elif GCC_VERSION >= 30400 // gcc 3.4 and up # include <ext/hashtable.h>
# include <ext/hashtable.h> #elif __GNUC__ >= 3
# elif __GNUC__ >= 3 # include <ext/stl_hashtable.h>
# include <ext/stl_hashtable.h> #else
# else
# include <hashtable.h>
# endif
#elif CC_CLANG
# include <hashtable.h> # include <hashtable.h>
#endif #endif
#elif LL_SOLARIS #elif LL_SOLARIS

View File

@@ -78,7 +78,18 @@
// Figure out differences between compilers // Figure out differences between compilers
#if defined(__GNUC__) #if defined(__clang__) && defined(__GNUC__)
#define CLANG_VERSION (__clang_major__ * 10000 \
+ __clang_minor__ * 100 \
+ __clang_patchlevel__)
#ifndef LL_CLANG
#define LL_CLANG 1
#endif
#elif defined (__ICC) && defined(__GNUC__)
#ifndef LL_ICC
#define LL_ICC 1
#endif
#elif defined(__GNUC__)
#define GCC_VERSION (__GNUC__ * 10000 \ #define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \ + __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__) + __GNUC_PATCHLEVEL__)

View File

@@ -55,10 +55,10 @@
# define LL_X86 1 # define LL_X86 1
#elif LL_MSVC && _M_IX86 #elif LL_MSVC && _M_IX86
# define LL_X86 1 # define LL_X86 1
#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) ) #elif LL_GNUC || LL_ICC || LL_CLANG && ( defined(__amd64__) || defined(__x86_64__) )
# define LL_X86_64 1 # define LL_X86_64 1
# define LL_X86 1 # define LL_X86 1
#elif LL_GNUC && ( defined(__i386__) ) #elif LL_GNUC || LL_ICC || LL_CLANG && ( defined(__i386__) )
# define LL_X86 1 # define LL_X86 1
#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) ) #elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
# define LL_PPC 1 # define LL_PPC 1

View File

@@ -251,7 +251,7 @@ bool LLQueuedThread::addRequest(QueuedRequest* req)
// MAIN thread // MAIN thread
bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_complete) bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_complete)
{ {
llassert (handle != nullHandle()) llassert (handle != nullHandle());
bool res = false; bool res = false;
bool waspaused = isPaused(); bool waspaused = isPaused();
bool done = false; bool done = false;
@@ -264,7 +264,7 @@ bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_co
{ {
done = true; // request does not exist done = true; // request does not exist
} }
else if (req->getStatus() == STATUS_COMPLETE) else if (req->getStatus() == STATUS_COMPLETE && !(req->getFlags() & FLAG_LOCKED))
{ {
res = true; res = true;
if (auto_complete) if (auto_complete)
@@ -372,9 +372,17 @@ bool LLQueuedThread::completeRequest(handle_t handle)
#if _DEBUG #if _DEBUG
// llinfos << llformat("LLQueuedThread::Completed req [%08d]",handle) << llendl; // llinfos << llformat("LLQueuedThread::Completed req [%08d]",handle) << llendl;
#endif #endif
mRequestHash.erase(handle); if (!(req->getFlags() & FLAG_LOCKED))
req->deleteRequest(); {
// check(); mRequestHash.erase(handle);
req->deleteRequest();
// check();
}
else
{
// Cause deletion immediately after FLAG_LOCKED is released.
req->setFlags(FLAG_AUTO_COMPLETE);
}
res = true; res = true;
} }
unlockData(); unlockData();
@@ -421,12 +429,44 @@ S32 LLQueuedThread::processNextRequest()
if ((req->getFlags() & FLAG_ABORT) || (mStatus == QUITTING)) if ((req->getFlags() & FLAG_ABORT) || (mStatus == QUITTING))
{ {
req->setStatus(STATUS_ABORTED); req->setStatus(STATUS_ABORTED);
// Unlock, because we can't call finishRequest() while keeping this lock:
// generateHandle() takes this lock too and is called while holding a lock
// (ie LLTextureFetchWorker::mWorkMutex) that finishRequest will lock too,
// causing a dead lock.
// Although a complete rewrite of LLQueuedThread is in order because it's
// far from robust the way it handles it's locking; the following rationale
// at least makes plausible that releasing the lock here SHOULD work if
// the original coder didn't completely fuck up: if before the QueuedRequest
// req was only accessed while keeping the lock, then it still should
// never happen that another thread is waiting for this lock in order to
// access the QueuedRequest: a few lines lower we delete it.
// In other words, if directly after releasing this lock another thread
// would access req, then that can only happen by finding it again in
// either mRequestQueue or mRequestHash. We already deleted it from the
// first, so this access would have to happen by finding it in mRequestHash.
// Such access happens in the following functions:
// 1) LLQueuedThread::shutdown -- but it does that anyway, as it doesn't use any locking.
// 2) LLQueuedThread::generateHandle -- might skip our handle while before it would block until we deleted it. Skipping it is actually better.
// 3) LLQueuedThread::waitForResult -- this now doesn't touch the req when it has the flag FLAG_LOCKED set.
// 4) LLQueuedThread::getRequest -- whereever this is used, FLAG_LOCKED is tested before using the req.
// 5) LLQueuedThread::getRequestStatus -- this is a read-only operation on the status, which should never be changed from finishRequest().
// 6) LLQueuedThread::abortRequest -- it doesn't seem to hurt to add flags (if this happens at all), while calling finishRequest().
// 7) LLQueuedThread::setFlags -- same.
// 8) LLQueuedThread::setPriority -- doesn't access req with status STATUS_ABORTED, STATUS_COMPLETE or STATUS_INPROGRESS.
// 9) LLQueuedThread::completeRequest -- now sets FLAG_AUTO_COMPLETE instead of deleting the req, if FLAG_LOCKED is set, so that deletion happens here when finishRequest returns.
req->setFlags(FLAG_LOCKED);
unlockData();
req->finishRequest(false); req->finishRequest(false);
if (req->getFlags() & FLAG_AUTO_COMPLETE) lockData();
req->resetFlags(FLAG_LOCKED);
if ((req->getFlags() & FLAG_AUTO_COMPLETE))
{ {
req->resetFlags(FLAG_AUTO_COMPLETE);
mRequestHash.erase(req); mRequestHash.erase(req);
req->deleteRequest();
// check(); // check();
unlockData();
req->deleteRequest();
lockData();
} }
continue; continue;
} }
@@ -453,14 +493,23 @@ S32 LLQueuedThread::processNextRequest()
{ {
lockData(); lockData();
req->setStatus(STATUS_COMPLETE); req->setStatus(STATUS_COMPLETE);
req->finishRequest(true); req->setFlags(FLAG_LOCKED);
if (req->getFlags() & FLAG_AUTO_COMPLETE)
{
mRequestHash.erase(req);
req->deleteRequest();
// check();
}
unlockData(); unlockData();
req->finishRequest(true);
if ((req->getFlags() & FLAG_AUTO_COMPLETE))
{
lockData();
req->resetFlags(FLAG_AUTO_COMPLETE);
mRequestHash.erase(req);
// check();
req->resetFlags(FLAG_LOCKED);
unlockData();
req->deleteRequest();
}
else
{
req->resetFlags(FLAG_LOCKED);
}
} }
else else
{ {

View File

@@ -72,7 +72,8 @@ public:
enum flags_t { enum flags_t {
FLAG_AUTO_COMPLETE = 1, FLAG_AUTO_COMPLETE = 1,
FLAG_AUTO_DELETE = 2, // child-class dependent FLAG_AUTO_DELETE = 2, // child-class dependent
FLAG_ABORT = 4 FLAG_ABORT = 4,
FLAG_LOCKED = 8
}; };
typedef U32 handle_t; typedef U32 handle_t;
@@ -110,6 +111,8 @@ public:
return mPriority > second.mPriority; return mPriority > second.mPriority;
} }
virtual void deleteRequest(); // Only method to delete a request
protected: protected:
status_t setStatus(status_t newstatus) status_t setStatus(status_t newstatus)
{ {
@@ -122,10 +125,13 @@ public:
// NOTE: flags are |'d // NOTE: flags are |'d
mFlags |= flags; mFlags |= flags;
} }
void resetFlags(U32 flags)
{
mFlags &= ~flags;
}
virtual bool processRequest() = 0; // Return true when request has completed virtual bool processRequest() = 0; // Return true when request has completed
virtual void finishRequest(bool completed); // Always called from thread after request has completed or aborted virtual void finishRequest(bool completed); // Always called from thread after request has completed or aborted
virtual void deleteRequest(); // Only method to delete a request
void setPriority(U32 pri) void setPriority(U32 pri)
{ {

View File

@@ -310,15 +310,27 @@ void LLThread::wakeLocked()
} }
} }
#ifdef SHOW_ASSERT //static
// This allows the use of llassert(is_main_thread()) to assure the current thread is the main thread. apr_os_thread_t LLThread::sMainThreadID;
static apr_os_thread_t main_thread_id;
LL_COMMON_API bool is_main_thread(void) { return apr_os_thread_equal(main_thread_id, apr_os_thread_current()); } void LLThread::set_main_thread_id(void)
#endif {
sMainThreadID = apr_os_thread_current();
}
// The thread private handle to access the LLThreadLocalData instance. // The thread private handle to access the LLThreadLocalData instance.
apr_threadkey_t* LLThreadLocalData::sThreadLocalDataKey; apr_threadkey_t* LLThreadLocalData::sThreadLocalDataKey;
LLThreadLocalData::LLThreadLocalData(char const* name) : mCurlMultiHandle(NULL), mCurlErrorBuffer(NULL), mName(name)
{
}
LLThreadLocalData::~LLThreadLocalData()
{
delete mCurlMultiHandle;
delete [] mCurlErrorBuffer;
}
//static //static
void LLThreadLocalData::init(void) void LLThreadLocalData::init(void)
{ {
@@ -336,10 +348,8 @@ void LLThreadLocalData::init(void)
// Create the thread-local data for the main thread (this function is called by the main thread). // Create the thread-local data for the main thread (this function is called by the main thread).
LLThreadLocalData::create(NULL); LLThreadLocalData::create(NULL);
#ifdef SHOW_ASSERT
// This function is called by the main thread. // This function is called by the main thread.
main_thread_id = apr_os_thread_current(); LLThread::set_main_thread_id();
#endif
} }
// This is called once for every thread when the thread is destructed. // This is called once for every thread when the thread is destructed.
@@ -352,7 +362,7 @@ void LLThreadLocalData::destroy(void* thread_local_data)
//static //static
void LLThreadLocalData::create(LLThread* threadp) void LLThreadLocalData::create(LLThread* threadp)
{ {
LLThreadLocalData* new_tld = new LLThreadLocalData; LLThreadLocalData* new_tld = new LLThreadLocalData(threadp ? threadp->mName.c_str() : "main thread");
if (threadp) if (threadp)
{ {
threadp->mThreadLocalData = new_tld; threadp->mThreadLocalData = new_tld;

View File

@@ -40,13 +40,6 @@
#include "llaprpool.h" #include "llaprpool.h"
#include "llatomic.h" #include "llatomic.h"
#ifdef SHOW_ASSERT
extern LL_COMMON_API bool is_main_thread(void);
#define ASSERT_SINGLE_THREAD do { static apr_os_thread_t first_thread_id = apr_os_thread_current(); llassert(apr_os_thread_equal(first_thread_id, apr_os_thread_current())); } while(0)
#else
#define ASSERT_SINGLE_THREAD do { } while(0)
#endif
class LLThread; class LLThread;
class LLMutex; class LLMutex;
class LLCondition; class LLCondition;
@@ -57,6 +50,12 @@ class LLCondition;
#define ll_thread_local __thread #define ll_thread_local __thread
#endif #endif
class LL_COMMON_API LLThreadLocalDataMember
{
public:
virtual ~LLThreadLocalDataMember() { };
};
class LL_COMMON_API LLThreadLocalData class LL_COMMON_API LLThreadLocalData
{ {
private: private:
@@ -66,16 +65,24 @@ public:
// Thread-local memory pool. // Thread-local memory pool.
LLAPRRootPool mRootPool; LLAPRRootPool mRootPool;
LLVolatileAPRPool mVolatileAPRPool; LLVolatileAPRPool mVolatileAPRPool;
LLThreadLocalDataMember* mCurlMultiHandle; // Initialized by AICurlMultiHandle::getInstance
char* mCurlErrorBuffer; // NULL, or pointing to a buffer used by libcurl.
std::string mName; // "main thread", or a copy of LLThread::mName.
static void init(void); static void init(void);
static void destroy(void* thread_local_data); static void destroy(void* thread_local_data);
static void create(LLThread* pthread); static void create(LLThread* pthread);
static LLThreadLocalData& tldata(void); static LLThreadLocalData& tldata(void);
private:
LLThreadLocalData(char const* name);
~LLThreadLocalData();
}; };
class LL_COMMON_API LLThread class LL_COMMON_API LLThread
{ {
private: private:
static apr_os_thread_t sMainThreadID;
static U32 sIDIter; static U32 sIDIter;
static LLAtomicS32 sCount; static LLAtomicS32 sCount;
static LLAtomicS32 sRunning; static LLAtomicS32 sRunning;
@@ -99,6 +106,7 @@ public:
static S32 getCount() { return sCount; } static S32 getCount() { return sCount; }
static S32 getRunning() { return sRunning; } static S32 getRunning() { return sRunning; }
static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure. static void yield(); // Static because it can be called by the main thread, which doesn't have an LLThread data structure.
static bool is_main_thread(void) { return apr_os_thread_equal(LLThread::sMainThreadID, apr_os_thread_current()); }
public: public:
// PAUSE / RESUME functionality. See source code for important usage notes. // PAUSE / RESUME functionality. See source code for important usage notes.
@@ -122,6 +130,9 @@ public:
// Return thread-local data for the current thread. // Return thread-local data for the current thread.
static LLThreadLocalData& tldata(void) { return LLThreadLocalData::tldata(); } static LLThreadLocalData& tldata(void) { return LLThreadLocalData::tldata(); }
// Called once, from LLThreadLocalData::init().
static void set_main_thread_id(void);
U32 getID() const { return mID; } U32 getID() const { return mID; }
private: private:
@@ -165,6 +176,13 @@ protected:
// mRunCondition->unlock(); // mRunCondition->unlock();
}; };
#ifdef SHOW_ASSERT
LL_COMMON_API inline bool is_main_thread(void) { return LLThread::is_main_thread(); }
#define ASSERT_SINGLE_THREAD do { static apr_os_thread_t first_thread_id = apr_os_thread_current(); llassert(apr_os_thread_equal(first_thread_id, apr_os_thread_current())); } while(0)
#else
#define ASSERT_SINGLE_THREAD do { } while(0)
#endif
//============================================================================ //============================================================================
#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO) #define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO)
@@ -206,6 +224,11 @@ protected:
apr_thread_mutex_t* mAPRMutexp; apr_thread_mutex_t* mAPRMutexp;
mutable U32 mCount; mutable U32 mCount;
mutable U32 mLockingThread; mutable U32 mLockingThread;
private:
// Disallow copy construction and assignment.
LLMutexBase(LLMutexBase const&);
LLMutexBase& operator=(LLMutexBase const&);
}; };
class LL_COMMON_API LLMutex : public LLMutexBase class LL_COMMON_API LLMutex : public LLMutexBase
@@ -225,10 +248,6 @@ public:
protected: protected:
LLAPRPool mPool; LLAPRPool mPool;
private:
// Disable copy construction, as si teh bomb!!! -SG
LLMutex(const LLMutex&);
LLMutex& operator=(const LLMutex&);
}; };
#if APR_HAS_THREADS #if APR_HAS_THREADS

View File

@@ -34,7 +34,7 @@
#define LL_LLVERSIONVIEWER_H #define LL_LLVERSIONVIEWER_H
const S32 LL_VERSION_MAJOR = 1; const S32 LL_VERSION_MAJOR = 1;
const S32 LL_VERSION_MINOR = 6; const S32 LL_VERSION_MINOR = 7;
const S32 LL_VERSION_PATCH = 0; const S32 LL_VERSION_PATCH = 0;
const S32 LL_VERSION_BUILD = ${vBUILD}; const S32 LL_VERSION_BUILD = ${vBUILD};

View File

@@ -226,7 +226,8 @@ LLWorkerClass::~LLWorkerClass()
llerrs << "LLWorkerClass destroyed with stale work handle" << llendl; llerrs << "LLWorkerClass destroyed with stale work handle" << llendl;
} }
if (workreq->getStatus() != LLWorkerThread::STATUS_ABORTED && if (workreq->getStatus() != LLWorkerThread::STATUS_ABORTED &&
workreq->getStatus() != LLWorkerThread::STATUS_COMPLETE) workreq->getStatus() != LLWorkerThread::STATUS_COMPLETE &&
!(workreq->getFlags() & LLWorkerThread::FLAG_LOCKED))
{ {
llerrs << "LLWorkerClass destroyed with active worker! Worker Status: " << workreq->getStatus() << llendl; llerrs << "LLWorkerClass destroyed with active worker! Worker Status: " << workreq->getStatus() << llendl;
} }
@@ -350,14 +351,10 @@ bool LLWorkerClass::checkWork(bool aborting)
} }
LLQueuedThread::status_t status = workreq->getStatus(); LLQueuedThread::status_t status = workreq->getStatus();
if (status == LLWorkerThread::STATUS_ABORTED) if (status == LLWorkerThread::STATUS_COMPLETE || status == LLWorkerThread::STATUS_ABORTED)
{ {
complete = true; complete = !(workreq->getFlags() & LLWorkerThread::FLAG_LOCKED);
abort = true; abort = status == LLWorkerThread::STATUS_ABORTED;
}
else if (status == LLWorkerThread::STATUS_COMPLETE)
{
complete = true;
} }
else else
{ {

View File

@@ -371,6 +371,9 @@ void LLCrashLogger::updateApplication(const std::string& message)
bool LLCrashLogger::init() bool LLCrashLogger::init()
{ {
// Initialize curl
AICurlInterface::initCurl();
// We assume that all the logs we're looking for reside on the current drive // We assume that all the logs we're looking for reside on the current drive
gDirUtilp->initAppDirs("SecondLife"); gDirUtilp->initAppDirs("SecondLife");

View File

@@ -29,7 +29,8 @@ set(llmessage_SOURCE_FILES
llchainio.cpp llchainio.cpp
llcircuit.cpp llcircuit.cpp
llclassifiedflags.cpp llclassifiedflags.cpp
llcurl.cpp aicurl.cpp
aicurlthread.cpp
lldatapacker.cpp lldatapacker.cpp
lldispatcher.cpp lldispatcher.cpp
llfiltersd2xmlrpc.cpp llfiltersd2xmlrpc.cpp
@@ -66,8 +67,6 @@ set(llmessage_SOURCE_FILES
llsdmessage.cpp llsdmessage.cpp
llsdmessagebuilder.cpp llsdmessagebuilder.cpp
llsdmessagereader.cpp llsdmessagereader.cpp
llsdrpcclient.cpp
llsdrpcserver.cpp
llservicebuilder.cpp llservicebuilder.cpp
llservice.cpp llservice.cpp
llstoredmessage.cpp llstoredmessage.cpp
@@ -117,6 +116,9 @@ set(llmessage_HEADER_FILES
llcircuit.h llcircuit.h
llclassifiedflags.h llclassifiedflags.h
llcurl.h llcurl.h
aicurl.h
aicurlprivate.h
aicurlthread.h
lldatapacker.h lldatapacker.h
lldbstrings.h lldbstrings.h
lldispatcher.h lldispatcher.h
@@ -164,8 +166,6 @@ set(llmessage_HEADER_FILES
llsdmessage.h llsdmessage.h
llsdmessagebuilder.h llsdmessagebuilder.h
llsdmessagereader.h llsdmessagereader.h
llsdrpcclient.h
llsdrpcserver.h
llservice.h llservice.h
llservicebuilder.h llservicebuilder.h
llstoredmessage.h llstoredmessage.h

1363
indra/llmessage/aicurl.cpp Normal file

File diff suppressed because it is too large Load Diff

322
indra/llmessage/aicurl.h Normal file
View File

@@ -0,0 +1,322 @@
/**
* @file aicurl.h
* @brief Thread safe wrapper for libcurl.
*
* Copyright (c) 2012, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 17/03/2012
* Initial version, written by Aleric Inglewood @ SL
*/
#ifndef AICURL_H
#define AICURL_H
#include <string>
#include <vector>
#include <set>
#include <stdexcept>
#include <boost/intrusive_ptr.hpp>
#include <boost/utility.hpp>
#include <curl/curl.h> // CURL, CURLM, CURLMcode, CURLoption, curl_*_callback
// Make sure we don't use this option: it is not thread-safe.
#undef CURLOPT_DNS_USE_GLOBAL_CACHE
#include "stdtypes.h" // U32
#include "lliopipe.h" // LLIOPipe::buffer_ptr_t
#include "llatomic.h" // LLAtomicU32
#include "aithreadsafe.h"
class LLSD;
//-----------------------------------------------------------------------------
// Exceptions.
//
// A general curl exception.
//
class AICurlError : public std::runtime_error {
public:
AICurlError(std::string const& message) : std::runtime_error(message) { }
};
class AICurlNoEasyHandle : public AICurlError {
public:
AICurlNoEasyHandle(std::string const& message) : AICurlError(message) { }
};
class AICurlNoMultiHandle : public AICurlError {
public:
AICurlNoMultiHandle(std::string const& message) : AICurlError(message) { }
};
// End Exceptions.
//-----------------------------------------------------------------------------
// Things defined in this namespace are called from elsewhere in the viewer code.
namespace AICurlInterface {
// Output parameter of AICurlPrivate::CurlEasyRequest::getResult.
// Only used by LLXMLRPCTransaction::Impl.
struct TransferInfo {
TransferInfo() : mSizeDownload(0.0), mTotalTime(0.0), mSpeedDownload(0.0) { }
F64 mSizeDownload;
F64 mTotalTime;
F64 mSpeedDownload;
};
//-----------------------------------------------------------------------------
// Global functions.
// Called once at start of application (from newview/llappviewer.cpp by main thread (before threads are created)),
// with main purpose to initialize curl.
void initCurl(void (*)(void) = NULL);
// Called once at start of application (from LLAppViewer::initThreads), starts AICurlThread.
void startCurlThread(void);
// Called once at end of application (from newview/llappviewer.cpp by main thread),
// with purpose to stop curl threads, free curl resources and deinitialize curl.
void cleanupCurl(void);
// Called from indra/llmessage/llurlrequest.cpp to print debug output regarding
// an error code returned by EasyRequest::getResult.
// Just returns curl_easy_strerror(errorcode).
std::string strerror(CURLcode errorcode);
// Called from indra/newview/llfloaterabout.cpp for the About floater, and
// from newview/llappviewer.cpp in behalf of debug output.
// Just returns curl_version().
std::string getVersionString(void);
// Called from newview/llappviewer.cpp (and llcrashlogger/llcrashlogger.cpp) to set
// the Certificate Authority file used to verify HTTPS certs.
void setCAFile(std::string const& file);
// Not called from anywhere.
// Can be used to set the path to the Certificate Authority file.
void setCAPath(std::string const& file);
//-----------------------------------------------------------------------------
// Global classes.
// Responder - base class for Request::get* and Request::post API.
//
// The life cycle of classes derived from this class is as follows:
// They are allocated with new on the line where get(), getByteRange() or post() is called,
// and the pointer to the allocated object is then put in a reference counting ResponderPtr.
// This ResponderPtr is passed to CurlResponderBuffer::prepRequest which stores it in its
// member mResponder. Hence, the life time of a Responder is never longer than its
// associated CurlResponderBuffer, however, if everything works correctly, then normally a
// responder is deleted in CurlResponderBuffer::removed_from_multi_handle by setting
// mReponder to NULL.
//
// Note that the lifetime of CurlResponderBuffer is (a bit) shorter than the associated
// CurlEasyRequest (because of the order of base classes of ThreadSafeBufferedCurlEasyRequest)
// and the callbacks, as set by prepRequest, only use those two.
// A callback locks the CurlEasyRequest before actually making the callback, and the
// destruction of CurlResponderBuffer also first locks the CurlEasyRequest, and then revokes
// the callbacks. This assures that a Responder is never used when the objects it uses are
// destructed. Also, if any of those are destructed then the Responder is automatically
// destructed too.
//
class Responder {
protected:
Responder(void);
virtual ~Responder();
private:
// Associated URL, used for debug output.
std::string mURL;
public:
// Called to set the URL of the current request for this Responder,
// used only when printing debug output regarding activity of the Responder.
void setURL(std::string const& url);
public:
// Called from LLHTTPClientURLAdaptor::complete():
// Derived classes can override this to get the HTML header that was received, when the message is completed.
// The default does nothing.
virtual void completedHeader(U32 status, std::string const& reason, LLSD const& content);
// Derived classes can override this to get the raw data of the body of the HTML message that was received.
// The default is to interpret the content as LLSD and call completed().
virtual void completedRaw(U32 status, std::string const& reason, LLChannelDescriptors const& channels, LLIOPipe::buffer_ptr_t const& buffer);
// Called from LLHTTPClient request calls, if an error occurs even before we can call one of the above.
// It calls completed() with a fake status U32_MAX, as that is what some derived clients expect (bad design).
// This means that if a derived class overrides completedRaw() it now STILL has to override completed() to catch this error.
void fatalError(std::string const& reason);
// A derived class should return true if curl should follow redirections.
// The default is not to follow redirections.
virtual bool followRedir(void) { return false; }
protected:
// ... or, derived classes can override this to get the LLSD content when the message is completed.
// The default is to call result() (or errorWithContent() in case of a HTML status indicating an error).
virtual void completed(U32 status, std::string const& reason, LLSD const& content);
// ... or, derived classes can override this to received the content of a body upon success.
// The default does nothing.
virtual void result(LLSD const& content);
// Derived classes can override this to get informed when a bad HTML status code is received.
// The default calls error().
virtual void errorWithContent(U32 status, std::string const& reason, LLSD const& content);
// ... or, derived classes can override this to get informed when a bad HTML statis code is received.
// The default prints the error to llinfos.
virtual void error(U32 status, std::string const& reason);
public:
// Called from LLSDMessage::ResponderAdapter::listener.
// LLSDMessage::ResponderAdapter is a hack, showing among others by fact that these functions need to be public.
void pubErrorWithContent(U32 status, std::string const& reason, LLSD const& content) { errorWithContent(status, reason, content); }
void pubResult(LLSD const& content) { result(content); }
private:
// Used by ResponderPtr. Object is deleted when reference count reaches zero.
LLAtomicU32 mReferenceCount;
friend void intrusive_ptr_add_ref(Responder* p); // Called by boost::intrusive_ptr when a new copy of a boost::intrusive_ptr<Responder> is made.
friend void intrusive_ptr_release(Responder* p); // Called by boost::intrusive_ptr when a boost::intrusive_ptr<Responder> is destroyed.
// This function must delete the Responder object when the reference count reaches zero.
};
// A Responder is passed around as ResponderPtr, which causes it to automatically
// destruct when there are no pointers left pointing to it.
typedef boost::intrusive_ptr<Responder> ResponderPtr;
} // namespace AICurlInterface
// Forward declaration (see aicurlprivate.h).
namespace AICurlPrivate {
class CurlEasyRequest;
} // namespace AICurlPrivate
// Define access types (_crat = Const Read Access Type, _rat = Read Access Type, _wat = Write Access Type).
// Typical usage is:
// AICurlEasyRequest h1; // Create easy handle.
// AICurlEasyRequest h2(h1); // Make lightweight copies.
// AICurlEasyRequest_wat h2_w(*h2); // Lock and obtain write access to the easy handle.
// Use *h2_w, which is a reference to the locked CurlEasyRequest instance.
// Note: As it is not allowed to use curl easy handles in any way concurrently,
// read access would at most give access to a CURL const*, which will turn out
// to be completely useless; therefore it is sufficient and efficient to use
// an AIThreadSafeSimple and it's unlikely that AICurlEasyRequest_rat will be used.
typedef AIAccessConst<AICurlPrivate::CurlEasyRequest> AICurlEasyRequest_rat;
typedef AIAccess<AICurlPrivate::CurlEasyRequest> AICurlEasyRequest_wat;
// Events generated by AICurlPrivate::CurlEasyHandle.
struct AICurlEasyHandleEvents {
// Events.
virtual void added_to_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w) = 0;
virtual void finished(AICurlEasyRequest_wat& curl_easy_request_w) = 0;
virtual void removed_from_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w) = 0;
// Avoid compiler warning.
virtual ~AICurlEasyHandleEvents() { }
};
#include "aicurlprivate.h"
// AICurlPrivate::CurlEasyRequestPtr, a boost::intrusive_ptr, is no more threadsafe than a
// builtin type, but wrapping it in AIThreadSafe is obviously not going to help here.
// Therefore we use the following trick: we wrap CurlEasyRequestPtr too, and only allow
// read accesses on it.
// AICurlEasyRequest: a thread safe, reference counting, auto-cleaning curl easy handle.
class AICurlEasyRequest {
public:
// Initial construction is allowed (thread-safe).
// Note: If ThreadSafeCurlEasyRequest() throws then the memory allocated is still freed.
// 'new' never returned however and neither the constructor nor destructor of mCurlEasyRequest is called in this case.
// This might throw AICurlNoEasyHandle.
AICurlEasyRequest(bool buffered) :
mCurlEasyRequest(buffered ? new AICurlPrivate::ThreadSafeBufferedCurlEasyRequest : new AICurlPrivate::ThreadSafeCurlEasyRequest) { }
AICurlEasyRequest(AICurlEasyRequest const& orig) : mCurlEasyRequest(orig.mCurlEasyRequest) { }
// For the rest, only allow read operations.
AIThreadSafeSimple<AICurlPrivate::CurlEasyRequest>& operator*(void) const { llassert(mCurlEasyRequest.get()); return *mCurlEasyRequest; }
AIThreadSafeSimple<AICurlPrivate::CurlEasyRequest>* operator->(void) const { llassert(mCurlEasyRequest.get()); return mCurlEasyRequest.get(); }
AIThreadSafeSimple<AICurlPrivate::CurlEasyRequest>* get(void) const { return mCurlEasyRequest.get(); }
// Returns true if this object points to the same CurlEasyRequest object.
bool operator==(AICurlEasyRequest const& cer) const { return mCurlEasyRequest == cer.mCurlEasyRequest; }
// Returns true if this object points to a different CurlEasyRequest object.
bool operator!=(AICurlEasyRequest const& cer) const { return mCurlEasyRequest != cer.mCurlEasyRequest; }
// Queue this request for insertion in the multi session.
void addRequest(void);
// Queue a command to remove this request from the multi session (or cancel a queued command to add it).
void removeRequest(void);
// Returns true when this AICurlEasyRequest wraps a AICurlPrivate::ThreadSafeBufferedCurlEasyRequest.
bool isBuffered(void) const { return mCurlEasyRequest->isBuffered(); }
private:
// The actual pointer to the ThreadSafeCurlEasyRequest instance.
AICurlPrivate::CurlEasyRequestPtr mCurlEasyRequest;
private:
// Assignment would not be thread-safe; we may create this object and read from it.
// Note: Destruction is implicitly assumed thread-safe, as it would be a logic error to
// destruct it while another thread still needs it, concurrent or not.
AICurlEasyRequest& operator=(AICurlEasyRequest const&) { return *this; }
public:
// The more exotic member functions of this class, to deal with passing this class
// as CURLOPT_PRIVATE pointer to a curl handle and afterwards restore it.
// For "internal use" only; don't use things from AICurlPrivate yourself.
// It's thread-safe to give read access the underlaying boost::intrusive_ptr.
// It's not OK to then call get() on that and store the AICurlPrivate::ThreadSafeCurlEasyRequest* separately.
AICurlPrivate::CurlEasyRequestPtr const& get_ptr(void) const { return mCurlEasyRequest; }
// If we have a correct (with regard to reference counting) AICurlPrivate::CurlEasyRequestPtr,
// then it's OK to construct a AICurlEasyRequest from it.
// Note that the external AICurlPrivate::CurlEasyRequestPtr needs its own locking, because
// it's not thread-safe in itself.
AICurlEasyRequest(AICurlPrivate::CurlEasyRequestPtr const& ptr) : mCurlEasyRequest(ptr) { }
// This one is obviously dangerous. It's for use only in MultiHandle::check_run_count.
// See also the long comment in CurlEasyRequest::finalizeRequest with regard to CURLOPT_PRIVATE.
explicit AICurlEasyRequest(AICurlPrivate::ThreadSafeCurlEasyRequest* ptr) : mCurlEasyRequest(ptr) { }
};
// Write Access Type for the buffer.
struct AICurlResponderBuffer_wat : public AIAccess<AICurlPrivate::CurlResponderBuffer> {
explicit AICurlResponderBuffer_wat(AICurlPrivate::ThreadSafeBufferedCurlEasyRequest& lockobj) :
AIAccess<AICurlPrivate::CurlResponderBuffer>(lockobj) { }
AICurlResponderBuffer_wat(AIThreadSafeSimple<AICurlPrivate::CurlEasyRequest>& lockobj) :
AIAccess<AICurlPrivate::CurlResponderBuffer>(static_cast<AICurlPrivate::ThreadSafeBufferedCurlEasyRequest&>(lockobj)) { }
};
#define AICurlPrivate DONTUSE_AICurlPrivate
#endif

View File

@@ -0,0 +1,414 @@
/**
* @file aicurlprivate.h
* @brief Thread safe wrapper for libcurl.
*
* Copyright (c) 2012, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 28/04/2012
* Initial version, written by Aleric Inglewood @ SL
*/
#ifndef AICURLPRIVATE_H
#define AICURLPRIVATE_H
#include <sstream>
#include "llatomic.h"
namespace AICurlPrivate {
namespace curlthread { class MultiHandle; }
struct Stats {
static LLAtomicU32 easy_calls;
static LLAtomicU32 easy_errors;
static LLAtomicU32 easy_init_calls;
static LLAtomicU32 easy_init_errors;
static LLAtomicU32 easy_cleanup_calls;
static LLAtomicU32 multi_calls;
static LLAtomicU32 multi_errors;
static void print(void);
};
void handle_multi_error(CURLMcode code);
inline CURLMcode check_multi_code(CURLMcode code) { Stats::multi_calls++; if (code != CURLM_OK) handle_multi_error(code); return code; }
bool curlThreadIsRunning(void);
void wakeUpCurlThread(void);
void stopCurlThread(void);
class ThreadSafeCurlEasyRequest;
class ThreadSafeBufferedCurlEasyRequest;
// This class wraps CURL*'s.
// It guarantees that a pointer is cleaned up when no longer needed, as required by libcurl.
class CurlEasyHandle : public boost::noncopyable, protected AICurlEasyHandleEvents {
public:
CurlEasyHandle(void);
~CurlEasyHandle();
private:
// Disallow assignment.
CurlEasyHandle& operator=(CurlEasyHandle const*);
public:
// Reset all options of a libcurl session handle.
void reset(void) { llassert(!mActiveMultiHandle); curl_easy_reset(mEasyHandle); }
// Set options for a curl easy handle.
template<typename BUILTIN>
CURLcode setopt(CURLoption option, BUILTIN parameter);
// Clone a libcurl session handle using all the options previously set.
//CurlEasyHandle(CurlEasyHandle const& orig);
// URL encode/decode the given string.
char* escape(char* url, int length);
char* unescape(char* url, int inlength , int* outlength);
// Extract information from a curl handle.
CURLcode getinfo(CURLINFO info, void* data);
#if _WIN64 || __x86_64__ || __ppc64__
// Overload for integer types that are too small (libcurl demands a long).
CURLcode getinfo(CURLINFO info, S32* data) { long ldata; CURLcode res = getinfo(info, &ldata); *data = static_cast<S32>(ldata); return res; }
CURLcode getinfo(CURLINFO info, U32* data) { long ldata; CURLcode res = getinfo(info, &ldata); *data = static_cast<U32>(ldata); return res; }
#endif
// Perform a file transfer (blocking).
CURLcode perform(void);
// Pause and unpause a connection.
CURLcode pause(int bitmask);
// Called when a request is queued for removal. In that case a race between the actual removal
// and revoking of the callbacks is harmless (and happens for the raw non-statemachine version).
void remove_queued(void) { mQueuedForRemoval = true; }
// In case it's added after being removed.
void add_queued(void) { mQueuedForRemoval = false; }
private:
CURL* mEasyHandle;
CURLM* mActiveMultiHandle;
char* mErrorBuffer;
bool mQueuedForRemoval; // Set if the easy handle is (probably) added to the multi handle, but is queued for removal.
#ifdef SHOW_ASSERT
public:
bool mRemovedPerCommand; // Set if mActiveMultiHandle was reset as per command from the main thread.
#endif
private:
// This should only be called from MultiHandle; add/remove an easy handle to/from a multi handle.
friend class curlthread::MultiHandle;
CURLMcode add_handle_to_multi(AICurlEasyRequest_wat& curl_easy_request_w, CURLM* multi_handle);
CURLMcode remove_handle_from_multi(AICurlEasyRequest_wat& curl_easy_request_w, CURLM* multi_handle);
public:
// Returns true if this easy handle was added to a curl multi handle.
bool active(void) const { return mActiveMultiHandle; }
// If there was an error code as result, then this returns a human readable error string.
// Only valid when setErrorBuffer was called and the curl_easy function returned an error.
std::string getErrorString(void) const { return mErrorBuffer ? mErrorBuffer : "(null)"; }
// Returns true when it is expected that the parent will revoke callbacks before the curl
// easy handle is removed from the multi handle; that usually happens when an external
// error demands termination of the request (ie, an expiration).
bool no_warning(void) const { return mQueuedForRemoval || LLApp::isExiting(); }
// Used for debugging purposes.
bool operator==(CURL* easy_handle) const { return mEasyHandle == easy_handle; }
private:
// Call this prior to every curl_easy function whose return value is passed to check_easy_code.
void setErrorBuffer(void);
static void handle_easy_error(CURLcode code);
// Always first call setErrorBuffer()!
static inline CURLcode check_easy_code(CURLcode code)
{
Stats::easy_calls++;
if (code != CURLE_OK)
handle_easy_error(code);
return code;
}
protected:
// Return the underlying curl easy handle.
CURL* getEasyHandle(void) const { return mEasyHandle; }
private:
// Return, and possibly create, the curl (easy) error buffer used by the current thread.
static char* getTLErrorBuffer(void);
};
template<typename BUILTIN>
CURLcode CurlEasyHandle::setopt(CURLoption option, BUILTIN parameter)
{
llassert(!mActiveMultiHandle);
setErrorBuffer();
return check_easy_code(curl_easy_setopt(mEasyHandle, option, parameter));
}
// CurlEasyRequest adds a slightly more powerful interface that can be used
// to set the options on a curl easy handle.
//
// Calling sendRequest() will then connect to the given URL and perform
// the data exchange. If an error occurs related to this handle, it can
// be read by calling getErrorString().
//
// Note that the life cycle of a CurlEasyRequest is controlled by AICurlEasyRequest:
// a CurlEasyRequest is only ever created as base class of a ThreadSafeCurlEasyRequest,
// which is only created by creating a AICurlEasyRequest. When the last copy of such
// AICurlEasyRequest is deleted, then also the ThreadSafeCurlEasyRequest is deleted
// and the CurlEasyRequest destructed.
class CurlEasyRequest : public CurlEasyHandle {
public:
void setoptString(CURLoption option, std::string const& value);
void setPost(char const* postdata, S32 size);
void addHeader(char const* str);
private:
// Callback stubs.
static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
static size_t writeCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
static size_t readCallback(char* ptr, size_t size, size_t nmemb, void* userdata);
static CURLcode SSLCtxCallback(CURL* curl, void* sslctx, void* userdata);
curl_write_callback mHeaderCallback;
void* mHeaderCallbackUserData;
curl_write_callback mWriteCallback;
void* mWriteCallbackUserData;
curl_read_callback mReadCallback;
void* mReadCallbackUserData;
curl_ssl_ctx_callback mSSLCtxCallback;
void* mSSLCtxCallbackUserData;
public:
void setHeaderCallback(curl_write_callback callback, void* userdata);
void setWriteCallback(curl_write_callback callback, void* userdata);
void setReadCallback(curl_read_callback callback, void* userdata);
void setSSLCtxCallback(curl_ssl_ctx_callback callback, void* userdata);
// Call this if the set callbacks are about to be invalidated.
void revokeCallbacks(void);
// Reset everything to the state it was in when this object was just created.
void resetState(void);
private:
// Called from applyDefaultOptions.
void applyProxySettings(void);
public:
// Set default options that we want applied to all curl easy handles.
void applyDefaultOptions(void);
// Prepare the request for adding it to a multi session, or calling perform.
// This actually adds the headers that were collected with addHeader.
void finalizeRequest(std::string const& url);
// Store result code that is returned by getResult.
void store_result(CURLcode result) { mResult = result; }
// Called when the curl easy handle is done.
void done(AICurlEasyRequest_wat& curl_easy_request_w) { finished(curl_easy_request_w); }
// Fill info with the transfer info.
void getTransferInfo(AICurlInterface::TransferInfo* info);
// If result != CURLE_FAILED_INIT then also info was filled.
void getResult(CURLcode* result, AICurlInterface::TransferInfo* info = NULL);
private:
curl_slist* mHeaders;
bool mRequestFinalized;
AICurlEasyHandleEvents* mEventsTarget;
CURLcode mResult;
private:
// This class may only be created by constructing a ThreadSafeCurlEasyRequest.
friend class ThreadSafeCurlEasyRequest;
// Throws AICurlNoEasyHandle.
CurlEasyRequest(void) :
mHeaders(NULL), mRequestFinalized(false), mEventsTarget(NULL), mResult(CURLE_FAILED_INIT)
{ applyDefaultOptions(); }
public:
~CurlEasyRequest();
public:
// Post-initialization, set the parent to pass the events to.
void send_events_to(AICurlEasyHandleEvents* target) { mEventsTarget = target; }
// For debugging purposes
bool is_finalized(void) const { return mRequestFinalized; }
// Return pointer to the ThreadSafe (wrapped) version of this object.
ThreadSafeCurlEasyRequest* get_lockobj(void);
protected:
// Pass events to parent.
/*virtual*/ void added_to_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w);
/*virtual*/ void finished(AICurlEasyRequest_wat& curl_easy_request_w);
/*virtual*/ void removed_from_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w);
};
// Buffers used by the AICurlInterface::Request API.
// Curl callbacks write into and read from these buffers.
// The interface with the rest of the code is through AICurlInterface::Responder.
//
// The lifetime of a CurlResponderBuffer is slightly shorter than its
// associated CurlEasyRequest; this class can only be created as base class
// of ThreadSafeBufferedCurlEasyRequest, and is therefore constructed after
// the construction of the associated CurlEasyRequest and destructed before it.
// Hence, it's safe to use get_lockobj() and through that access the CurlEasyRequest
// object at all times.
//
// A CurlResponderBuffer is thus created when a ThreadSafeBufferedCurlEasyRequest
// is created which only happens by creating a AICurlEasyRequest(true) instance,
// and when the last AICurlEasyRequest is deleted, then the ThreadSafeBufferedCurlEasyRequest
// is deleted and the CurlResponderBuffer destructed.
class CurlResponderBuffer : protected AICurlEasyHandleEvents {
public:
void resetState(AICurlEasyRequest_wat& curl_easy_request_w);
void prepRequest(AICurlEasyRequest_wat& buffered_curl_easy_request_w, std::vector<std::string> const& headers, AICurlInterface::ResponderPtr responder, S32 time_out = 0, bool post = false);
std::stringstream& getInput() { return mInput; }
std::stringstream& getHeaderOutput() { return mHeaderOutput; }
LLIOPipe::buffer_ptr_t& getOutput() { return mOutput; }
// Called if libcurl doesn't deliver within CurlRequestTimeOut seconds.
void timed_out(void);
// Called after removed_from_multi_handle was called.
void processOutput(AICurlEasyRequest_wat& curl_easy_request_w);
protected:
/*virtual*/ void added_to_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w);
/*virtual*/ void finished(AICurlEasyRequest_wat& curl_easy_request_w);
/*virtual*/ void removed_from_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w);
private:
std::stringstream mInput;
std::stringstream mHeaderOutput;
LLIOPipe::buffer_ptr_t mOutput;
AICurlInterface::ResponderPtr mResponder;
public:
static LLChannelDescriptors const sChannels; // Channel object for mOutput: we ONLY use channel 0, so this can be a constant.
private:
// This class may only be created by constructing a ThreadSafeBufferedCurlEasyRequest.
friend class ThreadSafeBufferedCurlEasyRequest;
CurlResponderBuffer(void);
public:
~CurlResponderBuffer();
private:
static size_t curlWriteCallback(char* data, size_t size, size_t nmemb, void* user_data);
static size_t curlReadCallback(char* data, size_t size, size_t nmemb, void* user_data);
static size_t curlHeaderCallback(char* data, size_t size, size_t nmemb, void* user_data);
public:
// Return pointer to the ThreadSafe (wrapped) version of this object.
ThreadSafeBufferedCurlEasyRequest* get_lockobj(void);
// Return true when prepRequest was already called and the object has not been
// invalidated as a result of calling timed_out().
bool isValid(void) const { return mResponder; }
};
// This class wraps CurlEasyRequest for thread-safety and adds a reference counter so we can
// copy it around cheaply and it gets destructed automatically when the last instance is deleted.
// It guarantees that the CURL* handle is never used concurrently, which is not allowed by libcurl.
// As AIThreadSafeSimpleDC contains a mutex, it cannot be copied. Therefore we need a reference counter for this object.
class ThreadSafeCurlEasyRequest : public AIThreadSafeSimple<CurlEasyRequest> {
public:
// Throws AICurlNoEasyHandle.
ThreadSafeCurlEasyRequest(void) : mReferenceCount(0)
{ new (ptr()) CurlEasyRequest;
Dout(dc::curl, "Creating ThreadSafeCurlEasyRequest with this = " << (void*)this); }
virtual ~ThreadSafeCurlEasyRequest()
{ Dout(dc::curl, "Destructing ThreadSafeCurlEasyRequest with this = " << (void*)this); }
// Returns true if this is a base class of ThreadSafeBufferedCurlEasyRequest.
virtual bool isBuffered(void) const { return false; }
private:
LLAtomicU32 mReferenceCount;
friend void intrusive_ptr_add_ref(ThreadSafeCurlEasyRequest* p); // Called by boost::intrusive_ptr when a new copy of a boost::intrusive_ptr<ThreadSafeCurlEasyRequest> is made.
friend void intrusive_ptr_release(ThreadSafeCurlEasyRequest* p); // Called by boost::intrusive_ptr when a boost::intrusive_ptr<ThreadSafeCurlEasyRequest> is destroyed.
};
// Same as the above but adds a CurlResponderBuffer. The latter has its own locking in order to
// allow casting the underlying CurlEasyRequest to ThreadSafeCurlEasyRequest, independent of
// what class it is part of: ThreadSafeCurlEasyRequest or ThreadSafeBufferedCurlEasyRequest.
// The virtual destructor of ThreadSafeCurlEasyRequest allows to treat each easy handle transparently
// as a ThreadSafeCurlEasyRequest object, or optionally dynamic_cast it to a ThreadSafeBufferedCurlEasyRequest.
// Note: the order of these base classes is important: AIThreadSafeSimple<CurlResponderBuffer> is now
// destructed before ThreadSafeCurlEasyRequest is.
class ThreadSafeBufferedCurlEasyRequest : public ThreadSafeCurlEasyRequest, public AIThreadSafeSimple<CurlResponderBuffer> {
public:
// Throws AICurlNoEasyHandle.
ThreadSafeBufferedCurlEasyRequest(void) { new (AIThreadSafeSimple<CurlResponderBuffer>::ptr()) CurlResponderBuffer; }
/*virtual*/ bool isBuffered(void) const { return true; }
};
// The curl easy request type wrapped in a reference counting pointer.
typedef boost::intrusive_ptr<AICurlPrivate::ThreadSafeCurlEasyRequest> CurlEasyRequestPtr;
// This class wraps CURLM*'s.
// It guarantees that a pointer is cleaned up when no longer needed, as required by libcurl.
class CurlMultiHandle : public boost::noncopyable {
public:
CurlMultiHandle(void);
~CurlMultiHandle();
private:
// Disallow assignment.
CurlMultiHandle& operator=(CurlMultiHandle const*);
private:
static LLAtomicU32 sTotalMultiHandles;
protected:
CURLM* mMultiHandle;
public:
// Set options for a curl multi handle.
template<typename BUILTIN>
CURLMcode setopt(CURLMoption option, BUILTIN parameter);
// Returns total number of existing CURLM* handles (excluding ones created outside this class).
static U32 getTotalMultiHandles(void) { return sTotalMultiHandles; }
};
template<typename BUILTIN>
CURLMcode CurlMultiHandle::setopt(CURLMoption option, BUILTIN parameter)
{
return check_multi_code(curl_multi_setopt(mMultiHandle, option, parameter));
}
} // namespace AICurlPrivate
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,128 @@
/**
* @file aicurlthread.h
* @brief Thread safe wrapper for libcurl.
*
* Copyright (c) 2012, Aleric Inglewood.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 28/04/2012
* Initial version, written by Aleric Inglewood @ SL
*/
#ifndef AICURLTHREAD_H
#define AICURLTHREAD_H
#include "aicurl.h"
#include <vector>
#undef AICurlPrivate
namespace AICurlPrivate {
namespace curlthread {
class PollSet;
// For ordering a std::set with AICurlEasyRequest objects.
struct AICurlEasyRequestCompare {
bool operator()(AICurlEasyRequest const& h1, AICurlEasyRequest const& h2) { return h1.get() < h2.get(); }
};
//-----------------------------------------------------------------------------
// MultiHandle
// This class adds member functions that will only be called from the AICurlThread thread.
// This class guarantees that all added easy handles will be removed from the multi handle
// before the multi handle is cleaned up, as is required by libcurl.
class MultiHandle : public CurlMultiHandle
{
public:
MultiHandle(void);
~MultiHandle();
// Add/remove an easy handle to/from a multi session.
CURLMcode add_easy_request(AICurlEasyRequest const& easy_request);
CURLMcode remove_easy_request(AICurlEasyRequest const& easy_request, bool as_per_command = false);
// Reads/writes available data from a particular socket (non-blocking).
CURLMcode socket_action(curl_socket_t sockfd, int ev_bitmask);
// Set data to association with an internal socket.
CURLMcode assign(curl_socket_t sockfd, void* sockptr);
// Read multi stack informationals.
CURLMsg const* info_read(int* msgs_in_queue) const;
private:
typedef std::set<AICurlEasyRequest, AICurlEasyRequestCompare> addedEasyRequests_type;
addedEasyRequests_type mAddedEasyRequests;
bool mHandleAddedOrRemoved; // Set when an easy handle was added or removed, reset in check_run_count().
int mPrevRunningHandles; // The last value of mRunningHandles that check_run_count() was called with.
int mRunningHandles; // The last value returned by curl_multi_socket_action.
long mTimeOut; // The last time out in ms as set by the callback CURLMOPT_TIMERFUNCTION.
private:
static int socket_callback(CURL* easy, curl_socket_t s, int action, void* userp, void* socketp);
static int timer_callback(CURLM* multi, long timeout_ms, void* userp);
public:
// Returns the number of active easy handles as reported by the last call to curl_multi_socket_action.
int getRunningHandles(void) const { return mRunningHandles; }
// Returns how long to wait for socket action before calling socket_action(CURL_SOCKET_TIMEOUT, 0), in ms.
int getTimeOut(void) const { return mTimeOut; }
// This is called before sleeping, after calling (one or more times) socket_action.
void check_run_count(void);
public:
//-----------------------------------------------------------------------------
// Curl socket administration:
PollSet* mReadPollSet;
PollSet* mWritePollSet;
};
} // namespace curlthread
} // namespace AICurlPrivate
// Thread safe, noncopyable curl multi handle.
// This class wraps MultiHandle for thread-safety.
// AIThreadSafeSingleThreadDC cannot be copied, but that is OK as we don't need that (or want that);
// this class provides a thread-local singleton (exactly one instance per thread), and because it
// can't be copied, that guarantees that the CURLM* handle is never used concurrently, which is
// not allowed by libcurl.
class AICurlMultiHandle : public AIThreadSafeSingleThreadDC<AICurlPrivate::curlthread::MultiHandle>, public LLThreadLocalDataMember {
public:
static AICurlMultiHandle& getInstance(void);
static void destroyInstance(void);
private:
// Use getInstance().
AICurlMultiHandle(void) { }
};
typedef AISTAccessConst<AICurlPrivate::curlthread::MultiHandle> AICurlMultiHandle_rat;
typedef AISTAccess<AICurlPrivate::curlthread::MultiHandle> AICurlMultiHandle_wat;
#define AICurlPrivate DONTUSE_AICurlPrivate
#endif

View File

@@ -28,7 +28,6 @@
#include "linden_common.h" #include "linden_common.h"
#include "llares.h" #include "llares.h"
#include "llscopedvolatileaprpool.h"
#include <ares_dns.h> #include <ares_dns.h>
#include <ares_version.h> #include <ares_version.h>

View File

@@ -401,7 +401,7 @@ bool LLAssetStorage::findInStaticVFSAndInvokeCallback(const LLUUID& uuid, LLAsse
if (user_data) if (user_data)
{ {
// The *user_data should not be passed without a callback to clean it up. // The *user_data should not be passed without a callback to clean it up.
llassert(callback != NULL) llassert(callback != NULL);
} }
BOOL exists = mStaticVFS->getExists(uuid, type); BOOL exists = mStaticVFS->getExists(uuid, type);
@@ -441,7 +441,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, LL
if (user_data) if (user_data)
{ {
// The *user_data should not be passed without a callback to clean it up. // The *user_data should not be passed without a callback to clean it up.
llassert(callback != NULL) llassert(callback != NULL);
} }
if (mShutDown) if (mShutDown)

File diff suppressed because it is too large Load Diff

View File

@@ -1,457 +1,39 @@
/** /**
* @file llcurl.h * @file llcurl.h
* @author Zero / Donovan * @brief Drop in replacement for old llcurl.h.
* @date 2006-10-15
* @brief A wrapper around libcurl.
* *
* $LicenseInfo:firstyear=2006&license=viewerlgpl$ * Copyright (c) 2012, Aleric Inglewood.
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
* *
* This library is free software; you can redistribute it and/or * This program is free software: you can redistribute it and/or modify
* modify it under the terms of the GNU Lesser General Public * it under the terms of the GNU General Public License as published by
* License as published by the Free Software Foundation; * the Free Software Foundation, either version 2 of the License, or
* version 2.1 of the License only. * (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Lesser General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU General Public License
* License along with this library; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * There are special exceptions to the terms and conditions of the GPL as
* $/LicenseInfo$ * it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution.
*
* CHANGELOG
* and additional copyright holders.
*
* 22/06/2012
* Initial version, written by Aleric Inglewood @ SL
*/ */
#ifndef LL_LLCURL_H #ifndef LL_LLCURL_H
#define LL_LLCURL_H #define LL_LLCURL_H
#include "linden_common.h" #include "aicurl.h"
#include <sstream> // Map interface to old LLCurl names so this can be used as a drop-in replacement.
#include <string> namespace LLCurl = AICurlInterface;
#include <vector>
#include <boost/intrusive_ptr.hpp>
#include <curl/curl.h> // TODO: remove dependency
#include "llbuffer.h"
#include "lliopipe.h"
#include "llsd.h"
#include "llthread.h"
#include "llqueuedthread.h"
#include "llframetimer.h"
class LLMutex;
class LLCurlThread;
// For whatever reason, this is not typedef'd in curl.h
typedef size_t (*curl_header_callback)(void *ptr, size_t size, size_t nmemb, void *stream);
class LLCurl
{
LOG_CLASS(LLCurl);
public:
class Easy;
class Multi;
struct TransferInfo
{
TransferInfo() : mSizeDownload(0.0), mTotalTime(0.0), mSpeedDownload(0.0) {}
F64 mSizeDownload;
F64 mTotalTime;
F64 mSpeedDownload;
};
class Responder
{
//LOG_CLASS(Responder);
public:
Responder();
virtual ~Responder();
/**
* @brief return true if the status code indicates success.
*/
static bool isGoodStatus(U32 status)
{
return((200 <= status) && (status < 300));
}
virtual void errorWithContent(
U32 status,
const std::string& reason,
const LLSD& content);
//< called by completed() on bad status
virtual void error(U32 status, const std::string& reason);
//< called by default error(status, reason, content)
virtual void result(const LLSD& content);
//< called by completed for good status codes.
virtual void completedRaw(
U32 status,
const std::string& reason,
const LLChannelDescriptors& channels,
const LLIOPipe::buffer_ptr_t& buffer);
/**< Override point for clients that may want to use this
class when the response is some other format besides LLSD
*/
virtual void completed(
U32 status,
const std::string& reason,
const LLSD& content);
/**< The default implemetnation calls
either:
* result(), or
* error()
*/
// Override to handle parsing of the header only. Note: this is the only place where the contents
// of the header can be parsed. In the ::completed call above only the body is contained in the LLSD.
virtual void completedHeader(U32 status, const std::string& reason, const LLSD& content);
// Used internally to set the url for debugging later.
void setURL(const std::string& url);
virtual bool followRedir()
{
return false;
}
public: /* but not really -- don't touch this */
U32 mReferenceCount;
private:
std::string mURL;
};
typedef boost::intrusive_ptr<Responder> ResponderPtr;
/**
* @ brief Set certificate authority file used to verify HTTPS certs.
*/
static void setCAFile(const std::string& file);
/**
* @ brief Set certificate authority path used to verify HTTPS certs.
*/
static void setCAPath(const std::string& path);
/**
* @ brief Return human-readable string describing libcurl version.
*/
static std::string getVersionString();
/**
* @ brief Get certificate authority file used to verify HTTPS certs.
*/
static const std::string& getCAFile() { return sCAFile; }
/**
* @ brief Get certificate authority path used to verify HTTPS certs.
*/
static const std::string& getCAPath() { return sCAPath; }
/**
* @ brief Initialize LLCurl class
*/
static void initClass(F32 curl_reuest_timeout = 120.f, S32 max_number_handles = 256, bool multi_threaded = false);
/**
* @ brief Cleanup LLCurl class
*/
static void cleanupClass();
/**
* @ brief curl error code -> string
*/
static std::string strerror(CURLcode errorcode);
// For OpenSSL callbacks
static std::vector<LLMutex*> sSSLMutex;
// OpenSSL callbacks
static void ssl_locking_callback(int mode, int type, const char *file, int line);
static unsigned long ssl_thread_id(void);
static LLCurlThread* getCurlThread() { return sCurlThread ;}
static CURLM* newMultiHandle() ;
static CURLMcode deleteMultiHandle(CURLM* handle) ;
static CURL* newEasyHandle() ;
static void deleteEasyHandle(CURL* handle) ;
private:
static std::string sCAPath;
static std::string sCAFile;
static const unsigned int MAX_REDIRECTS;
static LLCurlThread* sCurlThread;
static LLMutex* sHandleMutexp ;
static S32 sTotalHandles ;
static S32 sMaxHandles;
public:
static bool sNotQuitting;
static F32 sCurlRequestTimeOut;
};
class LLCurl::Easy
{
LOG_CLASS(Easy);
private:
Easy();
public:
static Easy* getEasy();
~Easy();
CURL* getCurlHandle() const { return mCurlEasyHandle; }
void setErrorBuffer();
void setCA();
void setopt(CURLoption option, S32 value);
// These assume the setter does not free value!
void setopt(CURLoption option, void* value);
void setopt(CURLoption option, char* value);
// Copies the string so that it is guaranteed to stick around
void setoptString(CURLoption option, const std::string& value);
void slist_append(const char* str);
void setHeaders();
U32 report(CURLcode);
void getTransferInfo(LLCurl::TransferInfo* info);
void prepRequest(const std::string& url, const std::vector<std::string>& headers, LLCurl::ResponderPtr, S32 time_out = 0, bool post = false);
const char* getErrorBuffer();
std::stringstream& getInput() { return mInput; }
std::stringstream& getHeaderOutput() { return mHeaderOutput; }
LLIOPipe::buffer_ptr_t& getOutput() { return mOutput; }
const LLChannelDescriptors& getChannels() { return mChannels; }
void resetState();
static CURL* allocEasyHandle();
static void releaseEasyHandle(CURL* handle);
private:
friend class LLCurl;
friend class LLCurl::Multi;
CURL* mCurlEasyHandle;
struct curl_slist* mHeaders;
std::stringstream mRequest;
LLChannelDescriptors mChannels;
LLIOPipe::buffer_ptr_t mOutput;
std::stringstream mInput;
std::stringstream mHeaderOutput;
char mErrorBuffer[CURL_ERROR_SIZE];
// Note: char*'s not strings since we pass pointers to curl
std::vector<char*> mStrings;
LLCurl::ResponderPtr mResponder;
static std::set<CURL*> sFreeHandles;
static std::set<CURL*> sActiveHandles;
static LLMutex* sHandleMutexp ;
};
class LLCurl::Multi
{
LOG_CLASS(Multi);
friend class LLCurlThread ;
private:
~Multi();
void markDead() ;
bool doPerform();
public:
typedef enum
{
STATE_READY=0,
STATE_PERFORMING=1,
STATE_COMPLETED=2
} ePerformState;
Multi(F32 idle_time_out = 0.f);
LLCurl::Easy* allocEasy();
bool addEasy(LLCurl::Easy* easy);
void removeEasy(LLCurl::Easy* easy);
void lock() ;
void unlock() ;
void setState(ePerformState state) ;
ePerformState getState() ;
bool isCompleted() ;
bool isValid() {return mCurlMultiHandle != NULL && mValid;}
bool isDead() {return mDead;}
bool waitToComplete() ;
S32 process();
CURLMsg* info_read(S32* msgs_in_queue);
S32 mQueued;
S32 mErrorCount;
private:
void easyFree(LLCurl::Easy*);
void cleanup(bool deleted = false);
CURLM* mCurlMultiHandle;
typedef std::set<LLCurl::Easy*> easy_active_list_t;
easy_active_list_t mEasyActiveList;
typedef std::map<CURL*, LLCurl::Easy*> easy_active_map_t;
easy_active_map_t mEasyActiveMap;
typedef std::set<LLCurl::Easy*> easy_free_list_t;
easy_free_list_t mEasyFreeList;
LLQueuedThread::handle_t mHandle ;
ePerformState mState;
BOOL mDead ;
BOOL mValid ;
LLMutex* mMutexp ;
LLMutex* mDeletionMutexp ;
LLMutex* mEasyMutexp ;
LLFrameTimer mIdleTimer ;
F32 mIdleTimeOut;
};
class LLCurlThread : public LLQueuedThread
{
public:
class CurlRequest : public LLQueuedThread::QueuedRequest
{
protected:
virtual ~CurlRequest(); // use deleteRequest()
public:
CurlRequest(handle_t handle, LLCurl::Multi* multi, LLCurlThread* curl_thread);
/*virtual*/ bool processRequest();
/*virtual*/ void finishRequest(bool completed);
private:
// input
LLCurl::Multi* mMulti;
LLCurlThread* mCurlThread;
};
friend class CurlRequest;
public:
LLCurlThread(bool threaded = true) ;
virtual ~LLCurlThread() ;
S32 update(F32 max_time_ms);
void addMulti(LLCurl::Multi* multi) ;
void killMulti(LLCurl::Multi* multi) ;
private:
bool doMultiPerform(LLCurl::Multi* multi) ;
void deleteMulti(LLCurl::Multi* multi) ;
void cleanupMulti(LLCurl::Multi* multi) ;
} ;
//namespace boost
//{
void intrusive_ptr_add_ref(LLCurl::Responder* p);
void intrusive_ptr_release(LLCurl::Responder* p);
//};
class LLCurlRequest
{
public:
typedef std::vector<std::string> headers_t;
LLCurlRequest();
~LLCurlRequest();
void get(const std::string& url, LLCurl::ResponderPtr responder);
bool getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, LLCurl::ResponderPtr responder);
bool post(const std::string& url, const headers_t& headers, const LLSD& data, LLCurl::ResponderPtr responder, S32 time_out = 0);
bool post(const std::string& url, const headers_t& headers, const std::string& data, LLCurl::ResponderPtr responder, S32 time_out = 0);
S32 process();
S32 getQueued();
private:
void addMulti();
LLCurl::Easy* allocEasy();
bool addEasy(LLCurl::Easy* easy);
private:
typedef std::set<LLCurl::Multi*> curlmulti_set_t;
curlmulti_set_t mMultiSet;
LLCurl::Multi* mActiveMulti;
S32 mActiveRequestCount;
BOOL mProcessing;
};
class LLCurlEasyRequest
{
public:
LLCurlEasyRequest();
~LLCurlEasyRequest();
void setopt(CURLoption option, S32 value);
void setoptString(CURLoption option, const std::string& value);
void setPost(char* postdata, S32 size);
void setHeaderCallback(curl_header_callback callback, void* userdata);
void setWriteCallback(curl_write_callback callback, void* userdata);
void setReadCallback(curl_read_callback callback, void* userdata);
void setSSLCtxCallback(curl_ssl_ctx_callback callback, void* userdata);
void slist_append(const char* str);
void sendRequest(const std::string& url);
void requestComplete();
bool getResult(CURLcode* result, LLCurl::TransferInfo* info = NULL);
std::string getErrorString();
bool isCompleted() {return mMulti->isCompleted() ;}
bool wait() { return mMulti->waitToComplete(); }
bool isValid() {return mMulti && mMulti->isValid(); }
LLCurl::Easy* getEasy() const { return mEasy; }
private:
CURLMsg* info_read(S32* queue, LLCurl::TransferInfo* info);
private:
LLCurl::Multi* mMulti;
LLCurl::Easy* mEasy;
bool mRequestSent;
bool mResultReturned;
};
// Provide access to LLCurl free functions outside of llcurl.cpp without polluting the global namespace.
namespace LLCurlFF
{
void check_easy_code(CURLcode code);
void check_multi_code(CURLMcode code);
}
#endif // LL_LLCURL_H #endif // LL_LLCURL_H

View File

@@ -220,17 +220,28 @@ static void request(
const LLSD& headers = LLSD() const LLSD& headers = LLSD()
) )
{ {
if (responder)
{
// For possible debug output from within the responder.
responder->setURL(url);
}
if (!LLHTTPClient::hasPump()) if (!LLHTTPClient::hasPump())
{ {
responder->completed(U32_MAX, "No pump", LLSD()); responder->fatalError("No pump");
return; return;
} }
LLPumpIO::chain_t chain; LLPumpIO::chain_t chain;
LLURLRequest* req = new LLURLRequest(method, url); LLURLRequest* req;
if(!req->isValid())//failed try
{ {
delete req ; req = new LLURLRequest(method, url);
}
catch(AICurlNoEasyHandle& error)
{
llwarns << "Failed to create LLURLRequest: " << error.what() << llendl;
// This is what the old LL code did: no recovery whatsoever (but also no leaks or crash).
return ; return ;
} }
@@ -282,11 +293,6 @@ static void request(
} }
} }
if (responder)
{
responder->setURL(url);
}
req->setCallback(new LLHTTPClientURLAdaptor(responder)); req->setCallback(new LLHTTPClientURLAdaptor(responder));
if (method == LLURLRequest::HTTP_POST && gMessageSystem) if (method == LLURLRequest::HTTP_POST && gMessageSystem)
@@ -333,7 +339,7 @@ void LLHTTPClient::getByteRange(
std::string range = llformat("bytes=%d-%d", offset, offset+bytes-1); std::string range = llformat("bytes=%d-%d", offset, offset+bytes-1);
headers["Range"] = range; headers["Range"] = range;
} }
request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers); request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers);
} }
void LLHTTPClient::head( void LLHTTPClient::head(
@@ -372,12 +378,12 @@ class LLHTTPBuffer
public: public:
LLHTTPBuffer() { } LLHTTPBuffer() { }
static size_t curl_write( void *ptr, size_t size, size_t nmemb, void *user_data) static size_t curl_write(char* ptr, size_t size, size_t nmemb, void* user_data)
{ {
LLHTTPBuffer* self = (LLHTTPBuffer*)user_data; LLHTTPBuffer* self = (LLHTTPBuffer*)user_data;
size_t bytes = (size * nmemb); size_t bytes = (size * nmemb);
self->mBuffer.append((char*)ptr,bytes); self->mBuffer.append(ptr,bytes);
return nmemb; return nmemb;
} }
@@ -428,104 +434,91 @@ static LLSD blocking_request(
) )
{ {
lldebugs << "blockingRequest of " << url << llendl; lldebugs << "blockingRequest of " << url << llendl;
char curl_error_buffer[CURL_ERROR_SIZE] = "\0";
CURL* curlp = LLCurl::newEasyHandle();
llassert_always(curlp != NULL) ;
LLHTTPBuffer http_buffer; S32 http_status = 499;
std::string body_str; LLSD response = LLSD::emptyMap();
// other request method checks root cert first, we skip? try
// Apply configured proxy settings
LLProxy::getInstance()->applyProxySettings(curlp);
// * Set curl handle options
curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts
curl_easy_setopt(curlp, CURLOPT_TIMEOUT, timeout); // seconds, see warning at top of function.
curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, LLHTTPBuffer::curl_write);
curl_easy_setopt(curlp, CURLOPT_WRITEDATA, &http_buffer);
curl_easy_setopt(curlp, CURLOPT_URL, url.c_str());
curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curl_error_buffer);
// * Setup headers (don't forget to free them after the call!)
curl_slist* headers_list = NULL;
if (headers.isMap())
{ {
LLSD::map_const_iterator iter = headers.beginMap(); AICurlEasyRequest easy_request(false);
LLSD::map_const_iterator end = headers.endMap(); AICurlEasyRequest_wat curlEasyRequest_w(*easy_request);
for (; iter != end; ++iter)
LLHTTPBuffer http_buffer;
std::string body_str;
// * Set curl handle options
curlEasyRequest_w->setopt(CURLOPT_TIMEOUT, timeout); // seconds, see warning at top of function.
curlEasyRequest_w->setWriteCallback(&LLHTTPBuffer::curl_write, &http_buffer);
// * Setup headers.
if (headers.isMap())
{ {
std::ostringstream header; LLSD::map_const_iterator iter = headers.beginMap();
header << iter->first << ": " << iter->second.asString() ; LLSD::map_const_iterator end = headers.endMap();
lldebugs << "header = " << header.str() << llendl; for (; iter != end; ++iter)
headers_list = curl_slist_append(headers_list, header.str().c_str()); {
std::ostringstream header;
header << iter->first << ": " << iter->second.asString() ;
lldebugs << "header = " << header.str() << llendl;
curlEasyRequest_w->addHeader(header.str().c_str());
}
}
// * Setup specific method / "verb" for the URI (currently only GET and POST supported + poppy)
if (method == LLURLRequest::HTTP_GET)
{
curlEasyRequest_w->setopt(CURLOPT_HTTPGET, 1);
}
else if (method == LLURLRequest::HTTP_POST)
{
curlEasyRequest_w->setopt(CURLOPT_POST, 1);
//serialize to ostr then copy to str - need to because ostr ptr is unstable :(
std::ostringstream ostr;
LLSDSerialize::toXML(body, ostr);
body_str = ostr.str();
curlEasyRequest_w->setopt(CURLOPT_POSTFIELDS, body_str.c_str());
//copied from PHP libs, correct?
curlEasyRequest_w->addHeader("Content-Type: application/llsd+xml");
// copied from llurlrequest.cpp
// it appears that apache2.2.3 or django in etch is busted. If
// we do not clear the expect header, we get a 500. May be
// limited to django/mod_wsgi.
curlEasyRequest_w->addHeader("Expect:");
}
// * Do the action using curl, handle results
lldebugs << "HTTP body: " << body_str << llendl;
curlEasyRequest_w->addHeader("Accept: application/llsd+xml");
curlEasyRequest_w->finalizeRequest(url);
S32 curl_success = curlEasyRequest_w->perform();
curlEasyRequest_w->getinfo(CURLINFO_RESPONSE_CODE, &http_status);
// if we get a non-404 and it's not a 200 OR maybe it is but you have error bits,
if ( http_status != 404 && (http_status != 200 || curl_success != 0) )
{
// We expect 404s, don't spam for them.
llwarns << "CURL REQ URL: " << url << llendl;
llwarns << "CURL REQ METHOD TYPE: " << method << llendl;
llwarns << "CURL REQ HEADERS: " << headers.asString() << llendl;
llwarns << "CURL REQ BODY: " << body_str << llendl;
llwarns << "CURL HTTP_STATUS: " << http_status << llendl;
llwarns << "CURL ERROR: " << curlEasyRequest_w->getErrorString() << llendl;
llwarns << "CURL ERROR BODY: " << http_buffer.asString() << llendl;
response["body"] = http_buffer.asString();
}
else
{
response["body"] = http_buffer.asLLSD();
lldebugs << "CURL response: " << http_buffer.asString() << llendl;
} }
} }
catch(AICurlNoEasyHandle const& error)
// * Setup specific method / "verb" for the URI (currently only GET and POST supported + poppy)
if (method == LLURLRequest::HTTP_GET)
{ {
curl_easy_setopt(curlp, CURLOPT_HTTPGET, 1); response["body"] = error.what();
}
else if (method == LLURLRequest::HTTP_POST)
{
curl_easy_setopt(curlp, CURLOPT_POST, 1);
//serialize to ostr then copy to str - need to because ostr ptr is unstable :(
std::ostringstream ostr;
LLSDSerialize::toXML(body, ostr);
body_str = ostr.str();
curl_easy_setopt(curlp, CURLOPT_POSTFIELDS, body_str.c_str());
//copied from PHP libs, correct?
headers_list = curl_slist_append(headers_list, "Content-Type: application/llsd+xml");
// copied from llurlrequest.cpp
// it appears that apache2.2.3 or django in etch is busted. If
// we do not clear the expect header, we get a 500. May be
// limited to django/mod_wsgi.
headers_list = curl_slist_append(headers_list, "Expect:");
} }
// * Do the action using curl, handle results
lldebugs << "HTTP body: " << body_str << llendl;
headers_list = curl_slist_append(headers_list, "Accept: application/llsd+xml");
CURLcode curl_result = curl_easy_setopt(curlp, CURLOPT_HTTPHEADER, headers_list);
if ( curl_result != CURLE_OK )
{
llinfos << "Curl is hosed - can't add headers" << llendl;
}
LLSD response = LLSD::emptyMap();
S32 curl_success = curl_easy_perform(curlp);
S32 http_status = 499;
curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &http_status);
response["status"] = http_status; response["status"] = http_status;
// if we get a non-404 and it's not a 200 OR maybe it is but you have error bits,
if ( http_status != 404 && (http_status != 200 || curl_success != 0) )
{
// We expect 404s, don't spam for them.
llwarns << "CURL REQ URL: " << url << llendl;
llwarns << "CURL REQ METHOD TYPE: " << method << llendl;
llwarns << "CURL REQ HEADERS: " << headers.asString() << llendl;
llwarns << "CURL REQ BODY: " << body_str << llendl;
llwarns << "CURL HTTP_STATUS: " << http_status << llendl;
llwarns << "CURL ERROR: " << curl_error_buffer << llendl;
llwarns << "CURL ERROR BODY: " << http_buffer.asString() << llendl;
response["body"] = http_buffer.asString();
}
else
{
response["body"] = http_buffer.asLLSD();
lldebugs << "CURL response: " << http_buffer.asString() << llendl;
}
if(headers_list)
{ // free the header list
curl_slist_free_all(headers_list);
}
// * Cleanup
LLCurl::deleteEasyHandle(curlp);
return response; return response;
} }

View File

@@ -55,6 +55,8 @@ public:
typedef LLCurl::Responder Responder; typedef LLCurl::Responder Responder;
typedef LLCurl::ResponderPtr ResponderPtr; typedef LLCurl::ResponderPtr ResponderPtr;
// The default actually already ignores responses.
class ResponderIgnore : public Responder { };
/** @name non-blocking API */ /** @name non-blocking API */
//@{ //@{

View File

@@ -76,7 +76,14 @@ LLIOPipe::~LLIOPipe()
} }
//virtual //virtual
bool LLIOPipe::isValid() bool LLIOPipe::hasExpiration(void) const
{
// LLIOPipe::hasNotExpired always returns true.
return false;
}
//virtual
bool LLIOPipe::hasNotExpired(void) const
{ {
return true ; return true ;
} }

View File

@@ -149,7 +149,7 @@ public:
// The connection was lost. // The connection was lost.
STATUS_LOST_CONNECTION = -5, STATUS_LOST_CONNECTION = -5,
// The totoal process time has exceeded the timeout. // The total process time has exceeded the timeout.
STATUS_EXPIRED = -6, STATUS_EXPIRED = -6,
// Keep track of the count of codes here. // Keep track of the count of codes here.
@@ -231,7 +231,16 @@ public:
*/ */
virtual ~LLIOPipe(); virtual ~LLIOPipe();
virtual bool isValid() ; /**
* @brief External expiration facility.
*
* If hasExpiration() returns true, then we need to check hasNotExpired()
* to see if the LLIOPipe is still valid. In the legacy LL code the
* latter was called isValid() and was overloaded for two purposes:
* either expiration or failure to initialize.
*/
virtual bool hasExpiration(void) const;
virtual bool hasNotExpired(void) const;
protected: protected:
/** /**

View File

@@ -47,23 +47,22 @@ static apr_status_t tcp_blocking_handshake(LLSocket::ptr_t handle, char * dataou
static LLSocket::ptr_t tcp_open_channel(LLHost host); // Open a TCP channel to a given host static LLSocket::ptr_t tcp_open_channel(LLHost host); // Open a TCP channel to a given host
static void tcp_close_channel(LLSocket::ptr_t* handle_ptr); // Close an open TCP channel static void tcp_close_channel(LLSocket::ptr_t* handle_ptr); // Close an open TCP channel
LLProxy::LLProxy(): ProxyShared::ProxyShared(void):
mHTTPProxyEnabled(false),
mProxyMutex(),
mUDPProxy(),
mTCPProxy(),
mHTTPProxy(),
mProxyType(LLPROXY_SOCKS), mProxyType(LLPROXY_SOCKS),
mAuthMethodSelected(METHOD_NOAUTH), mAuthMethodSelected(METHOD_NOAUTH)
mSocksUsername(), {
mSocksPassword() }
LLProxy::LLProxy():
mHTTPProxyEnabled(false)
{ {
} }
LLProxy::~LLProxy() LLProxy::~LLProxy()
{ {
stopSOCKSProxy(); stopSOCKSProxy();
disableHTTPProxy(); Shared_wat shared_w(mShared);
disableHTTPProxy(shared_w);
} }
/** /**
@@ -78,15 +77,18 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
{ {
S32 result; S32 result;
Unshared_rat unshared_r(mUnshared);
Shared_rat shared_r(mShared);
/* SOCKS 5 Auth request */ /* SOCKS 5 Auth request */
socks_auth_request_t socks_auth_request; socks_auth_request_t socks_auth_request;
socks_auth_response_t socks_auth_response; socks_auth_response_t socks_auth_response;
socks_auth_request.version = SOCKS_VERSION; // SOCKS version 5 socks_auth_request.version = SOCKS_VERSION; // SOCKS version 5
socks_auth_request.num_methods = 1; // Sending 1 method. socks_auth_request.num_methods = 1; // Sending 1 method.
socks_auth_request.methods = getSelectedAuthMethod(); // Send only the selected method. socks_auth_request.methods = getSelectedAuthMethod(shared_r); // Send only the selected method.
result = tcp_blocking_handshake(mProxyControlChannel, result = tcp_blocking_handshake(unshared_r->mProxyControlChannel,
static_cast<char*>(static_cast<void*>(&socks_auth_request)), static_cast<char*>(static_cast<void*>(&socks_auth_request)),
sizeof(socks_auth_request), sizeof(socks_auth_request),
static_cast<char*>(static_cast<void*>(&socks_auth_response)), static_cast<char*>(static_cast<void*>(&socks_auth_response)),
@@ -109,8 +111,8 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
if (socks_auth_response.method == METHOD_PASSWORD) if (socks_auth_response.method == METHOD_PASSWORD)
{ {
// The server has requested a username/password combination // The server has requested a username/password combination
std::string socks_username(getSocksUser()); std::string socks_username(getSocksUser(shared_r));
std::string socks_password(getSocksPwd()); std::string socks_password(getSocksPwd(shared_r));
U32 request_size = socks_username.size() + socks_password.size() + 3; U32 request_size = socks_username.size() + socks_password.size() + 3;
char * password_auth = new char[request_size]; char * password_auth = new char[request_size];
password_auth[0] = 0x01; password_auth[0] = 0x01;
@@ -121,7 +123,7 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
authmethod_password_reply_t password_reply; authmethod_password_reply_t password_reply;
result = tcp_blocking_handshake(mProxyControlChannel, result = tcp_blocking_handshake(unshared_r->mProxyControlChannel,
password_auth, password_auth,
request_size, request_size,
static_cast<char*>(static_cast<void*>(&password_reply)), static_cast<char*>(static_cast<void*>(&password_reply)),
@@ -157,7 +159,7 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
// "If the client is not in possession of the information at the time of the UDP ASSOCIATE, // "If the client is not in possession of the information at the time of the UDP ASSOCIATE,
// the client MUST use a port number and address of all zeros. RFC 1928" // the client MUST use a port number and address of all zeros. RFC 1928"
result = tcp_blocking_handshake(mProxyControlChannel, result = tcp_blocking_handshake(unshared_r->mProxyControlChannel,
static_cast<char*>(static_cast<void*>(&connect_request)), static_cast<char*>(static_cast<void*>(&connect_request)),
sizeof(connect_request), sizeof(connect_request),
static_cast<char*>(static_cast<void*>(&connect_reply)), static_cast<char*>(static_cast<void*>(&connect_reply)),
@@ -176,10 +178,14 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
return SOCKS_UDP_FWD_NOT_GRANTED; return SOCKS_UDP_FWD_NOT_GRANTED;
} }
mUDPProxy.setPort(ntohs(connect_reply.port)); // reply port is in network byte order {
mUDPProxy.setAddress(proxy.getAddress()); // Write access type and read access type are really the same, so unshared_w must be simply a reference.
Unshared_wat& unshared_w = unshared_r;
unshared_w->mUDPProxy.setPort(ntohs(connect_reply.port)); // reply port is in network byte order
unshared_w->mUDPProxy.setAddress(proxy.getAddress());
}
// The connection was successful. We now have the UDP port to send requests that need forwarding to. // The connection was successful. We now have the UDP port to send requests that need forwarding to.
LL_INFOS("Proxy") << "SOCKS 5 UDP proxy connected on " << mUDPProxy << LL_ENDL; LL_INFOS("Proxy") << "SOCKS 5 UDP proxy connected on " << unshared_r->mUDPProxy << LL_ENDL;
return SOCKS_OK; return SOCKS_OK;
} }
@@ -197,9 +203,11 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
*/ */
S32 LLProxy::startSOCKSProxy(LLHost host) S32 LLProxy::startSOCKSProxy(LLHost host)
{ {
Unshared_wat unshared_w(mUnshared);
if (host.isOk()) if (host.isOk())
{ {
mTCPProxy = host; unshared_w->mTCPProxy = host;
} }
else else
{ {
@@ -209,13 +217,13 @@ S32 LLProxy::startSOCKSProxy(LLHost host)
// Close any running SOCKS connection. // Close any running SOCKS connection.
stopSOCKSProxy(); stopSOCKSProxy();
mProxyControlChannel = tcp_open_channel(mTCPProxy); unshared_w->mProxyControlChannel = tcp_open_channel(unshared_w->mTCPProxy);
if (!mProxyControlChannel) if (!unshared_w->mProxyControlChannel)
{ {
return SOCKS_HOST_CONNECT_FAILED; return SOCKS_HOST_CONNECT_FAILED;
} }
S32 status = proxyHandshake(mTCPProxy); S32 status = proxyHandshake(unshared_w->mTCPProxy);
if (status != SOCKS_OK) if (status != SOCKS_OK)
{ {
@@ -246,14 +254,16 @@ void LLProxy::stopSOCKSProxy()
// then we must shut down any HTTP proxy operations. But it is allowable if web // then we must shut down any HTTP proxy operations. But it is allowable if web
// proxy is being used to continue proxying HTTP. // proxy is being used to continue proxying HTTP.
if (LLPROXY_SOCKS == getHTTPProxyType()) Shared_rat shared_r(mShared);
if (LLPROXY_SOCKS == getHTTPProxyType(shared_r))
{ {
disableHTTPProxy(); Shared_wat shared_w(shared_r);
disableHTTPProxy(shared_w);
} }
Unshared_wat unshared_w(mUnshared);
if (mProxyControlChannel) if (unshared_w->mProxyControlChannel)
{ {
tcp_close_channel(&mProxyControlChannel); tcp_close_channel(&unshared_w->mProxyControlChannel);
} }
} }
@@ -262,9 +272,7 @@ void LLProxy::stopSOCKSProxy()
*/ */
void LLProxy::setAuthNone() void LLProxy::setAuthNone()
{ {
LLMutexLock lock(&mProxyMutex); Shared_wat(mShared)->mAuthMethodSelected = METHOD_NOAUTH;
mAuthMethodSelected = METHOD_NOAUTH;
} }
/** /**
@@ -288,11 +296,10 @@ bool LLProxy::setAuthPassword(const std::string &username, const std::string &pa
return false; return false;
} }
LLMutexLock lock(&mProxyMutex); Shared_wat shared_w(mShared);
shared_w->mAuthMethodSelected = METHOD_PASSWORD;
mAuthMethodSelected = METHOD_PASSWORD; shared_w->mSocksUsername = username;
mSocksUsername = username; shared_w->mSocksPassword = password;
mSocksPassword = password;
return true; return true;
} }
@@ -314,12 +321,10 @@ bool LLProxy::enableHTTPProxy(LLHost httpHost, LLHttpProxyType type)
return false; return false;
} }
LLMutexLock lock(&mProxyMutex); Shared_wat shared_w(mShared);
mHTTPProxy = httpHost;
mProxyType = type;
mHTTPProxyEnabled = true; mHTTPProxyEnabled = true;
shared_w->mHTTPProxy = httpHost;
shared_w->mProxyType = type;
return true; return true;
} }
@@ -335,9 +340,8 @@ bool LLProxy::enableHTTPProxy()
{ {
bool ok; bool ok;
LLMutexLock lock(&mProxyMutex); Shared_rat shared_r(mShared);
ok = (shared_r->mHTTPProxy.isOk());
ok = (mHTTPProxy.isOk());
if (ok) if (ok)
{ {
mHTTPProxyEnabled = true; mHTTPProxyEnabled = true;
@@ -346,54 +350,6 @@ bool LLProxy::enableHTTPProxy()
return ok; return ok;
} }
/**
* @brief Disable the HTTP proxy.
*/
void LLProxy::disableHTTPProxy()
{
LLMutexLock lock(&mProxyMutex);
mHTTPProxyEnabled = false;
}
/**
* @brief Get the currently selected HTTP proxy type
*/
LLHttpProxyType LLProxy::getHTTPProxyType() const
{
LLMutexLock lock(&mProxyMutex);
return mProxyType;
}
/**
* @brief Get the SOCKS 5 password.
*/
std::string LLProxy::getSocksPwd() const
{
LLMutexLock lock(&mProxyMutex);
return mSocksPassword;
}
/**
* @brief Get the SOCKS 5 username.
*/
std::string LLProxy::getSocksUser() const
{
LLMutexLock lock(&mProxyMutex);
return mSocksUsername;
}
/**
* @brief Get the currently selected SOCKS 5 authentication method.
*
* @return Returns either none or password.
*/
LLSocks5AuthType LLProxy::getSelectedAuthMethod() const
{
LLMutexLock lock(&mProxyMutex);
return mAuthMethodSelected;
}
/** /**
* @brief Stop the LLProxy and make certain that any APR pools and classes are deleted before terminating APR. * @brief Stop the LLProxy and make certain that any APR pools and classes are deleted before terminating APR.
* *
@@ -406,57 +362,6 @@ void LLProxy::cleanupClass()
deleteSingleton(); deleteSingleton();
} }
void LLProxy::applyProxySettings(LLCurlEasyRequest* handle)
{
applyProxySettings(handle->getEasy());
}
void LLProxy::applyProxySettings(LLCurl::Easy* handle)
{
applyProxySettings(handle->getCurlHandle());
}
/**
* @brief Apply proxy settings to a CuRL request if an HTTP proxy is enabled.
*
* This method has been designed to be safe to call from
* any thread in the viewer. This allows requests in the
* texture fetch thread to be aware of the proxy settings.
* When the HTTP proxy is enabled, the proxy mutex will
* be locked every time this method is called.
*
* @param handle A pointer to a valid CURL request, before it has been performed.
*/
void LLProxy::applyProxySettings(CURL* handle)
{
// Do a faster unlocked check to see if we are supposed to proxy.
if (mHTTPProxyEnabled)
{
// We think we should proxy, lock the proxy mutex.
LLMutexLock lock(&mProxyMutex);
// Now test again to verify that the proxy wasn't disabled between the first check and the lock.
if (mHTTPProxyEnabled)
{
LLCurlFF::check_easy_code(curl_easy_setopt(handle, CURLOPT_PROXY, mHTTPProxy.getIPString().c_str()));
LLCurlFF::check_easy_code(curl_easy_setopt(handle, CURLOPT_PROXYPORT, mHTTPProxy.getPort()));
if (mProxyType == LLPROXY_SOCKS)
{
LLCurlFF::check_easy_code(curl_easy_setopt(handle, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5));
if (mAuthMethodSelected == METHOD_PASSWORD)
{
std::string auth_string = mSocksUsername + ":" + mSocksPassword;
LLCurlFF::check_easy_code(curl_easy_setopt(handle, CURLOPT_PROXYUSERPWD, auth_string.c_str()));
}
}
else
{
LLCurlFF::check_easy_code(curl_easy_setopt(handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP));
}
}
}
}
/** /**
* @brief Send one TCP packet and receive one in return. * @brief Send one TCP packet and receive one in return.
* *

View File

@@ -33,6 +33,7 @@
#include "llmemory.h" #include "llmemory.h"
#include "llsingleton.h" #include "llsingleton.h"
#include "llthread.h" #include "llthread.h"
#include "aithreadsafe.h"
#include <string> #include <string>
// SOCKS error codes returned from the StartProxy method // SOCKS error codes returned from the StartProxy method
@@ -206,41 +207,92 @@ enum LLSocks5AuthType
* The implementation of HTTP proxying is handled by libcurl. LLProxy * The implementation of HTTP proxying is handled by libcurl. LLProxy
* is responsible for managing the HTTP proxy options and provides a * is responsible for managing the HTTP proxy options and provides a
* thread-safe method to apply those options to a curl request * thread-safe method to apply those options to a curl request
* (LLProxy::applyProxySettings()). This method is overloaded * (LLProxy::applyProxySettings()).
* to accommodate the various abstraction libcurl layers that exist
* throughout the viewer (LLCurlEasyRequest, LLCurl::Easy, and CURL).
*
* If you are working with LLCurl or LLCurlEasyRequest objects,
* the configured proxy settings will be applied in the constructors
* of those request handles. If you are working with CURL objects
* directly, you will need to pass the handle of the request to
* applyProxySettings() before issuing the request.
* *
* To ensure thread safety, all LLProxy members that relate to the HTTP * To ensure thread safety, all LLProxy members that relate to the HTTP
* proxy require the LLProxyMutex to be locked before accessing. * proxy require the LLProxyMutex to be locked before accessing.
*/ */
struct ProxyUnshared
{
/*###########################################################################################
MEMBERS READ AND WRITTEN ONLY IN THE MAIN THREAD.
###########################################################################################*/
// UDP proxy address and port
LLHost mUDPProxy;
// TCP proxy control channel address and port
LLHost mTCPProxy;
// socket handle to proxy TCP control channel
LLSocket::ptr_t mProxyControlChannel;
/*###########################################################################################
END OF UNSHARED MEMBERS
###########################################################################################*/
};
struct ProxyShared
{
ProxyShared(void);
/*###########################################################################################
MEMBERS WRITTEN IN MAIN THREAD AND READ IN ANY THREAD.
###########################################################################################*/
// HTTP proxy address and port
LLHost mHTTPProxy;
// Currently selected HTTP proxy type. Can be web or SOCKS.
LLHttpProxyType mProxyType;
// SOCKS 5 selected authentication method.
LLSocks5AuthType mAuthMethodSelected;
// SOCKS 5 username
std::string mSocksUsername;
// SOCKS 5 password
std::string mSocksPassword;
/*###########################################################################################
END OF SHARED MEMBERS
###########################################################################################*/
};
class LLProxy: public LLSingleton<LLProxy> class LLProxy: public LLSingleton<LLProxy>
{ {
LOG_CLASS(LLProxy); LOG_CLASS(LLProxy);
public: public:
typedef AISTAccessConst<ProxyUnshared> Unshared_crat; // Constant Read Access Type for Unshared (cannot be converted to write access).
typedef AISTAccess<ProxyUnshared> Unshared_rat; // Read Access Type for Unshared (same as write access type, since we don't lock at all).
typedef AISTAccess<ProxyUnshared> Unshared_wat; // Write Access Type, for Unshared.
typedef AIReadAccessConst<ProxyShared> Shared_crat; // Constant Read Access Type for Shared (cannot be converted to write access).
typedef AIReadAccess<ProxyShared> Shared_rat; // Read Access Type for Shared.
typedef AIWriteAccess<ProxyShared> Shared_wat; // Write Access Type for Shared.
/*########################################################################################### /*###########################################################################################
METHODS THAT DO NOT LOCK mProxyMutex! Public methods that only access variables not shared between threads.
###########################################################################################*/ ###########################################################################################*/
// Constructor, cannot have parameters due to LLSingleton parent class. Call from main thread only. // Constructor, cannot have parameters due to LLSingleton parent class. Call from main thread only.
LLProxy(); LLProxy();
// Static check for enabled status for UDP packets. Call from main thread only. // Static check for enabled status for UDP packets. Called from main thread only.
static bool isSOCKSProxyEnabled() { return sUDPProxyEnabled; } static bool isSOCKSProxyEnabled(void) { llassert(is_main_thread()); return sUDPProxyEnabled; }
// Get the UDP proxy address and port. Call from main thread only. // Get the UDP proxy address and port. Called from main thread only.
LLHost getUDPProxy() const { return mUDPProxy; } LLHost getUDPProxy(void) const { return Unshared_crat(mUnshared)->mUDPProxy; }
/*########################################################################################### /*###########################################################################################
END OF NON-LOCKING METHODS End of methods that only access variables not shared between threads.
###########################################################################################*/ ###########################################################################################*/
// Return true if there is a good chance that the HTTP proxy is currently enabled.
bool HTTPProxyEnabled(void) const { return mHTTPProxyEnabled; }
/*########################################################################################### /*###########################################################################################
METHODS THAT LOCK mProxyMutex! DO NOT CALL WHILE mProxyMutex IS LOCKED! Public methods that access variables shared between threads.
###########################################################################################*/ ###########################################################################################*/
// Destructor, closes open connections. Do not call directly, use cleanupClass(). // Destructor, closes open connections. Do not call directly, use cleanupClass().
~LLProxy(); ~LLProxy();
@@ -251,9 +303,7 @@ public:
// Apply the current proxy settings to a curl request. Doesn't do anything if mHTTPProxyEnabled is false. // Apply the current proxy settings to a curl request. Doesn't do anything if mHTTPProxyEnabled is false.
// Safe to call from any thread. // Safe to call from any thread.
void applyProxySettings(CURL* handle); void applyProxySettings(AICurlEasyRequest_wat const& curlEasyRequest_w);
void applyProxySettings(LLCurl::Easy* handle);
void applyProxySettings(LLCurlEasyRequest* handle);
// Start a connection to the SOCKS 5 proxy. Call from main thread only. // Start a connection to the SOCKS 5 proxy. Call from main thread only.
S32 startSOCKSProxy(LLHost host); S32 startSOCKSProxy(LLHost host);
@@ -273,30 +323,37 @@ public:
bool enableHTTPProxy(); bool enableHTTPProxy();
// Stop proxying HTTP packets. Call from main thread only. // Stop proxying HTTP packets. Call from main thread only.
void disableHTTPProxy(); // Note that this needs shared_w to be passed because we want the shared members to be locked when this is reset to false.
void disableHTTPProxy(Shared_wat const& shared_w) { mHTTPProxyEnabled = false; }
void disableHTTPProxy(void) { disableHTTPProxy(Shared_wat(mShared)); }
// Get the currently selected HTTP proxy address and port
LLHost const& getHTTPProxy(Shared_crat const& shared_r) const { return shared_r->mHTTPProxy; }
// Get the currently selected HTTP proxy type
LLHttpProxyType getHTTPProxyType(Shared_crat const& shared_r) const { return shared_r->mProxyType; }
// Get the currently selected auth method.
LLSocks5AuthType getSelectedAuthMethod(Shared_crat const& shared_r) const { return shared_r->mAuthMethodSelected; }
// SOCKS 5 username and password accessors.
std::string getSocksUser(Shared_crat const& shared_r) const { return shared_r->mSocksUsername; }
std::string getSocksPwd(Shared_crat const& shared_r) const { return shared_r->mSocksPassword; }
/*########################################################################################### /*###########################################################################################
END OF LOCKING METHODS End of methods that access variables shared between threads.
###########################################################################################*/ ###########################################################################################*/
private: private:
/*########################################################################################### /*###########################################################################################
METHODS THAT LOCK mProxyMutex! DO NOT CALL WHILE mProxyMutex IS LOCKED! Private methods that access variables shared between threads.
###########################################################################################*/ ###########################################################################################*/
// Perform a SOCKS 5 authentication and UDP association with the proxy server. // Perform a SOCKS 5 authentication and UDP association with the proxy server.
S32 proxyHandshake(LLHost proxy); S32 proxyHandshake(LLHost proxy);
// Get the currently selected auth method.
LLSocks5AuthType getSelectedAuthMethod() const;
// Get the currently selected HTTP proxy type
LLHttpProxyType getHTTPProxyType() const;
std::string getSocksPwd() const;
std::string getSocksUser() const;
/*########################################################################################### /*###########################################################################################
END OF LOCKING METHODS End of methods that access variables shared between threads.
###########################################################################################*/ ###########################################################################################*/
private: private:
@@ -304,49 +361,16 @@ private:
// Instead use enableHTTPProxy() and disableHTTPProxy() instead. // Instead use enableHTTPProxy() and disableHTTPProxy() instead.
mutable LLAtomic32<bool> mHTTPProxyEnabled; mutable LLAtomic32<bool> mHTTPProxyEnabled;
// Mutex to protect shared members in non-main thread calls to applyProxySettings().
mutable LLMutex mProxyMutex;
/*###########################################################################################
MEMBERS READ AND WRITTEN ONLY IN THE MAIN THREAD. DO NOT SHARE!
###########################################################################################*/
// Is the UDP proxy enabled? // Is the UDP proxy enabled?
static bool sUDPProxyEnabled; static bool sUDPProxyEnabled;
// UDP proxy address and port AIThreadSafeSingleThreadDC<ProxyUnshared> mUnshared;
LLHost mUDPProxy; AIThreadSafeDC<ProxyShared> mShared;
// TCP proxy control channel address and port
LLHost mTCPProxy;
// socket handle to proxy TCP control channel public:
LLSocket::ptr_t mProxyControlChannel; // For thread-safe read access. Use the _crat access types with these.
AIThreadSafeSingleThreadDC<ProxyUnshared> const& unshared_lockobj(void) const { return mUnshared; }
/*########################################################################################### AIThreadSafeDC<ProxyShared> const& shared_lockobj(void) const { return mShared; }
END OF UNSHARED MEMBERS
###########################################################################################*/
/*###########################################################################################
MEMBERS WRITTEN IN MAIN THREAD AND READ IN ANY THREAD. ONLY READ OR WRITE AFTER LOCKING mProxyMutex!
###########################################################################################*/
// HTTP proxy address and port
LLHost mHTTPProxy;
// Currently selected HTTP proxy type. Can be web or socks.
LLHttpProxyType mProxyType;
// SOCKS 5 selected authentication method.
LLSocks5AuthType mAuthMethodSelected;
// SOCKS 5 username
std::string mSocksUsername;
// SOCKS 5 password
std::string mSocksPassword;
/*###########################################################################################
END OF SHARED MEMBERS
###########################################################################################*/
}; };
#endif #endif

View File

@@ -198,19 +198,17 @@ LLPumpIO::~LLPumpIO()
} }
} }
bool LLPumpIO::addChain(const chain_t& chain, F32 timeout, bool has_curl_request) bool LLPumpIO::addChain(chain_t const& chain, F32 timeout)
{ {
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(chain.empty()) return false;
#if LL_THREADS_APR chain_t::const_iterator it = chain.begin();
LLScopedLock lock(mChainsMutex); chain_t::const_iterator const end = chain.end();
#endif if (it == end) return false;
LLChainInfo info; LLChainInfo info;
info.mHasCurlRequest = has_curl_request;
info.setTimeoutSeconds(timeout); info.setTimeoutSeconds(timeout);
info.mData = LLIOPipe::buffer_ptr_t(new LLBufferArray); info.mData = LLIOPipe::buffer_ptr_t(new LLBufferArray);
info.mData->setThreaded(has_curl_request);
LLLinkInfo link; LLLinkInfo link;
#if LL_DEBUG_PIPE_TYPE_IN_PUMP #if LL_DEBUG_PIPE_TYPE_IN_PUMP
lldebugs << "LLPumpIO::addChain() " << chain[0] << " '" lldebugs << "LLPumpIO::addChain() " << chain[0] << " '"
@@ -218,14 +216,17 @@ bool LLPumpIO::addChain(const chain_t& chain, F32 timeout, bool has_curl_request
#else #else
lldebugs << "LLPumpIO::addChain() " << chain[0] <<llendl; lldebugs << "LLPumpIO::addChain() " << chain[0] <<llendl;
#endif #endif
chain_t::const_iterator it = chain.begin();
chain_t::const_iterator end = chain.end();
for(; it != end; ++it) for(; it != end; ++it)
{ {
info.mHasExpiration = info.mHasExpiration || (*it)->hasExpiration();
link.mPipe = (*it); link.mPipe = (*it);
link.mChannels = info.mData->nextChannel(); link.mChannels = info.mData->nextChannel();
info.mChainLinks.push_back(link); info.mChainLinks.push_back(link);
} }
#if LL_THREADS_APR
LLScopedLock lock(mChainsMutex);
#endif
mPendingChains.push_back(info); mPendingChains.push_back(info);
return true; return true;
} }
@@ -242,11 +243,10 @@ bool LLPumpIO::addChain(
// description, we need to have that description matched to a // description, we need to have that description matched to a
// particular buffer. // particular buffer.
if(!data) return false; if(!data) return false;
if(links.empty()) return false; links_t::const_iterator link = links.begin();
links_t::const_iterator const end = links.end();
if (link == end) return false;
#if LL_THREADS_APR
LLScopedLock lock(mChainsMutex);
#endif
#if LL_DEBUG_PIPE_TYPE_IN_PUMP #if LL_DEBUG_PIPE_TYPE_IN_PUMP
lldebugs << "LLPumpIO::addChain() " << links[0].mPipe << " '" lldebugs << "LLPumpIO::addChain() " << links[0].mPipe << " '"
<< typeid(*(links[0].mPipe)).name() << "'" << llendl; << typeid(*(links[0].mPipe)).name() << "'" << llendl;
@@ -258,6 +258,17 @@ bool LLPumpIO::addChain(
info.mChainLinks = links; info.mChainLinks = links;
info.mData = data; info.mData = data;
info.mContext = context; info.mContext = context;
for (; link != end; ++link)
{
if (link->mPipe->hasExpiration())
{
info.mHasExpiration = true;
break;
}
}
#if LL_THREADS_APR
LLScopedLock lock(mChainsMutex);
#endif
mPendingChains.push_back(info); mPendingChains.push_back(info);
return true; return true;
} }
@@ -1086,14 +1097,14 @@ void LLPumpIO::processChain(LLChainInfo& chain)
bool LLPumpIO::isChainExpired(LLChainInfo& chain) bool LLPumpIO::isChainExpired(LLChainInfo& chain)
{ {
if(!chain.mHasCurlRequest) if(!chain.mHasExpiration)
{ {
return false ; return false ;
} }
for(links_t::iterator iter = chain.mChainLinks.begin(); iter != chain.mChainLinks.end(); ++iter) for(links_t::iterator iter = chain.mChainLinks.begin(); iter != chain.mChainLinks.end(); ++iter)
{ {
if(!(*iter).mPipe->isValid()) if(!(*iter).mPipe->hasNotExpired())
{ {
return true ; return true ;
} }
@@ -1106,6 +1117,8 @@ bool LLPumpIO::handleChainError(
LLChainInfo& chain, LLChainInfo& chain,
LLIOPipe::EStatus error) LLIOPipe::EStatus error)
{ {
DoutEntering(dc::notice, "LLPumpIO::handleChainError(" << (void*)&chain << ", " << LLIOPipe::lookupStatusString(error) << ")");
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
links_t::reverse_iterator rit; links_t::reverse_iterator rit;
if(chain.mHead == chain.mChainLinks.end()) if(chain.mHead == chain.mChainLinks.end())
@@ -1168,7 +1181,7 @@ LLPumpIO::LLChainInfo::LLChainInfo() :
mInit(false), mInit(false),
mLock(0), mLock(0),
mEOS(false), mEOS(false),
mHasCurlRequest(false), mHasExpiration(false),
mDescriptorsPool(new LLAPRPool(LLThread::tldata().mRootPool)) mDescriptorsPool(new LLAPRPool(LLThread::tldata().mRootPool))
{ {
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
@@ -1180,9 +1193,7 @@ void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout)
LLMemType m1(LLMemType::MTYPE_IO_PUMP); LLMemType m1(LLMemType::MTYPE_IO_PUMP);
if(timeout > 0.0f) if(timeout > 0.0f)
{ {
mTimer.start(); mTimer.start(timeout);
mTimer.reset();
mTimer.setTimerExpirySec(timeout);
} }
else else
{ {

View File

@@ -100,10 +100,9 @@ public:
* @param chain The pipes for the chain * @param chain The pipes for the chain
* @param timeout The number of seconds in the future to * @param timeout The number of seconds in the future to
* expire. Pass in 0.0f to never expire. * expire. Pass in 0.0f to never expire.
* @param has_curl_request The chain contains LLURLRequest if true.
* @return Returns true if anything was added to the pump. * @return Returns true if anything was added to the pump.
*/ */
bool addChain(const chain_t& chain, F32 timeout, bool has_curl_request = false); bool addChain(const chain_t& chain, F32 timeout);
/** /**
* @brief Struct to associate a pipe with it's buffer io indexes. * @brief Struct to associate a pipe with it's buffer io indexes.
@@ -347,7 +346,7 @@ protected:
// basic member data // basic member data
bool mInit; bool mInit;
bool mEOS; bool mEOS;
bool mHasCurlRequest; bool mHasExpiration;
S32 mLock; S32 mLock;
LLFrameTimer mTimer; LLFrameTimer mTimer;
links_t::iterator mHead; links_t::iterator mHead;

View File

@@ -151,11 +151,11 @@ bool LLSDMessage::ResponderAdapter::listener(const LLSD& payload, bool success)
{ {
if (success) if (success)
{ {
mResponder->result(payload); mResponder->pubResult(payload);
} }
else else
{ {
mResponder->errorWithContent(payload["status"].asInteger(), payload["reason"], payload["content"]); mResponder->pubErrorWithContent(payload["status"].asInteger(), payload["reason"], payload["content"]);
} }
/*---------------- MUST BE LAST STATEMENT BEFORE RETURN ----------------*/ /*---------------- MUST BE LAST STATEMENT BEFORE RETURN ----------------*/

View File

@@ -1,255 +0,0 @@
/**
* @file llsdrpcclient.cpp
* @author Phoenix
* @date 2005-11-05
* @brief Implementation of the llsd client classes.
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llsdrpcclient.h"
#include "llbufferstream.h"
#include "llfasttimer.h"
#include "llfiltersd2xmlrpc.h"
#include "llmemtype.h"
#include "llpumpio.h"
#include "llsd.h"
#include "llsdserialize.h"
#include "llurlrequest.h"
/**
* String constants
*/
static std::string LLSDRPC_RESPONSE_NAME("response");
static std::string LLSDRPC_FAULT_NAME("fault");
/**
* LLSDRPCResponse
*/
LLSDRPCResponse::LLSDRPCResponse() :
mIsError(false),
mIsFault(false)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
}
// virtual
LLSDRPCResponse::~LLSDRPCResponse()
{
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
}
bool LLSDRPCResponse::extractResponse(const LLSD& sd)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
bool rv = true;
if(sd.has(LLSDRPC_RESPONSE_NAME))
{
mReturnValue = sd[LLSDRPC_RESPONSE_NAME];
mIsFault = false;
}
else if(sd.has(LLSDRPC_FAULT_NAME))
{
mReturnValue = sd[LLSDRPC_FAULT_NAME];
mIsFault = true;
}
else
{
mReturnValue.clear();
mIsError = true;
rv = false;
}
return rv;
}
static LLFastTimer::DeclareTimer FTM_SDRPC_RESPONSE("SDRPC Response");
// virtual
LLIOPipe::EStatus LLSDRPCResponse::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
LLFastTimer t(FTM_SDRPC_RESPONSE);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
if(mIsError)
{
error(pump);
}
else if(mIsFault)
{
fault(pump);
}
else
{
response(pump);
}
PUMP_DEBUG;
return STATUS_DONE;
}
/**
* LLSDRPCClient
*/
LLSDRPCClient::LLSDRPCClient() :
mState(STATE_NONE),
mQueue(EPBQ_PROCESS)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
}
// virtual
LLSDRPCClient::~LLSDRPCClient()
{
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
}
bool LLSDRPCClient::call(
const std::string& uri,
const std::string& method,
const LLSD& parameter,
LLSDRPCResponse* response,
EPassBackQueue queue)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
//llinfos << "RPC: " << uri << "." << method << "(" << *parameter << ")"
// << llendl;
if(method.empty() || !response)
{
return false;
}
mState = STATE_READY;
mURI.assign(uri);
std::stringstream req;
req << LLSDRPC_REQUEST_HEADER_1 << method
<< LLSDRPC_REQUEST_HEADER_2;
LLSDSerialize::toNotation(parameter, req);
req << LLSDRPC_REQUEST_FOOTER;
mRequest = req.str();
mQueue = queue;
mResponse = response;
return true;
}
bool LLSDRPCClient::call(
const std::string& uri,
const std::string& method,
const std::string& parameter,
LLSDRPCResponse* response,
EPassBackQueue queue)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
//llinfos << "RPC: " << uri << "." << method << "(" << parameter << ")"
// << llendl;
if(method.empty() || parameter.empty() || !response)
{
return false;
}
mState = STATE_READY;
mURI.assign(uri);
std::stringstream req;
req << LLSDRPC_REQUEST_HEADER_1 << method
<< LLSDRPC_REQUEST_HEADER_2 << parameter
<< LLSDRPC_REQUEST_FOOTER;
mRequest = req.str();
mQueue = queue;
mResponse = response;
return true;
}
static LLFastTimer::DeclareTimer FTM_PROCESS_SDRPC_CLIENT("SDRPC Client");
// virtual
LLIOPipe::EStatus LLSDRPCClient::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
LLFastTimer t(FTM_PROCESS_SDRPC_CLIENT);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_SD_CLIENT);
if((STATE_NONE == mState) || (!pump))
{
// You should have called the call() method already.
return STATUS_PRECONDITION_NOT_MET;
}
EStatus rv = STATUS_DONE;
switch(mState)
{
case STATE_READY:
{
PUMP_DEBUG;
// lldebugs << "LLSDRPCClient::process_impl STATE_READY" << llendl;
buffer->append(
channels.out(),
(U8*)mRequest.c_str(),
mRequest.length());
context[CONTEXT_DEST_URI_SD_LABEL] = mURI;
mState = STATE_WAITING_FOR_RESPONSE;
break;
}
case STATE_WAITING_FOR_RESPONSE:
{
PUMP_DEBUG;
// The input channel has the sd response in it.
//lldebugs << "LLSDRPCClient::process_impl STATE_WAITING_FOR_RESPONSE"
// << llendl;
LLBufferStream resp(channels, buffer.get());
LLSD sd;
LLSDSerialize::fromNotation(sd, resp, buffer->count(channels.in()));
LLSDRPCResponse* response = (LLSDRPCResponse*)mResponse.get();
if (!response)
{
mState = STATE_DONE;
break;
}
response->extractResponse(sd);
if(EPBQ_PROCESS == mQueue)
{
LLPumpIO::chain_t chain;
chain.push_back(mResponse);
pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS);
}
else
{
pump->respond(mResponse.get());
}
mState = STATE_DONE;
break;
}
case STATE_DONE:
default:
PUMP_DEBUG;
llinfos << "invalid state to process" << llendl;
rv = STATUS_ERROR;
break;
}
return rv;
}

View File

@@ -1,323 +0,0 @@
/**
* @file llsdrpcclient.h
* @author Phoenix
* @date 2005-11-05
* @brief Implementation and helpers for structure data RPC clients.
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLSDRPCCLIENT_H
#define LL_LLSDRPCCLIENT_H
/**
* This file declares classes to encapsulate a basic structured data
* remote procedure client.
*/
#include "llchainio.h"
#include "llfiltersd2xmlrpc.h"
#include "lliopipe.h"
#include "llurlrequest.h"
/**
* @class LLSDRPCClientResponse
* @brief Abstract base class to represent a response from an SD server.
*
* This is used as a base class for callbacks generated from an
* structured data remote procedure call. The
* <code>extractResponse</code> method will deal with the llsdrpc method
* call overhead, and keep track of what to call during the next call
* into <code>process</code>. If you use this as a base class, you
* need to implement <code>response</code>, <code>fault</code>, and
* <code>error</code> to do something useful. When in those methods,
* you can parse and utilize the mReturnValue member data.
*/
class LLSDRPCResponse : public LLIOPipe
{
public:
LLSDRPCResponse();
virtual ~LLSDRPCResponse();
/**
* @brief This method extracts the response out of the sd passed in
*
* Any appropriate data found in the sd passed in will be
* extracted and managed by this object - not copied or cloned. It
* will still be up to the caller to delete the pointer passed in.
* @param sd The raw structured data response from the remote server.
* @return Returns true if this was able to parse the structured data.
*/
bool extractResponse(const LLSD& sd);
protected:
/**
* @brief Method called when the response is ready.
*/
virtual bool response(LLPumpIO* pump) = 0;
/**
* @brief Method called when a fault is generated by the remote server.
*/
virtual bool fault(LLPumpIO* pump) = 0;
/**
* @brief Method called when there was an error
*/
virtual bool error(LLPumpIO* pump) = 0;
protected:
/* @name LLIOPipe virtual implementations
*/
//@{
/**
* @brief Process the data in buffer
*/
virtual EStatus process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump);
//@}
protected:
LLSD mReturnValue;
bool mIsError;
bool mIsFault;
};
/**
* @class LLSDRPCClient
* @brief Client class for a structured data remote procedure call.
*
* This class helps deal with making structured data calls to a remote
* server. You can visualize the calls as:
* <code>
* response = uri.method(parameter)
* </code>
* where you pass in everything to <code>call</code> and this class
* takes care of the rest of the details.
* In typical usage, you will derive a class from this class and
* provide an API more useful for the specific application at
* hand. For example, if you were writing a service to send an instant
* message, you could create an API for it to send the messsage, and
* that class would do the work of translating it into the method and
* parameter, find the destination, and invoke <code>call</call> with
* a useful implementation of LLSDRPCResponse passed in to handle the
* response from the network.
*/
class LLSDRPCClient : public LLIOPipe
{
public:
LLSDRPCClient();
virtual ~LLSDRPCClient();
/**
* @brief Enumeration for tracking which queue to process the
* response.
*/
enum EPassBackQueue
{
EPBQ_PROCESS,
EPBQ_CALLBACK,
};
/**
* @brief Call a method on a remote LLSDRPCServer
*
* @param uri The remote object to call, eg,
* http://localhost/usher. If you are using a factory with a fixed
* url, the uri passed in will probably be ignored.
* @param method The method to call on the remote object
* @param parameter The parameter to pass into the remote
* object. It is up to the caller to delete the value passed in.
* @param response The object which gets the response.
* @param queue Specifies to call the response on the process or
* callback queue.
* @return Returns true if this object will be able to make the RPC call.
*/
bool call(
const std::string& uri,
const std::string& method,
const LLSD& parameter,
LLSDRPCResponse* response,
EPassBackQueue queue);
/**
* @brief Call a method on a remote LLSDRPCServer
*
* @param uri The remote object to call, eg,
* http://localhost/usher. If you are using a factory with a fixed
* url, the uri passed in will probably be ignored.
* @param method The method to call on the remote object
* @param parameter The seriailized parameter to pass into the
* remote object.
* @param response The object which gets the response.
* @param queue Specifies to call the response on the process or
* callback queue.
* @return Returns true if this object will be able to make the RPC call.
*/
bool call(
const std::string& uri,
const std::string& method,
const std::string& parameter,
LLSDRPCResponse* response,
EPassBackQueue queue);
protected:
/**
* @brief Enumeration for tracking client state.
*/
enum EState
{
STATE_NONE,
STATE_READY,
STATE_WAITING_FOR_RESPONSE,
STATE_DONE
};
/* @name LLIOPipe virtual implementations
*/
//@{
/**
* @brief Process the data in buffer
*/
virtual EStatus process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump);
//@}
protected:
EState mState;
std::string mURI;
std::string mRequest;
EPassBackQueue mQueue;
LLIOPipe::ptr_t mResponse;
};
/**
* @class LLSDRPCClientFactory
* @brief Basic implementation for making an SD RPC client factory
*
* This class eases construction of a basic sd rpc client. Here is an
* example of it's use:
* <code>
* class LLUsefulService : public LLService { ... }
* LLService::registerCreator(
* "useful",
* LLService::creator_t(new LLSDRPCClientFactory<LLUsefulService>))
* </code>
*/
template<class Client>
class LLSDRPCClientFactory : public LLChainIOFactory
{
public:
LLSDRPCClientFactory() {}
LLSDRPCClientFactory(const std::string& fixed_url) : mURL(fixed_url) {}
virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const
{
lldebugs << "LLSDRPCClientFactory::build" << llendl;
LLURLRequest* http(new LLURLRequest(LLURLRequest::HTTP_POST));
if(!http->isValid())
{
llwarns << "Creating LLURLRequest failed." << llendl ;
delete http;
return false;
}
LLIOPipe::ptr_t service(new Client);
chain.push_back(service);
LLIOPipe::ptr_t http_pipe(http);
http->addHeader("Content-Type: text/llsd");
if(mURL.empty())
{
chain.push_back(LLIOPipe::ptr_t(new LLContextURLExtractor(http)));
}
else
{
http->setURL(mURL);
}
chain.push_back(http_pipe);
chain.push_back(service);
return true;
}
protected:
std::string mURL;
};
/**
* @class LLXMLSDRPCClientFactory
* @brief Basic implementation for making an XMLRPC to SD RPC client factory
*
* This class eases construction of a basic sd rpc client which uses
* xmlrpc as a serialization grammar. Here is an example of it's use:
* <code>
* class LLUsefulService : public LLService { ... }
* LLService::registerCreator(
* "useful",
* LLService::creator_t(new LLXMLSDRPCClientFactory<LLUsefulService>))
* </code>
*/
template<class Client>
class LLXMLSDRPCClientFactory : public LLChainIOFactory
{
public:
LLXMLSDRPCClientFactory() {}
LLXMLSDRPCClientFactory(const std::string& fixed_url) : mURL(fixed_url) {}
virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const
{
lldebugs << "LLXMLSDRPCClientFactory::build" << llendl;
LLURLRequest* http(new LLURLRequest(LLURLRequest::HTTP_POST));
if(!http->isValid())
{
llwarns << "Creating LLURLRequest failed." << llendl ;
delete http;
return false ;
}
LLIOPipe::ptr_t service(new Client);
chain.push_back(service);
LLIOPipe::ptr_t http_pipe(http);
http->addHeader("Content-Type: text/xml");
if(mURL.empty())
{
chain.push_back(LLIOPipe::ptr_t(new LLContextURLExtractor(http)));
}
else
{
http->setURL(mURL);
}
chain.push_back(LLIOPipe::ptr_t(new LLFilterSD2XMLRPCRequest(NULL)));
chain.push_back(http_pipe);
chain.push_back(LLIOPipe::ptr_t(new LLFilterXMLRPCResponse2LLSD));
chain.push_back(service);
return true;
}
protected:
std::string mURL;
};
#endif // LL_LLSDRPCCLIENT_H

View File

@@ -1,347 +0,0 @@
/**
* @file llsdrpcserver.cpp
* @author Phoenix
* @date 2005-10-11
* @brief Implementation of the LLSDRPCServer and related classes.
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "linden_common.h"
#include "llsdrpcserver.h"
#include "llbuffer.h"
#include "llbufferstream.h"
#include "llfasttimer.h"
#include "llmemtype.h"
#include "llpumpio.h"
#include "llsdserialize.h"
#include "llstl.h"
static const char FAULT_PART_1[] = "{'fault':{'code':i";
static const char FAULT_PART_2[] = ", 'description':'";
static const char FAULT_PART_3[] = "'}}";
static const char RESPONSE_PART_1[] = "{'response':";
static const char RESPONSE_PART_2[] = "}";
static const S32 FAULT_GENERIC = 1000;
static const S32 FAULT_METHOD_NOT_FOUND = 1001;
static const std::string LLSDRPC_METHOD_SD_NAME("method");
static const std::string LLSDRPC_PARAMETER_SD_NAME("parameter");
/**
* LLSDRPCServer
*/
LLSDRPCServer::LLSDRPCServer() :
mState(LLSDRPCServer::STATE_NONE),
mPump(NULL),
mLock(0)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER);
}
LLSDRPCServer::~LLSDRPCServer()
{
LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER);
std::for_each(
mMethods.begin(),
mMethods.end(),
llcompose1(
DeletePointerFunctor<LLSDRPCMethodCallBase>(),
llselect2nd<method_map_t::value_type>()));
std::for_each(
mCallbackMethods.begin(),
mCallbackMethods.end(),
llcompose1(
DeletePointerFunctor<LLSDRPCMethodCallBase>(),
llselect2nd<method_map_t::value_type>()));
}
// virtual
ESDRPCSStatus LLSDRPCServer::deferredResponse(
const LLChannelDescriptors& channels,
LLBufferArray* data) {
// subclass should provide a sane implementation
return ESDRPCS_DONE;
}
void LLSDRPCServer::clearLock()
{
if(mLock && mPump)
{
mPump->clearLock(mLock);
mPump = NULL;
mLock = 0;
}
}
static LLFastTimer::DeclareTimer FTM_PROCESS_SDRPC_SERVER("SDRPC Server");
// virtual
LLIOPipe::EStatus LLSDRPCServer::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
LLFastTimer t(FTM_PROCESS_SDRPC_SERVER);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER);
// lldebugs << "LLSDRPCServer::process_impl" << llendl;
// Once we have all the data, We need to read the sd on
// the the in channel, and respond on the out channel
if(!eos) return STATUS_BREAK;
if(!pump || !buffer) return STATUS_PRECONDITION_NOT_MET;
std::string method_name;
LLIOPipe::EStatus status = STATUS_DONE;
switch(mState)
{
case STATE_DEFERRED:
PUMP_DEBUG;
if(ESDRPCS_DONE != deferredResponse(channels, buffer.get()))
{
buildFault(
channels,
buffer.get(),
FAULT_GENERIC,
"deferred response failed.");
}
mState = STATE_DONE;
return STATUS_DONE;
case STATE_DONE:
// lldebugs << "STATE_DONE" << llendl;
break;
case STATE_CALLBACK:
// lldebugs << "STATE_CALLBACK" << llendl;
PUMP_DEBUG;
method_name = mRequest[LLSDRPC_METHOD_SD_NAME].asString();
if(!method_name.empty() && mRequest.has(LLSDRPC_PARAMETER_SD_NAME))
{
if(ESDRPCS_DONE != callbackMethod(
method_name,
mRequest[LLSDRPC_PARAMETER_SD_NAME],
channels,
buffer.get()))
{
buildFault(
channels,
buffer.get(),
FAULT_GENERIC,
"Callback method call failed.");
}
}
else
{
// this should never happen, since we should not be in
// this state unless we originally found a method and
// params during the first call to process.
buildFault(
channels,
buffer.get(),
FAULT_GENERIC,
"Invalid LLSDRPC sever state - callback without method.");
}
pump->clearLock(mLock);
mLock = 0;
mState = STATE_DONE;
break;
case STATE_NONE:
// lldebugs << "STATE_NONE" << llendl;
default:
{
// First time we got here - process the SD request, and call
// the method.
PUMP_DEBUG;
LLBufferStream istr(channels, buffer.get());
mRequest.clear();
LLSDSerialize::fromNotation(
mRequest,
istr,
buffer->count(channels.in()));
// { 'method':'...', 'parameter': ... }
method_name = mRequest[LLSDRPC_METHOD_SD_NAME].asString();
if(!method_name.empty() && mRequest.has(LLSDRPC_PARAMETER_SD_NAME))
{
ESDRPCSStatus rv = callMethod(
method_name,
mRequest[LLSDRPC_PARAMETER_SD_NAME],
channels,
buffer.get());
switch(rv)
{
case ESDRPCS_DEFERRED:
mPump = pump;
mLock = pump->setLock();
mState = STATE_DEFERRED;
status = STATUS_BREAK;
break;
case ESDRPCS_CALLBACK:
{
mState = STATE_CALLBACK;
LLPumpIO::LLLinkInfo link;
link.mPipe = LLIOPipe::ptr_t(this);
link.mChannels = channels;
LLPumpIO::links_t links;
links.push_back(link);
pump->respond(links, buffer, context);
mLock = pump->setLock();
status = STATUS_BREAK;
break;
}
case ESDRPCS_DONE:
mState = STATE_DONE;
break;
case ESDRPCS_ERROR:
default:
buildFault(
channels,
buffer.get(),
FAULT_GENERIC,
"Method call failed.");
break;
}
}
else
{
// send a fault
buildFault(
channels,
buffer.get(),
FAULT_GENERIC,
"Unable to find method and parameter in request.");
}
break;
}
}
PUMP_DEBUG;
return status;
}
// virtual
ESDRPCSStatus LLSDRPCServer::callMethod(
const std::string& method,
const LLSD& params,
const LLChannelDescriptors& channels,
LLBufferArray* response)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER);
// Try to find the method in the method table.
ESDRPCSStatus rv = ESDRPCS_DONE;
method_map_t::iterator it = mMethods.find(method);
if(it != mMethods.end())
{
rv = (*it).second->call(params, channels, response);
}
else
{
it = mCallbackMethods.find(method);
if(it == mCallbackMethods.end())
{
// method not found.
std::ostringstream message;
message << "rpc server unable to find method: " << method;
buildFault(
channels,
response,
FAULT_METHOD_NOT_FOUND,
message.str());
}
else
{
// we found it in the callback methods - tell the process
// to coordinate calling on the pump callback.
return ESDRPCS_CALLBACK;
}
}
return rv;
}
// virtual
ESDRPCSStatus LLSDRPCServer::callbackMethod(
const std::string& method,
const LLSD& params,
const LLChannelDescriptors& channels,
LLBufferArray* response)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER);
// Try to find the method in the callback method table.
ESDRPCSStatus rv = ESDRPCS_DONE;
method_map_t::iterator it = mCallbackMethods.find(method);
if(it != mCallbackMethods.end())
{
rv = (*it).second->call(params, channels, response);
}
else
{
std::ostringstream message;
message << "pcserver unable to find callback method: " << method;
buildFault(
channels,
response,
FAULT_METHOD_NOT_FOUND,
message.str());
}
return rv;
}
// static
void LLSDRPCServer::buildFault(
const LLChannelDescriptors& channels,
LLBufferArray* data,
S32 code,
const std::string& msg)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER);
LLBufferStream ostr(channels, data);
ostr << FAULT_PART_1 << code << FAULT_PART_2 << msg << FAULT_PART_3;
llinfos << "LLSDRPCServer::buildFault: " << code << ", " << msg << llendl;
}
// static
void LLSDRPCServer::buildResponse(
const LLChannelDescriptors& channels,
LLBufferArray* data,
const LLSD& response)
{
LLMemType m1(LLMemType::MTYPE_IO_SD_SERVER);
LLBufferStream ostr(channels, data);
ostr << RESPONSE_PART_1;
LLSDSerialize::toNotation(response, ostr);
ostr << RESPONSE_PART_2;
#if LL_DEBUG
std::ostringstream debug_ostr;
debug_ostr << "LLSDRPCServer::buildResponse: ";
LLSDSerialize::toNotation(response, debug_ostr);
llinfos << debug_ostr.str() << llendl;
#endif
}

View File

@@ -1,360 +0,0 @@
/**
* @file llsdrpcserver.h
* @author Phoenix
* @date 2005-10-11
* @brief Declaration of the structured data remote procedure call server.
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLSDRPCSERVER_H
#define LL_LLSDRPCSERVER_H
/**
* I've set this up to be pretty easy to use when you want to make a
* structured data rpc server which responds to methods by
* name. Derive a class from the LLSDRPCServer, and during
* construction (or initialization if you have the luxury) map method
* names to pointers to member functions. This will look a lot like:
*
* <code>
* class LLMessageAgents : public LLSDRPCServer {<br>
* public:<br>
* typedef LLSDRPCServer<LLUsher> mem_fn_t;<br>
* LLMessageAgents() {<br>
* mMethods["message"] = new mem_fn_t(this, &LLMessageAgents::rpc_IM);<br>
* mMethods["alert"] = new mem_fn_t(this, &LLMessageAgents::rpc_Alrt);<br>
* }<br>
* protected:<br>
* rpc_IM(const LLSD& params,
* const LLChannelDescriptors& channels,
* LLBufferArray* data)
* {...}<br>
* rpc_Alert(const LLSD& params,
* const LLChannelDescriptors& channels,
* LLBufferArray* data)
* {...}<br>
* };<br>
* </code>
*
* The params are an array where each element in the array is a single
* parameter in the call.
*
* It is up to you to pack a valid serialized llsd response into the
* data object passed into the method, but you can use the helper
* methods below to help.
*/
#include <map>
#include "lliopipe.h"
#include "lliohttpserver.h"
#include "llfiltersd2xmlrpc.h"
class LLSD;
/**
* @brief Enumeration for specifying server method call status. This
* enumeration controls how the server class will manage the pump
* process/callback mechanism.
*/
enum ESDRPCSStatus
{
// The call went ok, but the response is not yet ready. The
// method will arrange for the clearLock() call to be made at
// a later date, after which, once the chain is being pumped
// again, deferredResponse() will be called to gather the result
ESDRPCS_DEFERRED,
// The LLSDRPCServer would like to handle the method on the
// callback queue of the pump.
ESDRPCS_CALLBACK,
// The method call finished and generated output.
ESDRPCS_DONE,
// Method failed for some unspecified reason - you should avoid
// this. A generic fault will be sent to the output.
ESDRPCS_ERROR,
ESDRPCS_COUNT,
};
/**
* @class LLSDRPCMethodCallBase
* @brief Base class for calling a member function in an sd rpcserver
* implementation.
*/
class LLSDRPCMethodCallBase
{
public:
LLSDRPCMethodCallBase() {}
virtual ~LLSDRPCMethodCallBase() {}
virtual ESDRPCSStatus call(
const LLSD& params,
const LLChannelDescriptors& channels,
LLBufferArray* response) = 0;
protected:
};
/**
* @class LLSDRPCMethodCall
* @brief Class which implements member function calls.
*/
template<class Server>
class LLSDRPCMethodCall : public LLSDRPCMethodCallBase
{
public:
typedef ESDRPCSStatus (Server::*mem_fn)(
const LLSD& params,
const LLChannelDescriptors& channels,
LLBufferArray* data);
LLSDRPCMethodCall(Server* s, mem_fn fn) :
mServer(s),
mMemFn(fn)
{
}
virtual ~LLSDRPCMethodCall() {}
virtual ESDRPCSStatus call(
const LLSD& params,
const LLChannelDescriptors& channels,
LLBufferArray* data)
{
return (*mServer.*mMemFn)(params, channels, data);
}
protected:
Server* mServer;
mem_fn mMemFn;
//bool (Server::*mMemFn)(const LLSD& params, LLBufferArray& data);
};
/**
* @class LLSDRPCServer
* @brief Basic implementation of a structure data rpc server
*
* The rpc server is also designed to appropriately straddle the pump
* <code>process()</code> and <code>callback()</code> to specify which
* thread you want to work on when handling a method call. The
* <code>mMethods</code> methods are called from
* <code>process()</code>, while the <code>mCallbackMethods</code> are
* called when a pump is in a <code>callback()</code> cycle.
*/
class LLSDRPCServer : public LLIOPipe
{
public:
LLSDRPCServer();
virtual ~LLSDRPCServer();
/**
* enumeration for generic fault codes
*/
enum
{
FAULT_BAD_REQUEST = 2000,
FAULT_NO_RESPONSE = 2001,
};
/**
* @brief Call this method to return an rpc fault.
*
* @param channel The channel for output on the data buffer
* @param data buffer which will recieve the final output
* @param code The fault code
* @param msg The fault message
*/
static void buildFault(
const LLChannelDescriptors& channels,
LLBufferArray* data,
S32 code,
const std::string& msg);
/**
* @brief Call this method to build an rpc response.
*
* @param channel The channel for output on the data buffer
* @param data buffer which will recieve the final output
* @param response The return value from the method call
*/
static void buildResponse(
const LLChannelDescriptors& channels,
LLBufferArray* data,
const LLSD& response);
protected:
/* @name LLIOPipe virtual implementations
*/
//@{
/**
* @brief Process the data in buffer
*/
virtual EStatus process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump);
//@}
protected:
/**
* @brief Enumeration to track the state of the rpc server instance
*/
enum EState
{
STATE_NONE,
STATE_CALLBACK,
STATE_DEFERRED,
STATE_DONE
};
/**
* @brief This method is called when an http post comes in.
*
* The default behavior is to look at the method name, look up the
* method in the method table, and call it. If the method is not
* found, this function will build a fault response. You can
* implement your own version of this function if you want to hard
* wire some behavior or optimize things a bit.
* @param method The method name being called
* @param params The parameters
* @param channel The channel for output on the data buffer
* @param data The http data
* @return Returns the status of the method call, done/deferred/etc
*/
virtual ESDRPCSStatus callMethod(
const std::string& method,
const LLSD& params,
const LLChannelDescriptors& channels,
LLBufferArray* data);
/**
* @brief This method is called when a pump callback is processed.
*
* The default behavior is to look at the method name, look up the
* method in the callback method table, and call it. If the method
* is not found, this function will build a fault response. You
* can implement your own version of this function if you want to
* hard wire some behavior or optimize things a bit.
* @param method The method name being called
* @param params The parameters
* @param channel The channel for output on the data buffer
* @param data The http data
* @return Returns the status of the method call, done/deferred/etc
*/
virtual ESDRPCSStatus callbackMethod(
const std::string& method,
const LLSD& params,
const LLChannelDescriptors& channels,
LLBufferArray* data);
/**
* @brief Called after a deferred service is unlocked
*
* If a method returns ESDRPCS_DEFERRED, then the service chain
* will be locked and not processed until some other system calls
* clearLock() on the service instance again. At that point,
* once the pump starts processing the chain again, this method
* will be called so the service can output the final result
* into the buffers.
*/
virtual ESDRPCSStatus deferredResponse(
const LLChannelDescriptors& channels,
LLBufferArray* data);
// donovan put this public here 7/27/06
public:
/**
* @brief unlock a service that as ESDRPCS_DEFERRED
*/
void clearLock();
protected:
EState mState;
LLSD mRequest;
LLPumpIO* mPump;
S32 mLock;
typedef std::map<std::string, LLSDRPCMethodCallBase*> method_map_t;
method_map_t mMethods;
method_map_t mCallbackMethods;
};
/**
* @name Helper Templates for making LLHTTPNodes
*
* These templates help in creating nodes for handing a service from
* either SDRPC or XMLRPC, given a single implementation of LLSDRPCServer.
*
* To use it:
* \code
* class LLUsefulServer : public LLSDRPCServer { ... }
*
* LLHTTPNode& root = LLCreateHTTPWireServer(...);
* root.addNode("llsdrpc/useful", new LLSDRPCNode<LLUsefulServer>);
* root.addNode("xmlrpc/useful", new LLXMLRPCNode<LLUsefulServer>);
* \endcode
*/
//@{
template<class Server>
class LLSDRPCServerFactory : public LLChainIOFactory
{
public:
virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const
{
lldebugs << "LLXMLSDRPCServerFactory::build" << llendl;
chain.push_back(LLIOPipe::ptr_t(new Server));
return true;
}
};
template<class Server>
class LLSDRPCNode : public LLHTTPNodeForFactory<
LLSDRPCServerFactory<Server> >
{
};
template<class Server>
class LLXMLRPCServerFactory : public LLChainIOFactory
{
public:
virtual bool build(LLPumpIO::chain_t& chain, LLSD context) const
{
lldebugs << "LLXMLSDRPCServerFactory::build" << llendl;
chain.push_back(LLIOPipe::ptr_t(new LLFilterXMLRPCRequest2LLSD));
chain.push_back(LLIOPipe::ptr_t(new Server));
chain.push_back(LLIOPipe::ptr_t(new LLFilterSD2XMLRPCResponse));
return true;
}
};
template<class Server>
class LLXMLRPCNode : public LLHTTPNodeForFactory<
LLXMLRPCServerFactory<Server> >
{
};
//@}
#endif // LL_LLSDRPCSERVER_H

View File

@@ -29,6 +29,10 @@
#include "linden_common.h" #include "linden_common.h"
#include "llurlrequest.h" #include "llurlrequest.h"
#ifdef CWDEBUG
#include <libcwd/buf2str.h>
#endif
#include <algorithm> #include <algorithm>
#include <openssl/x509_vfy.h> #include <openssl/x509_vfy.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
@@ -48,13 +52,10 @@ static const U32 HTTP_STATUS_PIPE_ERROR = 499;
/** /**
* String constants * String constants
*/ */
const std::string CONTEXT_DEST_URI_SD_LABEL("dest_uri");
const std::string CONTEXT_TRANSFERED_BYTES("transfered_bytes"); const std::string CONTEXT_TRANSFERED_BYTES("transfered_bytes");
static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user); static size_t headerCallback(char* data, size_t size, size_t nmemb, void* user);
/** /**
* class LLURLRequestDetail * class LLURLRequestDetail
@@ -65,7 +66,7 @@ public:
LLURLRequestDetail(); LLURLRequestDetail();
~LLURLRequestDetail(); ~LLURLRequestDetail();
std::string mURL; std::string mURL;
LLCurlEasyRequest* mCurlRequest; AICurlEasyRequest mCurlEasyRequest;
LLIOPipe::buffer_ptr_t mResponseBuffer; LLIOPipe::buffer_ptr_t mResponseBuffer;
LLChannelDescriptors mChannels; LLChannelDescriptors mChannels;
U8* mLastRead; U8* mLastRead;
@@ -76,36 +77,28 @@ public:
}; };
LLURLRequestDetail::LLURLRequestDetail() : LLURLRequestDetail::LLURLRequestDetail() :
mCurlRequest(NULL), mCurlEasyRequest(false),
mLastRead(NULL), mLastRead(NULL),
mBodyLimit(0), mBodyLimit(0),
mByteAccumulator(0), mByteAccumulator(0),
mIsBodyLimitSet(false), mIsBodyLimitSet(false),
mSSLVerifyCallback(NULL) mSSLVerifyCallback(NULL)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mCurlRequest = new LLCurlEasyRequest();
if(!mCurlRequest->isValid()) //failed.
{
delete mCurlRequest ;
mCurlRequest = NULL ;
}
} }
LLURLRequestDetail::~LLURLRequestDetail() LLURLRequestDetail::~LLURLRequestDetail()
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
delete mCurlRequest;
mLastRead = NULL; mLastRead = NULL;
} }
void LLURLRequest::setSSLVerifyCallback(SSLCertVerifyCallback callback, void *param) void LLURLRequest::setSSLVerifyCallback(SSLCertVerifyCallback callback, void *param)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mDetail->mSSLVerifyCallback = callback; mDetail->mSSLVerifyCallback = callback;
mDetail->mCurlRequest->setSSLCtxCallback(LLURLRequest::_sslCtxCallback, (void *)this); AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
mDetail->mCurlRequest->setopt(CURLOPT_SSL_VERIFYPEER, true); curlEasyRequest_w->setSSLCtxCallback(LLURLRequest::_sslCtxCallback, (void *)this);
mDetail->mCurlRequest->setopt(CURLOPT_SSL_VERIFYHOST, 2); curlEasyRequest_w->setopt(CURLOPT_SSL_VERIFYPEER, true);
curlEasyRequest_w->setopt(CURLOPT_SSL_VERIFYHOST, 2);
} }
@@ -159,6 +152,7 @@ LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action) :
mAction(action) mAction(action)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
// This might throw AICurlNoEasyHandle.
initialize(); initialize();
} }
@@ -168,6 +162,7 @@ LLURLRequest::LLURLRequest(
mAction(action) mAction(action)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
// This might throw AICurlNoEasyHandle.
initialize(); initialize();
setURL(url); setURL(url);
} }
@@ -175,13 +170,16 @@ LLURLRequest::LLURLRequest(
LLURLRequest::~LLURLRequest() LLURLRequest::~LLURLRequest()
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
{
AICurlEasyRequest_wat curl_easy_request_w(*mDetail->mCurlEasyRequest);
curl_easy_request_w->revokeCallbacks();
curl_easy_request_w->send_events_to(NULL);
}
delete mDetail; delete mDetail;
mDetail = NULL ;
} }
void LLURLRequest::setURL(const std::string& url) void LLURLRequest::setURL(const std::string& url)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mDetail->mURL = url; mDetail->mURL = url;
} }
@@ -193,7 +191,8 @@ std::string LLURLRequest::getURL() const
void LLURLRequest::addHeader(const char* header) void LLURLRequest::addHeader(const char* header)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mDetail->mCurlRequest->slist_append(header); AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
curlEasyRequest_w->addHeader(header);
} }
void LLURLRequest::setBodyLimit(U32 size) void LLURLRequest::setBodyLimit(U32 size)
@@ -206,7 +205,8 @@ void LLURLRequest::setCallback(LLURLRequestComplete* callback)
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mCompletionCallback = callback; mCompletionCallback = callback;
mDetail->mCurlRequest->setHeaderCallback(&headerCallback, (void*)callback); AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
curlEasyRequest_w->setHeaderCallback(&headerCallback, (void*)callback);
} }
// Added to mitigate the effect of libcurl looking // Added to mitigate the effect of libcurl looking
@@ -242,30 +242,39 @@ void LLURLRequest::useProxy(bool use_proxy)
lldebugs << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = \"" << env_proxy << "\"" << llendl; lldebugs << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = \"" << env_proxy << "\"" << llendl;
if (use_proxy) AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
{ curlEasyRequest_w->setoptString(CURLOPT_PROXY, use_proxy ? env_proxy : std::string(""));
mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, env_proxy);
}
else
{
mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, "");
}
} }
void LLURLRequest::useProxy(const std::string &proxy) void LLURLRequest::useProxy(const std::string &proxy)
{ {
mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, proxy); AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
curlEasyRequest_w->setoptString(CURLOPT_PROXY, proxy);
} }
void LLURLRequest::allowCookies() void LLURLRequest::allowCookies()
{ {
mDetail->mCurlRequest->setoptString(CURLOPT_COOKIEFILE, ""); AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
curlEasyRequest_w->setoptString(CURLOPT_COOKIEFILE, "");
} }
//virtual //virtual
bool LLURLRequest::isValid() bool LLURLRequest::hasExpiration(void) const
{ {
return mDetail->mCurlRequest && mDetail->mCurlRequest->isValid(); // Currently, this ALWAYS returns false -- because only AICurlEasyRequestStateMachine uses buffered
// AICurlEasyRequest objects, and LLURLRequest uses (unbuffered) AICurlEasyRequest directly, which
// have no expiration facility.
return mDetail->mCurlEasyRequest.isBuffered();
}
//virtual
bool LLURLRequest::hasNotExpired(void) const
{
if (!mDetail->mCurlEasyRequest.isBuffered())
return true;
AICurlEasyRequest_wat buffered_easy_request_w(*mDetail->mCurlEasyRequest);
AICurlResponderBuffer_wat buffer_w(*mDetail->mCurlEasyRequest);
return buffer_w->isValid();
} }
// virtual // virtual
@@ -273,10 +282,24 @@ LLIOPipe::EStatus LLURLRequest::handleError(
LLIOPipe::EStatus status, LLIOPipe::EStatus status,
LLPumpIO* pump) LLPumpIO* pump)
{ {
DoutEntering(dc::curl, "LLURLRequest::handleError(" << LLIOPipe::lookupStatusString(status) << ", " << (void*)pump << ")");
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
if(!isValid()) if (LL_LIKELY(!mDetail->mCurlEasyRequest.isBuffered())) // Currently always true.
{ {
// The last reference will be deleted when the pump that this chain belongs to
// is removed from the running chains vector, upon returning from this function.
// This keeps the CurlEasyRequest object alive until the curl thread cleanly removed it.
Dout(dc::curl, "Calling mDetail->mCurlEasyRequest.removeRequest()");
mDetail->mCurlEasyRequest.removeRequest();
}
else if (!hasNotExpired())
{
// The buffered version has it's own time out handling, and that already expired,
// so we can ignore the expiration of this timer (currently never happens).
// I left it here because it's what LL did (in the form if (!isValid() ...),
// and it would be relevant if this characteristic of mDetail->mCurlEasyRequest
// would change. --Aleric
return STATUS_EXPIRED ; return STATUS_EXPIRED ;
} }
@@ -294,6 +317,19 @@ LLIOPipe::EStatus LLURLRequest::handleError(
return status; return status;
} }
void LLURLRequest::added_to_multi_handle(AICurlEasyRequest_wat&)
{
}
void LLURLRequest::finished(AICurlEasyRequest_wat&)
{
}
void LLURLRequest::removed_from_multi_handle(AICurlEasyRequest_wat&)
{
mRemoved = true;
}
static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST("URL Request"); static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST("URL Request");
// virtual // virtual
@@ -310,7 +346,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
//llinfos << "LLURLRequest::process_impl()" << llendl; //llinfos << "LLURLRequest::process_impl()" << llendl;
if (!buffer) return STATUS_ERROR; if (!buffer) return STATUS_ERROR;
// we're still waiting or prcessing, check how many // we're still waiting or processing, check how many
// bytes we have accumulated. // bytes we have accumulated.
const S32 MIN_ACCUMULATION = 100000; const S32 MIN_ACCUMULATION = 100000;
if(pump && (mDetail->mByteAccumulator > MIN_ACCUMULATION)) if(pump && (mDetail->mByteAccumulator > MIN_ACCUMULATION))
@@ -354,43 +390,35 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
{ {
return STATUS_ERROR; return STATUS_ERROR;
} }
mRemoved = false;
mState = STATE_WAITING_FOR_RESPONSE; mState = STATE_WAITING_FOR_RESPONSE;
mDetail->mCurlEasyRequest.addRequest(); // Add easy handle to multi handle.
// *FIX: Maybe we should just go to the next state now...
return STATUS_BREAK; return STATUS_BREAK;
} }
case STATE_WAITING_FOR_RESPONSE: case STATE_WAITING_FOR_RESPONSE:
case STATE_PROCESSING_RESPONSE: case STATE_PROCESSING_RESPONSE:
{ {
PUMP_DEBUG; if (!mRemoved) // Not removed from multi handle yet?
LLIOPipe::EStatus status = STATUS_BREAK;
static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform");
{ {
LLFastTimer t(FTM_URL_PERFORM); // Easy handle is still being processed.
if(!mDetail->mCurlRequest->wait()) return STATUS_BREAK;
{
return status ;
}
} }
// Curl thread finished with this easy handle.
mState = STATE_CURL_FINISHED;
}
case STATE_CURL_FINISHED:
{
PUMP_DEBUG;
LLIOPipe::EStatus status = STATUS_NO_CONNECTION; // Catch-all failure code.
while(1) // Left braces in order not to change indentation.
{ {
CURLcode result; CURLcode result;
static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result"); static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result");
bool newmsg = false; AICurlEasyRequest_wat(*mDetail->mCurlEasyRequest)->getResult(&result);
{
LLFastTimer t(FTM_PROCESS_URL_REQUEST_GET_RESULT);
newmsg = mDetail->mCurlRequest->getResult(&result);
}
if(!newmsg)
{
// keep processing
break;
}
mState = STATE_HAVE_RESPONSE; mState = STATE_HAVE_RESPONSE;
context[CONTEXT_REQUEST][CONTEXT_TRANSFERED_BYTES] = mRequestTransferedBytes; context[CONTEXT_REQUEST][CONTEXT_TRANSFERED_BYTES] = mRequestTransferedBytes;
@@ -423,6 +451,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
} }
mCompletionCallback = NULL; mCompletionCallback = NULL;
} }
status = STATUS_BREAK; // This is what the old code returned. Does it make sense?
break; break;
case CURLE_FAILED_INIT: case CURLE_FAILED_INIT:
case CURLE_COULDNT_CONNECT: case CURLE_COULDNT_CONNECT:
@@ -464,16 +493,15 @@ void LLURLRequest::initialize()
{ {
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
mState = STATE_INITIALIZED; mState = STATE_INITIALIZED;
// This might throw AICurlNoEasyHandle.
mDetail = new LLURLRequestDetail; mDetail = new LLURLRequestDetail;
if(!isValid())
{ {
return ; AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
curlEasyRequest_w->setWriteCallback(&downCallback, (void*)this);
curlEasyRequest_w->setReadCallback(&upCallback, (void*)this);
} }
mDetail->mCurlRequest->setopt(CURLOPT_NOSIGNAL, 1);
mDetail->mCurlRequest->setWriteCallback(&downCallback, (void*)this);
mDetail->mCurlRequest->setReadCallback(&upCallback, (void*)this);
mRequestTransferedBytes = 0; mRequestTransferedBytes = 0;
mResponseTransferedBytes = 0; mResponseTransferedBytes = 0;
} }
@@ -488,70 +516,74 @@ bool LLURLRequest::configure()
S32 bytes = mDetail->mResponseBuffer->countAfter( S32 bytes = mDetail->mResponseBuffer->countAfter(
mDetail->mChannels.in(), mDetail->mChannels.in(),
NULL); NULL);
switch(mAction)
{ {
case HTTP_HEAD: AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
mDetail->mCurlRequest->setopt(CURLOPT_HEADER, 1); switch(mAction)
mDetail->mCurlRequest->setopt(CURLOPT_NOBODY, 1); {
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1); case HTTP_HEAD:
rv = true; curlEasyRequest_w->setopt(CURLOPT_HEADER, 1);
break; curlEasyRequest_w->setopt(CURLOPT_NOBODY, 1);
case HTTP_GET: curlEasyRequest_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
mDetail->mCurlRequest->setopt(CURLOPT_HTTPGET, 1); rv = true;
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1); break;
case HTTP_GET:
curlEasyRequest_w->setopt(CURLOPT_HTTPGET, 1);
curlEasyRequest_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
// Set Accept-Encoding to allow response compression // Set Accept-Encoding to allow response compression
mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, ""); curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
rv = true; rv = true;
break; break;
case HTTP_PUT: case HTTP_PUT:
// Disable the expect http 1.1 extension. POST and PUT default // Disable the expect http 1.1 extension. POST and PUT default
// to turning this on, and I am not too sure what it means. // to turning this on, and I am not too sure what it means.
addHeader("Expect:"); addHeader("Expect:");
mDetail->mCurlRequest->setopt(CURLOPT_UPLOAD, 1); curlEasyRequest_w->setopt(CURLOPT_UPLOAD, 1);
mDetail->mCurlRequest->setopt(CURLOPT_INFILESIZE, bytes); curlEasyRequest_w->setopt(CURLOPT_INFILESIZE, bytes);
rv = true; rv = true;
break; break;
case HTTP_POST: case HTTP_POST:
// Disable the expect http 1.1 extension. POST and PUT default // Disable the expect http 1.1 extension. POST and PUT default
// to turning this on, and I am not too sure what it means. // to turning this on, and I am not too sure what it means.
addHeader("Expect:"); addHeader("Expect:");
// Disable the content type http header. // Disable the content type http header.
// *FIX: what should it be? // *FIX: what should it be?
addHeader("Content-Type:"); addHeader("Content-Type:");
// Set the handle for an http post // Set the handle for an http post
mDetail->mCurlRequest->setPost(NULL, bytes); curlEasyRequest_w->setPost(NULL, bytes);
// Set Accept-Encoding to allow response compression // Set Accept-Encoding to allow response compression
mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, ""); curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
rv = true; rv = true;
break; break;
case HTTP_DELETE: case HTTP_DELETE:
// Set the handle for an http post // Set the handle for an http post
mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "DELETE"); curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "DELETE");
rv = true; rv = true;
break; break;
case HTTP_MOVE: case HTTP_MOVE:
// Set the handle for an http post // Set the handle for an http post
mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE"); curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE");
// *NOTE: should we check for the Destination header? // *NOTE: should we check for the Destination header?
rv = true; rv = true;
break; break;
default: default:
llwarns << "Unhandled URLRequest action: " << mAction << llendl; llwarns << "Unhandled URLRequest action: " << mAction << llendl;
break; break;
} }
if(rv) if(rv)
{ {
mDetail->mCurlRequest->sendRequest(mDetail->mURL); curlEasyRequest_w->finalizeRequest(mDetail->mURL);
curlEasyRequest_w->send_events_to(this);
}
} }
return rv; return rv;
} }
@@ -615,9 +647,8 @@ size_t LLURLRequest::upCallback(
return bytes; return bytes;
} }
static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user) static size_t headerCallback(char* header_line, size_t size, size_t nmemb, void* user)
{ {
const char* header_line = (const char*)data;
size_t header_len = size * nmemb; size_t header_len = size * nmemb;
LLURLRequestComplete* complete = (LLURLRequestComplete*)user; LLURLRequestComplete* complete = (LLURLRequestComplete*)user;
@@ -683,42 +714,6 @@ static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user)
return header_len; return header_len;
} }
static LLFastTimer::DeclareTimer FTM_PROCESS_URL_EXTRACTOR("URL Extractor");
/**
* LLContextURLExtractor
*/
// virtual
LLIOPipe::EStatus LLContextURLExtractor::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
LLFastTimer t(FTM_PROCESS_URL_EXTRACTOR);
PUMP_DEBUG;
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
// The destination host is in the context.
if(context.isUndefined() || !mRequest)
{
return STATUS_PRECONDITION_NOT_MET;
}
// copy in to out, since this just extract the URL and does not
// actually change the data.
LLChangeChannel change(channels.in(), channels.out());
std::for_each(buffer->beginSegment(), buffer->endSegment(), change);
// find the context url
if(context.has(CONTEXT_DEST_URI_SD_LABEL))
{
mRequest->setURL(context[CONTEXT_DEST_URI_SD_LABEL].asString());
return STATUS_DONE;
}
return STATUS_ERROR;
}
/** /**
* LLURLRequestComplete * LLURLRequestComplete
*/ */

View File

@@ -42,7 +42,6 @@
extern const std::string CONTEXT_REQUEST; extern const std::string CONTEXT_REQUEST;
extern const std::string CONTEXT_DEST_URI_SD_LABEL;
extern const std::string CONTEXT_RESPONSE; extern const std::string CONTEXT_RESPONSE;
extern const std::string CONTEXT_TRANSFERED_BYTES; extern const std::string CONTEXT_TRANSFERED_BYTES;
@@ -66,7 +65,7 @@ typedef struct x509_store_ctx_st X509_STORE_CTX;
* worth the time and effort to eventually port this to a raw client * worth the time and effort to eventually port this to a raw client
* socket. * socket.
*/ */
class LLURLRequest : public LLIOPipe class LLURLRequest : public LLIOPipe, protected AICurlEasyHandleEvents
{ {
LOG_CLASS(LLURLRequest); LOG_CLASS(LLURLRequest);
public: public:
@@ -190,7 +189,8 @@ public:
*/ */
void allowCookies(); void allowCookies();
/*virtual*/ bool isValid() ; /*virtual*/ bool hasExpiration(void) const;
/*virtual*/ bool hasNotExpired(void) const;
public: public:
/** /**
@@ -217,6 +217,7 @@ protected:
STATE_INITIALIZED, STATE_INITIALIZED,
STATE_WAITING_FOR_RESPONSE, STATE_WAITING_FOR_RESPONSE,
STATE_PROCESSING_RESPONSE, STATE_PROCESSING_RESPONSE,
STATE_CURL_FINISHED,
STATE_HAVE_RESPONSE, STATE_HAVE_RESPONSE,
}; };
EState mState; EState mState;
@@ -228,6 +229,14 @@ protected:
static CURLcode _sslCtxCallback(CURL * curl, void *sslctx, void *param); static CURLcode _sslCtxCallback(CURL * curl, void *sslctx, void *param);
// mRemoved is used instead of changing mState directly, because I'm not convinced the latter is atomic.
// Set to false before adding curl request and then only tested.
// Reset in removed_from_multi_handle (by another thread), this is thread-safe.
bool mRemoved;
/*virtual*/ void added_to_multi_handle(AICurlEasyRequest_wat&);
/*virtual*/ void finished(AICurlEasyRequest_wat&);
/*virtual*/ void removed_from_multi_handle(AICurlEasyRequest_wat&);
private: private:
/** /**
* @brief Initialize the object. Called during construction. * @brief Initialize the object. Called during construction.
@@ -266,42 +275,6 @@ private:
LLURLRequest(const LLURLRequest&); LLURLRequest(const LLURLRequest&);
}; };
/**
* @class LLContextURLExtractor
* @brief This class unpacks the url out of a agent usher service so
* it can be packed into a LLURLRequest object.
* @see LLIOPipe
*
* This class assumes that the context is a map that contains an entry
* named CONTEXT_DEST_URI_SD_LABEL.
*/
class LLContextURLExtractor : public LLIOPipe
{
public:
LLContextURLExtractor(LLURLRequest* req) : mRequest(req) {}
~LLContextURLExtractor() {}
protected:
/* @name LLIOPipe virtual implementations
*/
//@{
/**
* @brief Process the data in buffer
*/
virtual EStatus process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump);
//@}
protected:
LLURLRequest* mRequest;
};
/** /**
* @class LLURLRequestComplete * @class LLURLRequestComplete
* @brief Class which can optionally be used with an LLURLRequest to * @brief Class which can optionally be used with an LLURLRequest to
@@ -374,11 +347,4 @@ protected:
EStatus mRequestStatus; EStatus mRequestStatus;
}; };
/**
* External constants
*/
extern const std::string CONTEXT_DEST_URI_SD_LABEL;
#endif // LL_LLURLREQUEST_H #endif // LL_LLURLREQUEST_H

View File

@@ -55,7 +55,6 @@ set_target_properties(SLPlugin
) )
target_link_libraries(SLPlugin target_link_libraries(SLPlugin
${GOOGLE_PERFTOOLS_LIBRARIES}
${LLPLUGIN_LIBRARIES} ${LLPLUGIN_LIBRARIES}
${LLMESSAGE_LIBRARIES} ${LLMESSAGE_LIBRARIES}
${LLCOMMON_LIBRARIES} ${LLCOMMON_LIBRARIES}
@@ -82,11 +81,4 @@ if (DARWIN)
) )
endif (DARWIN) endif (DARWIN)
if (WINDOWS)
set_target_properties(SLPlugin
PROPERTIES
LINK_FLAGS "${GOOGLE_PERFTOOLS_LINKER_FLAGS}"
)
endif (WINDOWS)
#ll_deploy_sharedlibs_command(SLPlugin) #ll_deploy_sharedlibs_command(SLPlugin)

View File

@@ -435,11 +435,7 @@ LLGLManager::LLGLManager() :
mHasPointParameters(FALSE), mHasPointParameters(FALSE),
mHasDrawBuffers(FALSE), mHasDrawBuffers(FALSE),
mHasTextureRectangle(FALSE), mHasTextureRectangle(FALSE),
mHasTextureMultisample(FALSE),
mHasTransformFeedback(FALSE), mHasTransformFeedback(FALSE),
mMaxSampleMaskWords(0),
mMaxColorTextureSamples(0),
mMaxDepthTextureSamples(0),
mMaxIntegerSamples(0), mMaxIntegerSamples(0),
mHasAnisotropic(FALSE), mHasAnisotropic(FALSE),
@@ -732,12 +728,10 @@ bool LLGLManager::initGL()
stop_glerror(); stop_glerror();
if (mHasTextureMultisample) if (mHasFramebufferMultisample)
{ {
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &mMaxColorTextureSamples);
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &mMaxDepthTextureSamples);
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples); glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples);
glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &mMaxSampleMaskWords); glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
} }
stop_glerror(); stop_glerror();
@@ -749,24 +743,12 @@ bool LLGLManager::initGL()
} }
#endif #endif
stop_glerror(); stop_glerror();
mHasTextureMultisample = FALSE;
#if LL_WINDOWS
if (mIsATI)
{ //using multisample textures on ATI results in black screen for some reason
mHasTextureMultisample = FALSE;
}
#endif
if (mIsIntel && mGLVersion <= 3.f) if (mIsIntel && mGLVersion <= 3.f)
{ //never try to use framebuffer objects on older intel drivers (crashy) { //never try to use framebuffer objects on older intel drivers (crashy)
mHasFramebufferObject = FALSE; mHasFramebufferObject = FALSE;
} }
if (mHasFramebufferObject)
{
glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
}
stop_glerror(); stop_glerror();
setToDebugGPU(); setToDebugGPU();
@@ -847,14 +829,6 @@ std::string LLGLManager::getRawGLString()
return gl_string; return gl_string;
} }
U32 LLGLManager::getNumFBOFSAASamples(U32 samples)
{
samples = llmin(samples, (U32) mMaxColorTextureSamples);
samples = llmin(samples, (U32) mMaxDepthTextureSamples);
samples = llmin(samples, (U32) 4);
return samples;
}
void LLGLManager::shutdownGL() void LLGLManager::shutdownGL()
{ {
if (mInited) if (mInited)
@@ -960,7 +934,6 @@ void LLGLManager::initExtensions()
mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts); mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts);
mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts); mHasBlendFuncSeparate = ExtensionExists("GL_EXT_blend_func_separate", gGLHExts.mSysExts);
mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts); mHasTextureRectangle = ExtensionExists("GL_ARB_texture_rectangle", gGLHExts.mSysExts);
mHasTextureMultisample = ExtensionExists("GL_ARB_texture_multisample", gGLHExts.mSysExts);
mHasDebugOutput = ExtensionExists("GL_ARB_debug_output", gGLHExts.mSysExts); mHasDebugOutput = ExtensionExists("GL_ARB_debug_output", gGLHExts.mSysExts);
mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE; mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE;
#if !LL_DARWIN #if !LL_DARWIN
@@ -1198,13 +1171,6 @@ void LLGLManager::initExtensions()
{ {
glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT"); glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC) GLH_EXT_GET_PROC_ADDRESS("glBlendFuncSeparateEXT");
} }
if (mHasTextureMultisample)
{
glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) GLH_EXT_GET_PROC_ADDRESS("glTexImage2DMultisample");
glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) GLH_EXT_GET_PROC_ADDRESS("glTexImage3DMultisample");
glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) GLH_EXT_GET_PROC_ADDRESS("glGetMultisamplefv");
glSampleMaski = (PFNGLSAMPLEMASKIPROC) GLH_EXT_GET_PROC_ADDRESS("glSampleMaski");
}
if (mHasTransformFeedback) if (mHasTransformFeedback)
{ {
glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) GLH_EXT_GET_PROC_ADDRESS("glBeginTransformFeedback"); glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) GLH_EXT_GET_PROC_ADDRESS("glBeginTransformFeedback");

View File

@@ -104,11 +104,7 @@ public:
BOOL mHasDrawBuffers; BOOL mHasDrawBuffers;
BOOL mHasDepthClamp; BOOL mHasDepthClamp;
BOOL mHasTextureRectangle; BOOL mHasTextureRectangle;
BOOL mHasTextureMultisample;
BOOL mHasTransformFeedback; BOOL mHasTransformFeedback;
S32 mMaxSampleMaskWords;
S32 mMaxColorTextureSamples;
S32 mMaxDepthTextureSamples;
S32 mMaxIntegerSamples; S32 mMaxIntegerSamples;
// Other extensions. // Other extensions.
@@ -155,7 +151,6 @@ public:
void printGLInfoString(); void printGLInfoString();
void getGLInfo(LLSD& info); void getGLInfo(LLSD& info);
U32 getNumFBOFSAASamples(U32 desired_samples = 32);
// In ALL CAPS // In ALL CAPS
std::string mGLVendor; std::string mGLVendor;
std::string mGLVendorShort; std::string mGLVendorShort;
@@ -521,4 +516,5 @@ extern BOOL gGLActive;
#ifndef GL_DEPTH24_STENCIL8 #ifndef GL_DEPTH24_STENCIL8
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT #define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
#endif #endif
#endif // LL_LLGL_H #endif // LL_LLGL_H

View File

@@ -783,6 +783,7 @@ extern PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB;
extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB; extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB;
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB; extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB;
#elif LL_DARWIN #elif LL_DARWIN
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// LL_DARWIN // LL_DARWIN
@@ -825,6 +826,7 @@ extern void glGenerateMipmapEXT(GLenum target) AVAILABLE_MAC_OS_X_VERSION_10_4_A
#define glGenerateMipmap glGenerateMipmapEXT #define glGenerateMipmap glGenerateMipmapEXT
#define GL_MAX_SAMPLES 0x8D57 #define GL_MAX_SAMPLES 0x8D57
#endif #endif
// GL_ARB_draw_buffers // GL_ARB_draw_buffers
extern void glDrawBuffersARB(GLsizei n, const GLenum* bufs) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; extern void glDrawBuffersARB(GLsizei n, const GLenum* bufs) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
@@ -997,7 +999,7 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
} }
#endif #endif
#include <AGL/gl.h> #include <OpenGL/gl.h>
#endif // LL_MESA / LL_WINDOWS / LL_DARWIN #endif // LL_MESA / LL_WINDOWS / LL_DARWIN
@@ -1029,4 +1031,5 @@ extern void glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC #define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD #define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
#endif #endif
#endif // LL_LLGLHEADERS_H #endif // LL_LLGLHEADERS_H

View File

@@ -330,7 +330,6 @@ S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 categ
//static //static
void LLImageGL::destroyGL(BOOL save_state) void LLImageGL::destroyGL(BOOL save_state)
{ {
deleteDeadTextures(); //Dump unimportant textures.
for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++) for (S32 stage = 0; stage < gGLManager.mNumTextureUnits; stage++)
{ {
gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE);
@@ -364,7 +363,6 @@ void LLImageGL::destroyGL(BOOL save_state)
} }
llinfos << "Storing " << stored_count << " images..." << llendl; llinfos << "Storing " << stored_count << " images..." << llendl;
sAllowReadBackRaw = false ; sAllowReadBackRaw = false ;
deleteDeadTextures();//Now, actually call glDeleteTextures for everything.
} }
//static //static
@@ -1528,7 +1526,7 @@ void LLImageGL::deleteDeadTextures()
{ {
bool reset = false; bool reset = false;
for(U32 i=0;i<LLTexUnit::TT_NONE;++i) /*for(U32 i=0;i<LLTexUnit::TT_NONE;++i)
{ {
for(dead_texturelist_t::iterator it=sDeadTextureList[i].begin();it!=sDeadTextureList[i].end();++it) for(dead_texturelist_t::iterator it=sDeadTextureList[i].begin();it!=sDeadTextureList[i].end();++it)
{ {
@@ -1554,7 +1552,7 @@ void LLImageGL::deleteDeadTextures()
stop_glerror(); stop_glerror();
} }
} }
} }*/
if (reset) if (reset)
{ {

View File

@@ -699,6 +699,28 @@ bool LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth
release(); release();
stop_glerror(); stop_glerror();
if (!gGLManager.mHasFramebufferMultisample || !gGLManager.mHasFramebufferObject || !(sUseFBO || use_fbo))
return false;
if(color_fmt != GL_RGBA)
{
llwarns << "Unsupported color format: " << color_fmt << llendl;
return false;
}
//Restrict to valid sample count
{
mSamples = samples;
mSamples = llmin(mSamples, (U32)4); //Cap to prevent memory bloat.
mSamples = llmin(mSamples, (U32) gGLManager.mMaxIntegerSamples);//GL_RGBA
if(depth && !stencil)
mSamples = llmin(mSamples, (U32) gGLManager.mMaxSamples); //GL_DEPTH_COMPONENT16_ARB
}
if (mSamples <= 1)
return false;
mResX = resx; mResX = resx;
mResY = resy; mResY = resy;
@@ -706,30 +728,16 @@ bool LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth
mUseDepth = depth; mUseDepth = depth;
mStencil = stencil; mStencil = stencil;
if (!gGLManager.mHasFramebufferMultisample)
{
llerrs << "Attempting to allocate unsupported render target type!" << llendl;
return false;
}
mSamples = gGLManager.getNumFBOFSAASamples(samples);
if (mSamples <= 1)
{
llerrs << "Cannot create a multisample buffer with less than 2 samples." << llendl;
return false;
}
stop_glerror();
if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject)
{ {
if (depth) if (depth)
{ {
stop_glerror(); stop_glerror();
if(!allocateDepth()) if(!allocateDepth())
{
release();
return false; return false;
}
stop_glerror(); stop_glerror();
} }
glGenFramebuffers(1, (GLuint *) &mFBO); glGenFramebuffers(1, (GLuint *) &mFBO);
@@ -779,6 +787,7 @@ bool LLMultisampleBuffer::addColorAttachment(U32 color_fmt)
if (glGetError() != GL_NO_ERROR) if (glGetError() != GL_NO_ERROR)
{ {
llwarns << "Unable to allocate color buffer for multisample render target." << llendl; llwarns << "Unable to allocate color buffer for multisample render target." << llendl;
release();
return false; return false;
} }

View File

@@ -231,7 +231,6 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader)
if (features->hasLighting) if (features->hasLighting)
{ {
if (features->hasWaterFog) if (features->hasWaterFog)
{ {
if (features->disableTextureIndex) if (features->disableTextureIndex)
@@ -571,7 +570,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
return 0; return 0;
} }
//we can't have any lines longer than 1024 characters //we can't have any lines longer than 1024 characters
//or any shaders longer than 4096 lines... deal - DaveP //or any shaders longer than 4096 lines... deal - DaveP
GLcharARB buff[1024]; GLcharARB buff[1024];
GLcharARB* text[4096]; GLcharARB* text[4096];
@@ -718,20 +717,33 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
} }
else if (major_version > 1 || minor_version >= 30) else if (major_version > 1 || minor_version >= 30)
{ //switches are supported in GLSL 1.30 and later { //switches are supported in GLSL 1.30 and later
text[count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n"); if (gGLManager.mIsNVIDIA)
text[count++] = strdup("\tswitch (vary_texture_index.r)\n"); { //switches are unreliable on some NVIDIA drivers
text[count++] = strdup("\t{\n"); for (S32 i = 0; i < texture_index_channels; ++i)
{
//switch body std::string if_string = llformat("\t%sif (vary_texture_index.r == %d) { return texture2D(tex%d, texcoord); }\n", i > 0 ? "else " : "", i, i);
for (S32 i = 0; i < texture_index_channels; ++i) text[count++] = strdup(if_string.c_str());
{ }
std::string case_str = llformat("\t\tcase %d: ret = texture2D(tex%d, texcoord); break;\n", i, i); text[count++] = strdup("\treturn vec4(1,0,1,1);\n");
text[count++] = strdup(case_str.c_str()); text[count++] = strdup("}\n");
} }
else
{
text[count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n");
text[count++] = strdup("\tswitch (vary_texture_index.r)\n");
text[count++] = strdup("\t{\n");
text[count++] = strdup("\t}\n"); //switch body
text[count++] = strdup("\treturn ret;\n"); for (S32 i = 0; i < texture_index_channels; ++i)
text[count++] = strdup("}\n"); {
std::string case_str = llformat("\t\tcase %d: ret = texture2D(tex%d, texcoord); break;\n", i, i);
text[count++] = strdup(case_str.c_str());
}
text[count++] = strdup("\t}\n");
text[count++] = strdup("\treturn ret;\n");
text[count++] = strdup("}\n");
}
} }
else else
{ //should never get here. Indexed texture rendering requires GLSL 1.30 or later { //should never get here. Indexed texture rendering requires GLSL 1.30 or later

View File

@@ -39,10 +39,8 @@
#include "llmemory.h" #include "llmemory.h"
#include "llfasttimer.h" #include "llfasttimer.h"
#if LL_DARWIN #define LL_VBO_POOLING 0
#define LL_VBO_POOLING 1
#else
#endif
//Next Highest Power Of Two //Next Highest Power Of Two
//helper function, returns first number > v that is a power of 2, or v if v is already a power of 2 //helper function, returns first number > v that is a power of 2, or v if v is already a power of 2
U32 nhpo2(U32 v) U32 nhpo2(U32 v)
@@ -70,7 +68,6 @@ U32 wpo2(U32 i)
const U32 LL_VBO_BLOCK_SIZE = 2048; const U32 LL_VBO_BLOCK_SIZE = 2048;
const U32 LL_VBO_POOL_MAX_SEED_SIZE = 256*1024;
U32 vbo_block_size(U32 size) U32 vbo_block_size(U32 size)
{ //what block size will fit size? { //what block size will fit size?
@@ -83,7 +80,6 @@ U32 vbo_block_index(U32 size)
return vbo_block_size(size)/LL_VBO_BLOCK_SIZE; return vbo_block_size(size)/LL_VBO_BLOCK_SIZE;
} }
const U32 LL_VBO_POOL_SEED_COUNT = vbo_block_index(LL_VBO_POOL_MAX_SEED_SIZE);
//============================================================================ //============================================================================
@@ -96,11 +92,6 @@ LLVBOPool LLVertexBuffer::sDynamicIBOPool(GL_DYNAMIC_DRAW_ARB, GL_ELEMENT_ARRAY_
U32 LLVBOPool::sBytesPooled = 0; U32 LLVBOPool::sBytesPooled = 0;
U32 LLVBOPool::sIndexBytesPooled = 0; U32 LLVBOPool::sIndexBytesPooled = 0;
U32 LLVBOPool::sCurGLName = 1;
std::list<U32> LLVertexBuffer::sAvailableVAOName;
U32 LLVertexBuffer::sCurVAOName = 1;
U32 LLVertexBuffer::sAllocatedIndexBytes = 0; U32 LLVertexBuffer::sAllocatedIndexBytes = 0;
U32 LLVertexBuffer::sIndexCount = 0; U32 LLVertexBuffer::sIndexCount = 0;
@@ -126,54 +117,14 @@ bool LLVertexBuffer::sUseVAO = false;
bool LLVertexBuffer::sPreferStreamDraw = false; bool LLVertexBuffer::sPreferStreamDraw = false;
U32 LLVBOPool::genBuffer() volatile U8* LLVBOPool::allocate(U32& name, U32 size)
{
U32 ret = 0;
if (mGLNamePool.empty())
{
ret = sCurGLName++;
}
else
{
ret = mGLNamePool.front();
mGLNamePool.pop_front();
}
return ret;
}
void LLVBOPool::deleteBuffer(U32 name)
{
if (gGLManager.mInited)
{
LLVertexBuffer::unbind();
glBindBufferARB(mType, name);
glBufferDataARB(mType, 0, NULL, mUsage);
llassert(std::find(mGLNamePool.begin(), mGLNamePool.end(), name) == mGLNamePool.end());
mGLNamePool.push_back(name);
glBindBufferARB(mType, 0);
}
}
LLVBOPool::LLVBOPool(U32 vboUsage, U32 vboType)
: mUsage(vboUsage), mType(vboType)
{
mMissCount.resize(LL_VBO_POOL_SEED_COUNT);
std::fill(mMissCount.begin(), mMissCount.end(), 0);
}
volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
{ {
llassert(vbo_block_size(size) == size); llassert(vbo_block_size(size) == size);
volatile U8* ret = NULL; volatile U8* ret = NULL;
#if LL_VBO_POOLING
U32 i = vbo_block_index(size); U32 i = vbo_block_index(size);
if (mFreeList.size() <= i) if (mFreeList.size() <= i)
@@ -181,31 +132,25 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
mFreeList.resize(i+1); mFreeList.resize(i+1);
} }
if (mFreeList[i].empty() || for_seed) if (mFreeList[i].empty())
{ {
//make a new buffer //make a new buffer
name = genBuffer(); glGenBuffersARB(1, &name);
glBindBufferARB(mType, name); glBindBufferARB(mType, name);
if (!for_seed && i < LL_VBO_POOL_SEED_COUNT)
{ //record this miss
mMissCount[i]++;
}
if (mType == GL_ARRAY_BUFFER_ARB) if (mType == GL_ARRAY_BUFFER_ARB)
{ {
LLVertexBuffer::sAllocatedBytes += size; LLVertexBuffer::sAllocatedBytes += size;
} }
else else
{ {
LLVertexBuffer::sAllocatedIndexBytes += size; LLVertexBuffer::sAllocatedIndexBytes += size;
} }
if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB) if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB)
{ {
glBufferDataARB(mType, size, 0, mUsage); glBufferDataARB(mType, size, 0, mUsage);
ret = (U8*) ll_aligned_malloc_16(size); ret = (U8*) ll_aligned_malloc_16(size);
} }
else else
{ //always use a true hint of static draw when allocating non-client-backed buffers { //always use a true hint of static draw when allocating non-client-backed buffers
@@ -213,25 +158,6 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
} }
glBindBufferARB(mType, 0); glBindBufferARB(mType, 0);
if (for_seed)
{ //put into pool for future use
llassert(mFreeList.size() > i);
Record rec;
rec.mGLName = name;
rec.mClientData = ret;
if (mType == GL_ARRAY_BUFFER_ARB)
{
sBytesPooled += size;
}
else
{
sIndexBytesPooled += size;
}
mFreeList[i].push_back(rec);
}
} }
else else
{ {
@@ -249,6 +175,33 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
mFreeList[i].pop_front(); mFreeList[i].pop_front();
} }
#else //no pooling
glGenBuffersARB(1, &name);
glBindBufferARB(mType, name);
if (mType == GL_ARRAY_BUFFER_ARB)
{
LLVertexBuffer::sAllocatedBytes += size;
}
else
{
LLVertexBuffer::sAllocatedIndexBytes += size;
}
if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB)
{
glBufferDataARB(mType, size, 0, mUsage);
ret = (U8*) ll_aligned_malloc_16(size);
}
else
{ //always use a true hint of static draw when allocating non-client-backed buffers
glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB);
}
glBindBufferARB(mType, 0);
#endif
return ret; return ret;
} }
@@ -257,7 +210,34 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size)
{ {
llassert(vbo_block_size(size) == size); llassert(vbo_block_size(size) == size);
deleteBuffer(name); #if LL_VBO_POOLING
U32 i = vbo_block_index(size);
llassert(mFreeList.size() > i);
Record rec;
rec.mGLName = name;
rec.mClientData = buffer;
if (buffer == NULL)
{
glDeleteBuffersARB(1, &rec.mGLName);
}
else
{
if (mType == GL_ARRAY_BUFFER_ARB)
{
sBytesPooled += size;
}
else
{
sIndexBytesPooled += size;
}
mFreeList[i].push_back(rec);
}
#else //no pooling
glDeleteBuffersARB(1, &name);
ll_aligned_free_16((U8*) buffer); ll_aligned_free_16((U8*) buffer);
if (mType == GL_ARRAY_BUFFER_ARB) if (mType == GL_ARRAY_BUFFER_ARB)
@@ -268,36 +248,12 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size)
{ {
LLVertexBuffer::sAllocatedIndexBytes -= size; LLVertexBuffer::sAllocatedIndexBytes -= size;
} }
#endif
} }
void LLVBOPool::seedPool()
{
U32 dummy_name = 0;
if (mFreeList.size() < LL_VBO_POOL_SEED_COUNT)
{
mFreeList.resize(LL_VBO_POOL_SEED_COUNT);
}
for (U32 i = 0; i < LL_VBO_POOL_SEED_COUNT; i++)
{
if (mMissCount[i] > mFreeList[i].size())
{
U32 size = i*LL_VBO_BLOCK_SIZE;
S32 count = mMissCount[i] - mFreeList[i].size();
for (S32 j = 0; j < count; ++j)
{
allocate(dummy_name, size, true);
}
}
}
}
void LLVBOPool::cleanup() void LLVBOPool::cleanup()
{ {
U32 size = LL_VBO_BLOCK_SIZE; U32 size = 1;
for (U32 i = 0; i < mFreeList.size(); ++i) for (U32 i = 0; i < mFreeList.size(); ++i)
{ {
@@ -307,7 +263,7 @@ void LLVBOPool::cleanup()
{ {
Record& r = l.front(); Record& r = l.front();
deleteBuffer(r.mGLName); glDeleteBuffersARB(1, &r.mGLName);
if (r.mClientData) if (r.mClientData)
{ {
@@ -328,11 +284,8 @@ void LLVBOPool::cleanup()
} }
} }
size += LL_VBO_BLOCK_SIZE; size *= 2;
} }
//reset miss counts
std::fill(mMissCount.begin(), mMissCount.end(), 0);
} }
@@ -366,41 +319,6 @@ U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] =
GL_LINE_LOOP, GL_LINE_LOOP,
}; };
//static
U32 LLVertexBuffer::getVAOName()
{
U32 ret = 0;
if (!sAvailableVAOName.empty())
{
ret = sAvailableVAOName.front();
sAvailableVAOName.pop_front();
}
else
{
#ifdef GL_ARB_vertex_array_object
glGenVertexArrays(1, &ret);
#endif
}
return ret;
}
//static
void LLVertexBuffer::releaseVAOName(U32 name)
{
sAvailableVAOName.push_back(name);
}
//static
void LLVertexBuffer::seedPools()
{
sStreamVBOPool.seedPool();
sDynamicVBOPool.seedPool();
sStreamIBOPool.seedPool();
sDynamicIBOPool.seedPool();
}
//static //static
void LLVertexBuffer::setupClientArrays(U32 data_mask) void LLVertexBuffer::setupClientArrays(U32 data_mask)
@@ -1010,7 +928,7 @@ LLVertexBuffer::~LLVertexBuffer()
if (mGLArray) if (mGLArray)
{ {
#if GL_ARB_vertex_array_object #if GL_ARB_vertex_array_object
releaseVAOName(mGLArray); glDeleteVertexArrays(1, &mGLArray);
#endif #endif
} }
@@ -1295,7 +1213,7 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
if (gGLManager.mHasVertexArrayObject && useVBOs() && (LLRender::sGLCoreProfile || sUseVAO)) if (gGLManager.mHasVertexArrayObject && useVBOs() && (LLRender::sGLCoreProfile || sUseVAO))
{ {
#if GL_ARB_vertex_array_object #if GL_ARB_vertex_array_object
mGLArray = getVAOName(); glGenVertexArrays(1, &mGLArray);
#endif #endif
setupVertexArray(); setupVertexArray();
} }
@@ -2165,16 +2083,6 @@ void LLVertexBuffer::flush()
} }
} }
// bind for transform feedback (quick 'n dirty)
void LLVertexBuffer::bindForFeedback(U32 channel, U32 type, U32 index, U32 count)
{
#ifdef GL_TRANSFORM_FEEDBACK_BUFFER
U32 offset = mOffsets[type] + sTypeSize[type]*index;
U32 size= (sTypeSize[type]*count);
glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, channel, mGLBuffer, offset, size);
#endif
}
// Set for rendering // Set for rendering
void LLVertexBuffer::setBuffer(U32 data_mask) void LLVertexBuffer::setBuffer(U32 data_mask)
{ {

View File

@@ -57,28 +57,23 @@ public:
static U32 sBytesPooled; static U32 sBytesPooled;
static U32 sIndexBytesPooled; static U32 sIndexBytesPooled;
static U32 sCurGLName; LLVBOPool(U32 vboUsage, U32 vboType)
: mUsage(vboUsage)
LLVBOPool(U32 vboUsage, U32 vboType); , mType(vboType)
{}
const U32 mUsage; const U32 mUsage;
const U32 mType; const U32 mType;
//size MUST be a power of 2 //size MUST be a power of 2
volatile U8* allocate(U32& name, U32 size, bool for_seed = false); volatile U8* allocate(U32& name, U32 size);
//size MUST be the size provided to allocate that returned the given name //size MUST be the size provided to allocate that returned the given name
void release(U32 name, volatile U8* buffer, U32 size); void release(U32 name, volatile U8* buffer, U32 size);
//batch allocate buffers to be provided to the application on demand
void seedPool();
//destroy all records in mFreeList //destroy all records in mFreeList
void cleanup(); void cleanup();
U32 genBuffer();
void deleteBuffer(U32 name);
class Record class Record
{ {
public: public:
@@ -86,13 +81,11 @@ public:
volatile U8* mClientData; volatile U8* mClientData;
}; };
std::list<U32> mGLNamePool;
typedef std::list<Record> record_list_t; typedef std::list<Record> record_list_t;
std::vector<record_list_t> mFreeList; std::vector<record_list_t> mFreeList;
std::vector<U32> mMissCount;
}; };
//============================================================================ //============================================================================
// base class // base class
class LLPrivateMemoryPool; class LLPrivateMemoryPool;
@@ -126,22 +119,13 @@ public:
static LLVBOPool sStreamIBOPool; static LLVBOPool sStreamIBOPool;
static LLVBOPool sDynamicIBOPool; static LLVBOPool sDynamicIBOPool;
static std::list<U32> sAvailableVAOName;
static U32 sCurVAOName;
static bool sUseStreamDraw; static bool sUseStreamDraw;
static bool sUseVAO; static bool sUseVAO;
static bool sPreferStreamDraw; static bool sPreferStreamDraw;
static void seedPools();
static U32 getVAOName();
static void releaseVAOName(U32 name);
static void initClass(bool use_vbo, bool no_vbo_mapping); static void initClass(bool use_vbo, bool no_vbo_mapping);
static void cleanupClass(); static void cleanupClass();
static void setupClientArrays(U32 data_mask); static void setupClientArrays(U32 data_mask);
static void pushPositions(U32 mode, const LLVector4a* pos, U32 count);
static void drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm); static void drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm);
static void drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp); static void drawElements(U32 mode, const LLVector4a* pos, const LLVector2* tc, S32 num_indices, const U16* indicesp);
@@ -218,6 +202,7 @@ protected:
void destroyGLIndices(); void destroyGLIndices();
void updateNumVerts(S32 nverts); void updateNumVerts(S32 nverts);
void updateNumIndices(S32 nindices); void updateNumIndices(S32 nindices);
bool useVBOs() const;
void unmapBuffer(); void unmapBuffer();
public: public:
@@ -227,8 +212,6 @@ public:
volatile U8* mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range); volatile U8* mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range);
volatile U8* mapIndexBuffer(S32 index, S32 count, bool map_range); volatile U8* mapIndexBuffer(S32 index, S32 count, bool map_range);
void bindForFeedback(U32 channel, U32 type, U32 index, U32 count);
// set for rendering // set for rendering
virtual void setBuffer(U32 data_mask); // calls setupVertexBuffer() if data_mask is not 0 virtual void setBuffer(U32 data_mask); // calls setupVertexBuffer() if data_mask is not 0
void flush(); //flush pending data to GL memory void flush(); //flush pending data to GL memory
@@ -251,14 +234,12 @@ public:
bool getNormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getNormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getBinormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getBinormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getColorStrider(LLStrider<LLColor4U>& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getColorStrider(LLStrider<LLColor4U>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getTextureIndexStrider(LLStrider<LLColor4U>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getEmissiveStrider(LLStrider<LLColor4U>& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getEmissiveStrider(LLStrider<LLColor4U>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getWeightStrider(LLStrider<F32>& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getWeightStrider(LLStrider<F32>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getWeight4Strider(LLStrider<LLVector4>& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getWeight4Strider(LLStrider<LLVector4>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getClothWeightStrider(LLStrider<LLVector4>& strider, S32 index=0, S32 count = -1, bool map_range = false); bool getClothWeightStrider(LLStrider<LLVector4>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool useVBOs() const;
bool isEmpty() const { return mEmpty; } bool isEmpty() const { return mEmpty; }
bool isLocked() const { return mVertexLocked || mIndexLocked; } bool isLocked() const { return mVertexLocked || mIndexLocked; }
S32 getNumVerts() const { return mNumVerts; } S32 getNumVerts() const { return mNumVerts; }

View File

@@ -809,7 +809,11 @@ void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LL
gGL.flush(); gGL.flush();
glLineWidth(2.5f); glLineWidth(2.5f);
glLineStipple(2, 0x3333 << shift); if (!LLGLSLShader::sNoFixedFunction)
{
glLineStipple(2, 0x3333 << shift);
}
gGL.begin(LLRender::LINES); gGL.begin(LLRender::LINES);
{ {

View File

@@ -175,7 +175,7 @@ BOOL LLVFile::isReadComplete()
{ {
LLVFSThread::Request* req = (LLVFSThread::Request*)sVFSThread->getRequest(mHandle); LLVFSThread::Request* req = (LLVFSThread::Request*)sVFSThread->getRequest(mHandle);
LLVFSThread::status_t status = req->getStatus(); LLVFSThread::status_t status = req->getStatus();
if (status == LLVFSThread::STATUS_COMPLETE) if (status == LLVFSThread::STATUS_COMPLETE && !(req->getFlags() & LLVFSThread::FLAG_LOCKED))
{ {
mBytesRead = req->getBytesRead(); mBytesRead = req->getBytesRead();
mPosition += mBytesRead; mPosition += mBytesRead;

View File

@@ -45,17 +45,20 @@ class LLMouseHandler
public: public:
LLMouseHandler() {} LLMouseHandler() {}
virtual ~LLMouseHandler() {} virtual ~LLMouseHandler() {}
typedef enum { typedef enum {
SHOW_NEVER, SHOW_NEVER,
SHOW_IF_NOT_BLOCKED, SHOW_IF_NOT_BLOCKED,
SHOW_ALWAYS, SHOW_ALWAYS,
} EShowToolTip; } EShowToolTip;
typedef enum { typedef enum {
CLICK_LEFT, CLICK_LEFT,
CLICK_MIDDLE, CLICK_MIDDLE,
CLICK_RIGHT, CLICK_RIGHT,
CLICK_DOUBLELEFT CLICK_DOUBLELEFT
} EClickType; } EClickType;
virtual BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down); virtual BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down);
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0;
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask) = 0;

View File

@@ -113,6 +113,7 @@ LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags)
mSupportedResolutions(NULL), mSupportedResolutions(NULL),
mNumSupportedResolutions(0), mNumSupportedResolutions(0),
mCurrentCursor(UI_CURSOR_ARROW), mCurrentCursor(UI_CURSOR_ARROW),
mNextCursor(UI_CURSOR_ARROW),
mCursorHidden(FALSE), mCursorHidden(FALSE),
mBusyCount(0), mBusyCount(0),
mIsMouseClipping(FALSE), mIsMouseClipping(FALSE),
@@ -125,7 +126,6 @@ LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags)
LLWindow::~LLWindow() LLWindow::~LLWindow()
{ {
} }
//virtual //virtual
@@ -139,6 +139,7 @@ BOOL LLWindow::canDelete()
{ {
return TRUE; return TRUE;
} }
// virtual // virtual
void LLWindow::incBusyCount() void LLWindow::incBusyCount()
{ {

View File

@@ -104,12 +104,14 @@ public:
virtual S32 getBusyCount() const; virtual S32 getBusyCount() const;
// Sets cursor, may set to arrow+hourglass // Sets cursor, may set to arrow+hourglass
virtual void setCursor(ECursorType cursor) = 0; virtual void setCursor(ECursorType cursor) { mNextCursor = cursor; };
virtual ECursorType getCursor() const; virtual ECursorType getCursor() const;
virtual void updateCursor() = 0;
virtual void captureMouse() = 0; virtual void captureMouse() = 0;
virtual void releaseMouse() = 0; virtual void releaseMouse() = 0;
virtual void setMouseClipping( BOOL b ) = 0; virtual void setMouseClipping( BOOL b ) = 0;
virtual BOOL isClipboardTextAvailable() = 0; virtual BOOL isClipboardTextAvailable() = 0;
virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0; virtual BOOL pasteTextFromClipboard(LLWString &dst) = 0;
virtual BOOL copyTextToClipboard(const LLWString &src) = 0; virtual BOOL copyTextToClipboard(const LLWString &src) = 0;
@@ -196,6 +198,7 @@ protected:
LLWindowResolution* mSupportedResolutions; LLWindowResolution* mSupportedResolutions;
S32 mNumSupportedResolutions; S32 mNumSupportedResolutions;
ECursorType mCurrentCursor; ECursorType mCurrentCursor;
ECursorType mNextCursor;
BOOL mCursorHidden; BOOL mCursorHidden;
S32 mBusyCount; // how deep is the "cursor busy" stack? S32 mBusyCount; // how deep is the "cursor busy" stack?
BOOL mIsMouseClipping; // Is this window currently clipping the mouse BOOL mIsMouseClipping; // Is this window currently clipping the mouse

View File

@@ -91,5 +91,4 @@ public:
}; };
#endif #endif

View File

@@ -61,7 +61,7 @@ public:
/*virtual*/ void showCursorFromMouseMove() {}; /*virtual*/ void showCursorFromMouseMove() {};
/*virtual*/ void hideCursorUntilMouseMove() {}; /*virtual*/ void hideCursorUntilMouseMove() {};
/*virtual*/ BOOL isCursorHidden() {return FALSE;}; /*virtual*/ BOOL isCursorHidden() {return FALSE;};
/*virtual*/ void setCursor(ECursorType cursor) {}; /*virtual*/ void updateCursor() {};
//virtual ECursorType getCursor() { return mCurrentCursor; }; //virtual ECursorType getCursor() { return mCurrentCursor; };
/*virtual*/ void captureMouse() {}; /*virtual*/ void captureMouse() {};
/*virtual*/ void releaseMouse() {}; /*virtual*/ void releaseMouse() {};

View File

@@ -50,6 +50,11 @@ void setupCocoa()
{ {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// The following prevents the Cocoa command line parser from trying to open 'unknown' arguements as documents.
// ie. running './secondlife -set Language fr' would cause a pop-up saying can't open document 'fr'
// when init'ing the Cocoa App window.
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
// This is a bit of voodoo taken from the Apple sample code "CarbonCocoa_PictureCursor": // This is a bit of voodoo taken from the Apple sample code "CarbonCocoa_PictureCursor":
// http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/index.html // http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/index.html
@@ -60,6 +65,8 @@ void setupCocoa()
[[[NSWindow alloc] init] release]; [[[NSWindow alloc] init] release];
[pool release]; [pool release];
inited = true;
} }
} }

View File

@@ -484,7 +484,6 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
true, true,
(long)this); (long)this);
if (!mWindow) if (!mWindow)
{ {
setupFailure("Window creation error", "Error", OSMB_OK); setupFailure("Window creation error", "Error", OSMB_OK);
@@ -581,16 +580,16 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
AGL_NO_RECOVERY, AGL_NO_RECOVERY,
AGL_DOUBLEBUFFER, AGL_DOUBLEBUFFER,
AGL_CLOSEST_POLICY, AGL_CLOSEST_POLICY,
AGL_ACCELERATED, AGL_ACCELERATED,
AGL_SAMPLE_BUFFERS_ARB, mFSAASamples > 0 ? 1 : 0, AGL_SAMPLE_BUFFERS_ARB, mFSAASamples > 0 ? 1 : 0,
AGL_SAMPLES_ARB, mFSAASamples, AGL_SAMPLES_ARB, mFSAASamples,
AGL_RED_SIZE, 8, AGL_RED_SIZE, 8,
AGL_GREEN_SIZE, 8, AGL_GREEN_SIZE, 8,
AGL_BLUE_SIZE, 8, AGL_BLUE_SIZE, 8,
AGL_ALPHA_SIZE, 8, AGL_ALPHA_SIZE, 8,
AGL_DEPTH_SIZE, 24, AGL_DEPTH_SIZE, 24,
AGL_STENCIL_SIZE, 8, AGL_STENCIL_SIZE, 8,
AGL_NONE AGL_NONE
}; };
LL_DEBUGS("Window") << "createContext: creating windowed pixelformat" << LL_ENDL; LL_DEBUGS("Window") << "createContext: creating windowed pixelformat" << LL_ENDL;
@@ -1042,6 +1041,7 @@ void LLWindowMacOSX::hide()
HideWindow(mWindow); HideWindow(mWindow);
} }
//virtual
void LLWindowMacOSX::minimize() void LLWindowMacOSX::minimize()
{ {
setMouseClipping(FALSE); setMouseClipping(FALSE);
@@ -1049,6 +1049,7 @@ void LLWindowMacOSX::minimize()
CollapseWindow(mWindow, true); CollapseWindow(mWindow, true);
} }
//virtual
void LLWindowMacOSX::restore() void LLWindowMacOSX::restore()
{ {
show(); show();
@@ -1169,6 +1170,8 @@ void LLWindowMacOSX::gatherInput()
} }
} }
updateCursor();
} }
BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position) BOOL LLWindowMacOSX::getPosition(LLCoordScreen *position)
@@ -1441,7 +1444,7 @@ static void fixOrigin(void)
::GetPortBounds(port, &portrect); ::GetPortBounds(port, &portrect);
if((portrect.left != 0) || (portrect.top != 0)) if((portrect.left != 0) || (portrect.top != 0))
{ {
// Mozilla sometimes changes our port origin. Fuckers. // Mozilla sometimes changes our port origin.
::SetOrigin(0,0); ::SetOrigin(0,0);
} }
} }
@@ -2133,6 +2136,7 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
{ {
UInt32 modifiers = 0; UInt32 modifiers = 0;
// First, process the raw event. // First, process the raw event.
{ {
EventRef rawEvent = NULL; EventRef rawEvent = NULL;
@@ -2843,7 +2847,7 @@ static void initPixmapCursor(int cursorid, int hotspotX, int hotspotY)
gCursors[cursorid] = createImageCursor(fullpath.c_str(), hotspotX, hotspotY); gCursors[cursorid] = createImageCursor(fullpath.c_str(), hotspotX, hotspotY);
} }
void LLWindowMacOSX::setCursor(ECursorType cursor) void LLWindowMacOSX::updateCursor()
{ {
OSStatus result = noErr; OSStatus result = noErr;
@@ -2851,30 +2855,30 @@ void LLWindowMacOSX::setCursor(ECursorType cursor)
{ {
// A drag is in progress...remember the requested cursor and we'll // A drag is in progress...remember the requested cursor and we'll
// restore it when it is done // restore it when it is done
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
return; return;
} }
if (cursor == UI_CURSOR_ARROW if (mNextCursor == UI_CURSOR_ARROW
&& mBusyCount > 0) && mBusyCount > 0)
{ {
cursor = UI_CURSOR_WORKING; mNextCursor = UI_CURSOR_WORKING;
} }
if(mCurrentCursor == cursor) if(mCurrentCursor == mNextCursor)
return; return;
// RN: replace multi-drag cursors with single versions // RN: replace multi-drag cursors with single versions
if (cursor == UI_CURSOR_ARROWDRAGMULTI) if (mNextCursor == UI_CURSOR_ARROWDRAGMULTI)
{ {
cursor = UI_CURSOR_ARROWDRAG; mNextCursor = UI_CURSOR_ARROWDRAG;
} }
else if (cursor == UI_CURSOR_ARROWCOPYMULTI) else if (mNextCursor == UI_CURSOR_ARROWCOPYMULTI)
{ {
cursor = UI_CURSOR_ARROWCOPY; mNextCursor = UI_CURSOR_ARROWCOPY;
} }
switch(cursor) switch(mNextCursor)
{ {
default: default:
case UI_CURSOR_ARROW: case UI_CURSOR_ARROW:
@@ -2926,7 +2930,7 @@ void LLWindowMacOSX::setCursor(ECursorType cursor)
case UI_CURSOR_TOOLBUY: case UI_CURSOR_TOOLBUY:
case UI_CURSOR_TOOLOPEN: case UI_CURSOR_TOOLOPEN:
case UI_CURSOR_TOOLPAY: case UI_CURSOR_TOOLPAY:
result = setImageCursor(gCursors[cursor]); result = setImageCursor(gCursors[mNextCursor]);
break; break;
} }
@@ -2936,7 +2940,7 @@ void LLWindowMacOSX::setCursor(ECursorType cursor)
InitCursor(); InitCursor();
} }
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
} }
ECursorType LLWindowMacOSX::getCursor() const ECursorType LLWindowMacOSX::getCursor() const
@@ -2967,9 +2971,9 @@ void LLWindowMacOSX::initCursors()
initPixmapCursor(UI_CURSOR_TOOLPLAY, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPLAY, 1, 1);
initPixmapCursor(UI_CURSOR_TOOLPAUSE, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPAUSE, 1, 1);
initPixmapCursor(UI_CURSOR_TOOLMEDIAOPEN, 1, 1); initPixmapCursor(UI_CURSOR_TOOLMEDIAOPEN, 1, 1);
initPixmapCursor(UI_CURSOR_TOOLSIT, 1, 1); initPixmapCursor(UI_CURSOR_TOOLSIT, 20, 15);
initPixmapCursor(UI_CURSOR_TOOLBUY, 1, 1); initPixmapCursor(UI_CURSOR_TOOLBUY, 20, 15);
initPixmapCursor(UI_CURSOR_TOOLOPEN, 1, 1); initPixmapCursor(UI_CURSOR_TOOLOPEN, 20, 15);
initPixmapCursor(UI_CURSOR_TOOLPAY, 1, 1); initPixmapCursor(UI_CURSOR_TOOLPAY, 1, 1);
initPixmapCursor(UI_CURSOR_SIZENWSE, 10, 10); initPixmapCursor(UI_CURSOR_SIZENWSE, 10, 10);

View File

@@ -73,7 +73,7 @@ public:
/*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void showCursorFromMouseMove();
/*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ void hideCursorUntilMouseMove();
/*virtual*/ BOOL isCursorHidden(); /*virtual*/ BOOL isCursorHidden();
/*virtual*/ void setCursor(ECursorType cursor); /*virtual*/ void updateCursor();
/*virtual*/ ECursorType getCursor() const; /*virtual*/ ECursorType getCursor() const;
/*virtual*/ void captureMouse(); /*virtual*/ void captureMouse();
/*virtual*/ void releaseMouse(); /*virtual*/ void releaseMouse();

View File

@@ -65,7 +65,7 @@ public:
/*virtual*/ void showCursorFromMouseMove() {}; /*virtual*/ void showCursorFromMouseMove() {};
/*virtual*/ void hideCursorUntilMouseMove() {}; /*virtual*/ void hideCursorUntilMouseMove() {};
/*virtual*/ BOOL isCursorHidden() {return FALSE;}; /*virtual*/ BOOL isCursorHidden() {return FALSE;};
/*virtual*/ void setCursor(ECursorType cursor) {}; /*virtual*/ void updateCursor() {};
//virtual ECursorType getCursor() { return mCurrentCursor; }; //virtual ECursorType getCursor() { return mCurrentCursor; };
/*virtual*/ void captureMouse() {}; /*virtual*/ void captureMouse() {};
/*virtual*/ void releaseMouse() {}; /*virtual*/ void releaseMouse() {};

View File

@@ -39,6 +39,7 @@
#include "llwindowcallbacks.h" #include "llwindowcallbacks.h"
#include "llkeyboardsdl.h" #include "llkeyboardsdl.h"
#include "llerror.h" #include "llerror.h"
#include "llgl.h" #include "llgl.h"
#include "llstring.h" #include "llstring.h"
@@ -221,15 +222,14 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks,
#endif // LL_X11 #endif // LL_X11
#if LL_GTK #if LL_GTK
// We MUST be the first to initialize GTK, i.e. we have to beat // We MUST be the first to initialize GTK so that GTK doesn't get badly
// our embedded Mozilla to the punch so that GTK doesn't get badly
// initialized with a non-C locale and cause lots of serious random // initialized with a non-C locale and cause lots of serious random
// weirdness. // weirdness.
ll_try_gtk_init(); ll_try_gtk_init();
#endif // LL_GTK #endif // LL_GTK
// Get the original aspect ratio of the main device. // Assume 4:3 aspect ratio until we know better
mOriginalAspectRatio = 1024.0 / 768.0; // !!! *FIX: ? //(double)CGDisplayPixelsWide(mDisplay) / (double)CGDisplayPixelsHigh(mDisplay); mOriginalAspectRatio = 1024.0 / 768.0;
if (title.empty()) if (title.empty())
mWindowTitle = "SDL Window"; // *FIX: (???) mWindowTitle = "SDL Window"; // *FIX: (???)
@@ -425,7 +425,6 @@ static int x11_detect_VRAM_kb()
BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync) BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, BOOL fullscreen, BOOL disable_vsync)
{ {
//bool glneedsinit = false; //bool glneedsinit = false;
// const char *gllibname = null;
llinfos << "createContext, fullscreen=" << fullscreen << llinfos << "createContext, fullscreen=" << fullscreen <<
" size=" << width << "x" << height << llendl; " size=" << width << "x" << height << llendl;
@@ -856,11 +855,13 @@ void LLWindowSDL::hide()
// *FIX: What to do with SDL? // *FIX: What to do with SDL?
} }
//virtual
void LLWindowSDL::minimize() void LLWindowSDL::minimize()
{ {
// *FIX: What to do with SDL? // *FIX: What to do with SDL?
} }
//virtual
void LLWindowSDL::restore() void LLWindowSDL::restore()
{ {
// *FIX: What to do with SDL? // *FIX: What to do with SDL?
@@ -1680,12 +1681,13 @@ void check_vm_bloat()
} }
#endif // LL_LINUX #endif // LL_LINUX
} }
// virtual // virtual
void LLWindowSDL::processMiscNativeEvents() void LLWindowSDL::processMiscNativeEvents()
{ {
#if LL_GTK #if LL_GTK
// Pump GTK events to avoid starvation for: // Pump GTK events to avoid starvation for:
// * Embedded Gecko
// * DBUS servicing // * DBUS servicing
// * Anything else which quietly hooks into the default glib/GTK loop // * Anything else which quietly hooks into the default glib/GTK loop
if (ll_try_gtk_init()) if (ll_try_gtk_init())
@@ -1721,7 +1723,7 @@ void LLWindowSDL::processMiscNativeEvents()
void LLWindowSDL::gatherInput() void LLWindowSDL::gatherInput()
{ {
const Uint32 CLICK_THRESHOLD = 500; // milliseconds const Uint32 CLICK_THRESHOLD = 500; // milliseconds
static int leftClick = 0; static int leftClick = 0;
static int rightClick = 0; static int rightClick = 0;
static Uint32 lastLeftDown = 0; static Uint32 lastLeftDown = 0;
@@ -1747,16 +1749,17 @@ void LLWindowSDL::gatherInput()
mKeyScanCode = event.key.keysym.scancode; mKeyScanCode = event.key.keysym.scancode;
mKeyVirtualKey = event.key.keysym.unicode; mKeyVirtualKey = event.key.keysym.unicode;
mKeyModifiers = event.key.keysym.mod; mKeyModifiers = event.key.keysym.mod;
gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod);
// part of the fix for SL-13243
if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0)
SDLReallyCaptureInput(TRUE);
if (event.key.keysym.unicode) gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod);
{ // part of the fix for SL-13243
handleUnicodeUTF16(event.key.keysym.unicode, if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0)
gKeyboard->currentMask(FALSE)); SDLReallyCaptureInput(TRUE);
}
if (event.key.keysym.unicode)
{
handleUnicodeUTF16(event.key.keysym.unicode,
gKeyboard->currentMask(FALSE));
}
break; break;
case SDL_KEYUP: case SDL_KEYUP:
@@ -1767,8 +1770,8 @@ void LLWindowSDL::gatherInput()
if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0) if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0)
SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243
gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod);
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
{ {
@@ -1933,6 +1936,8 @@ void LLWindowSDL::gatherInput()
} }
} }
updateCursor();
#if LL_X11 #if LL_X11
// This is a good time to stop flashing the icon if our mFlashTimer has // This is a good time to stop flashing the icon if our mFlashTimer has
// expired. // expired.
@@ -2018,7 +2023,7 @@ static SDL_Cursor *makeSDLCursorFromBMP(const char *filename, int hotx, int hoty
return sdlcursor; return sdlcursor;
} }
void LLWindowSDL::setCursor(ECursorType cursor) void LLWindowSDL::updateCursor()
{ {
if (ATIbug) { if (ATIbug) {
// cursor-updating is very flaky when this bug is // cursor-updating is very flaky when this bug is
@@ -2026,11 +2031,11 @@ void LLWindowSDL::setCursor(ECursorType cursor)
return; return;
} }
if (mCurrentCursor != cursor) if (mCurrentCursor != mNextCursor)
{ {
if (cursor < UI_CURSOR_COUNT) if (mNextCursor < UI_CURSOR_COUNT)
{ {
SDL_Cursor *sdlcursor = mSDLCursors[cursor]; SDL_Cursor *sdlcursor = mSDLCursors[mNextCursor];
// Try to default to the arrow for any cursors that // Try to default to the arrow for any cursors that
// did not load correctly. // did not load correctly.
if (!sdlcursor && mSDLCursors[UI_CURSOR_ARROW]) if (!sdlcursor && mSDLCursors[UI_CURSOR_ARROW])
@@ -2038,9 +2043,9 @@ void LLWindowSDL::setCursor(ECursorType cursor)
if (sdlcursor) if (sdlcursor)
SDL_SetCursor(sdlcursor); SDL_SetCursor(sdlcursor);
} else { } else {
llwarns << "Tried to set invalid cursor number " << cursor << llendl; llwarns << "Tried to set invalid cursor number " << mNextCursor << llendl;
} }
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
} }
} }

View File

@@ -78,7 +78,7 @@ public:
/*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void showCursorFromMouseMove();
/*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ void hideCursorUntilMouseMove();
/*virtual*/ BOOL isCursorHidden(); /*virtual*/ BOOL isCursorHidden();
/*virtual*/ void setCursor(ECursorType cursor); /*virtual*/ void updateCursor();
/*virtual*/ void captureMouse(); /*virtual*/ void captureMouse();
/*virtual*/ void releaseMouse(); /*virtual*/ void releaseMouse();
/*virtual*/ void setMouseClipping( BOOL b ); /*virtual*/ void setMouseClipping( BOOL b );
@@ -102,7 +102,7 @@ public:
/*virtual*/ void gatherInput(); /*virtual*/ void gatherInput();
/*virtual*/ void swapBuffers(); /*virtual*/ void swapBuffers();
/*virtual*/ void delayInputProcessing() { }; /*virtual*/ void delayInputProcessing() { };
// handy coordinate space conversion routines // handy coordinate space conversion routines
/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to); /*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);

View File

@@ -677,6 +677,7 @@ void LLWindowWin32::hide()
ShowWindow(mWindowHandle, SW_HIDE); ShowWindow(mWindowHandle, SW_HIDE);
} }
//virtual
void LLWindowWin32::minimize() void LLWindowWin32::minimize()
{ {
setMouseClipping(FALSE); setMouseClipping(FALSE);
@@ -684,7 +685,7 @@ void LLWindowWin32::minimize()
ShowWindow(mWindowHandle, SW_MINIMIZE); ShowWindow(mWindowHandle, SW_MINIMIZE);
} }
//virtual
void LLWindowWin32::restore() void LLWindowWin32::restore()
{ {
ShowWindow(mWindowHandle, SW_RESTORE); ShowWindow(mWindowHandle, SW_RESTORE);
@@ -1019,6 +1020,7 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
dw_style = WS_OVERLAPPEDWINDOW; dw_style = WS_OVERLAPPEDWINDOW;
} }
// don't post quit messages when destroying old windows // don't post quit messages when destroying old windows
mPostQuit = FALSE; mPostQuit = FALSE;
@@ -1070,6 +1072,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
return FALSE; return FALSE;
} }
LL_INFOS("Window") << "Device context retrieved." << llendl ;
if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd))) if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd)))
{ {
close(); close();
@@ -1078,6 +1082,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
return FALSE; return FALSE;
} }
LL_INFOS("Window") << "Pixel format chosen." << llendl ;
// Verify what pixel format we actually received. // Verify what pixel format we actually received.
if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR), if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR),
&pfd)) &pfd))
@@ -1653,13 +1659,13 @@ void LLWindowWin32::initCursors()
mCursor[ UI_CURSOR_PIPETTE ] = LoadCursor(module, TEXT("TOOLPIPETTE")); mCursor[ UI_CURSOR_PIPETTE ] = LoadCursor(module, TEXT("TOOLPIPETTE"));
// Color cursors // Color cursors
mCursor[UI_CURSOR_TOOLSIT] = loadColorCursor(TEXT("TOOLSIT")); mCursor[ UI_CURSOR_TOOLSIT ] = loadColorCursor(TEXT("TOOLSIT"));
mCursor[UI_CURSOR_TOOLBUY] = loadColorCursor(TEXT("TOOLBUY")); mCursor[ UI_CURSOR_TOOLBUY ] = loadColorCursor(TEXT("TOOLBUY"));
mCursor[UI_CURSOR_TOOLPAY] = loadColorCursor(TEXT("TOOLPAY")); mCursor[ UI_CURSOR_TOOLPAY ] = loadColorCursor(TEXT("TOOLPAY"));
mCursor[UI_CURSOR_TOOLOPEN] = loadColorCursor(TEXT("TOOLOPEN")); mCursor[ UI_CURSOR_TOOLOPEN ] = loadColorCursor(TEXT("TOOLOPEN"));
mCursor[UI_CURSOR_TOOLPLAY] = loadColorCursor(TEXT("TOOLPLAY")); mCursor[ UI_CURSOR_TOOLPLAY ] = loadColorCursor(TEXT("TOOLPLAY"));
mCursor[UI_CURSOR_TOOLPAUSE] = loadColorCursor(TEXT("TOOLPAUSE")); mCursor[ UI_CURSOR_TOOLPAUSE ] = loadColorCursor(TEXT("TOOLPAUSE"));
mCursor[UI_CURSOR_TOOLMEDIAOPEN] = loadColorCursor(TEXT("TOOLMEDIAOPEN")); mCursor[ UI_CURSOR_TOOLMEDIAOPEN ] = loadColorCursor(TEXT("TOOLMEDIAOPEN"));
// Note: custom cursors that are not found make LoadCursor() return NULL. // Note: custom cursors that are not found make LoadCursor() return NULL.
for( S32 i = 0; i < UI_CURSOR_COUNT; i++ ) for( S32 i = 0; i < UI_CURSOR_COUNT; i++ )
@@ -1673,18 +1679,18 @@ void LLWindowWin32::initCursors()
void LLWindowWin32::setCursor(ECursorType cursor) void LLWindowWin32::updateCursor()
{ {
if (cursor == UI_CURSOR_ARROW if (mNextCursor == UI_CURSOR_ARROW
&& mBusyCount > 0) && mBusyCount > 0)
{ {
cursor = UI_CURSOR_WORKING; mNextCursor = UI_CURSOR_WORKING;
} }
if( mCurrentCursor != cursor ) if( mCurrentCursor != mNextCursor )
{ {
mCurrentCursor = cursor; mCurrentCursor = mNextCursor;
SetCursor( mCursor[cursor] ); SetCursor( mCursor[mNextCursor] );
} }
} }
@@ -1764,6 +1770,8 @@ void LLWindowWin32::gatherInput()
mInputProcessingPaused = FALSE; mInputProcessingPaused = FALSE;
updateCursor();
// clear this once we've processed all mouse messages that might have occurred after // clear this once we've processed all mouse messages that might have occurred after
// we slammed the mouse position // we slammed the mouse position
mMousePositionModified = FALSE; mMousePositionModified = FALSE;

View File

@@ -72,7 +72,7 @@ public:
/*virtual*/ void showCursorFromMouseMove(); /*virtual*/ void showCursorFromMouseMove();
/*virtual*/ void hideCursorUntilMouseMove(); /*virtual*/ void hideCursorUntilMouseMove();
/*virtual*/ BOOL isCursorHidden(); /*virtual*/ BOOL isCursorHidden();
/*virtual*/ void setCursor(ECursorType cursor); /*virtual*/ void updateCursor();
/*virtual*/ ECursorType getCursor() const; /*virtual*/ ECursorType getCursor() const;
/*virtual*/ void captureMouse(); /*virtual*/ void captureMouse();
/*virtual*/ void releaseMouse(); /*virtual*/ void releaseMouse();

View File

@@ -152,6 +152,7 @@ set(viewer_SOURCE_FILES
llconfirmationmanager.cpp llconfirmationmanager.cpp
llconsole.cpp llconsole.cpp
llcontainerview.cpp llcontainerview.cpp
llcurlrequest.cpp
llcurrencyuimanager.cpp llcurrencyuimanager.cpp
llcylinder.cpp llcylinder.cpp
lldebugmessagebox.cpp lldebugmessagebox.cpp
@@ -474,8 +475,6 @@ set(viewer_SOURCE_FILES
llviewerfoldertype.cpp llviewerfoldertype.cpp
llviewergenericmessage.cpp llviewergenericmessage.cpp
llviewergesture.cpp llviewergesture.cpp
#llviewerimage.cpp
#llviewerimagelist.cpp
llviewerinventory.cpp llviewerinventory.cpp
llviewerjoint.cpp llviewerjoint.cpp
llviewerjointattachment.cpp llviewerjointattachment.cpp
@@ -649,6 +648,7 @@ set(viewer_HEADER_FILES
llconfirmationmanager.h llconfirmationmanager.h
llconsole.h llconsole.h
llcontainerview.h llcontainerview.h
llcurlrequest.h
llcurrencyuimanager.h llcurrencyuimanager.h
llcylinder.h llcylinder.h
lldebugmessagebox.h lldebugmessagebox.h
@@ -976,8 +976,6 @@ set(viewer_HEADER_FILES
llviewerfoldertype.h llviewerfoldertype.h
llviewergenericmessage.h llviewergenericmessage.h
llviewergesture.h llviewergesture.h
#llviewerimage.h
#llviewerimagelist.h
llviewerinventory.h llviewerinventory.h
llviewerjoint.h llviewerjoint.h
llviewerjointattachment.h llviewerjointattachment.h
@@ -1372,23 +1370,28 @@ if (FMOD OR FMODEX)
endif (FMOD) endif (FMOD)
if (DARWIN) if (DARWIN)
set(fmodwrapper_SOURCE_FILES fmodwrapper.cpp) if(FMOD)
add_library(fmodwrapper SHARED ${fmodwrapper_SOURCE_FILES}) set(fmodwrapper_SOURCE_FILES fmodwrapper.cpp)
if (FMODEX) add_library(fmodwrapper SHARED ${fmodwrapper_SOURCE_FILES})
set(fmodwrapper_needed_LIBRARIES ${FMODEX_LIBRARY} ${CARBON_LIBRARY}) if (FMODEX)
endif (FMODEX) set(fmodwrapper_needed_LIBRARIES ${FMODEX_LIBRARY} ${CARBON_LIBRARY})
if (FMOD) endif (FMODEX)
set(fmodwrapper_needed_LIBRARIES ${FMOD_LIBRARY} ${CARBON_LIBRARY}) if (FMOD)
endif (FMOD) set(fmodwrapper_needed_LIBRARIES ${FMOD_LIBRARY} ${CARBON_LIBRARY})
set_target_properties( endif (FMOD)
fmodwrapper set_target_properties(
PROPERTIES fmodwrapper
BUILD_WITH_INSTALL_RPATH 1 PROPERTIES
INSTALL_NAME_DIR "@executable_path/../Resources" BUILD_WITH_INSTALL_RPATH 1
LINK_FLAGS "-unexported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/fmod_hidden_symbols.exp" INSTALL_NAME_DIR "@executable_path/../Resources"
) LINK_FLAGS "-unexported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/fmod_hidden_symbols.exp"
set(FMODWRAPPER_LIBRARY fmodwrapper) )
target_link_libraries(fmodwrapper ${fmodwrapper_needed_LIBRARIES}) set(FMODWRAPPER_LIBRARY fmodwrapper)
target_link_libraries(fmodwrapper ${fmodwrapper_needed_LIBRARIES})
endif(FMOD)
if(FMODEX)
set(FMODWRAPPER_LIBRARY ${FMODEX_LIBRARY})
endif(FMODEX)
else (DARWIN) else (DARWIN)
# fmodwrapper unnecessary on linux or windows, for fmod and fmodex # fmodwrapper unnecessary on linux or windows, for fmod and fmodex
if (FMODEX) if (FMODEX)
@@ -1798,7 +1801,7 @@ endif (WINDOWS)
if (DARWIN) if (DARWIN)
# Don't do this here -- it's taken care of by viewer_manifest.py # Don't do this here -- it's taken care of by viewer_manifest.py
# add_custom_command(TARGET ${VIEWER_BINARY_NAME} POST_BUILD # add_custom_command(TARGET ${VIEWER_BINARY_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llplugin/ # COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib/release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llplugin/
# DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib # DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib/release/libllqtwebkit.dylib
# ) # )
endif (DARWIN) endif (DARWIN)

View File

@@ -2,6 +2,6 @@
CFBundleName = "Singularity"; CFBundleName = "Singularity";
CFBundleShortVersionString = "Singularity Viewer 1.5.0.0"; CFBundleShortVersionString = "Singularity Viewer 1.7.0.0";
CFBundleGetInfoString = "Singularity Viewer 1.5.0.0, Copyright 2010 Siana Gearz"; CFBundleGetInfoString = "Singularity Viewer 1.7.0.0, Copyright 2012 Siana Gearz";

View File

@@ -9,7 +9,7 @@
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>singularity.icns</string> <string>singularity.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.secondlife.indra.viewer</string> <string>org.singularityviewer.singularity</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>

View File

@@ -786,6 +786,18 @@
<real>0.7843137254902</real> <real>0.7843137254902</real>
<real>1</real> <real>1</real>
</array> </array>
</map>
<key>5886ec80-cf56-11e1-9b23-0800200c9a66</key>
<map>
<key>name</key>
<string>Voodoo</string>
<key>color</key>
<array>
<real>0.70588235294118</real>
<real>0.7843137254902</real>
<real>0.7843137254902</real>
<real>1</real>
</array>
</map> </map>
<key>734bae36-a197-b087-ee2d-a098d58fed55</key> <key>734bae36-a197-b087-ee2d-a098d58fed55</key>
<map> <map>

View File

@@ -4006,17 +4006,6 @@
<key>Value</key> <key>Value</key>
<real>120.0</real> <real>120.0</real>
</map> </map>
<key>CurlUseMultipleThreads</key>
<map>
<key>Comment</key>
<string>Use background threads for executing curl_multi_perform (requires restart)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
</map>
<key>Cursor3D</key> <key>Cursor3D</key>
<map> <map>
<key>Comment</key> <key>Comment</key>

View File

@@ -214,6 +214,8 @@
<string>F32</string> <string>F32</string>
<key>Value</key> <key>Value</key>
<real>0.5</real> <real>0.5</real>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>BuildPrefs_Ysize</key> <key>BuildPrefs_Ysize</key>
<map> <map>
@@ -225,6 +227,8 @@
<string>F32</string> <string>F32</string>
<key>Value</key> <key>Value</key>
<real>0.5</real> <real>0.5</real>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>BuildPrefs_Zsize</key> <key>BuildPrefs_Zsize</key>
<map> <map>
@@ -236,6 +240,8 @@
<string>F32</string> <string>F32</string>
<key>Value</key> <key>Value</key>
<real>0.5</real> <real>0.5</real>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Phantom</key> <key>EmeraldBuildPrefs_Phantom</key>
<map> <map>
@@ -247,6 +253,8 @@
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Temporary</key> <key>EmeraldBuildPrefs_Temporary</key>
<map> <map>
@@ -258,6 +266,8 @@
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Physical</key> <key>EmeraldBuildPrefs_Physical</key>
<map> <map>
@@ -269,6 +279,8 @@
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_EmbedItem</key> <key>EmeraldBuildPrefs_EmbedItem</key>
<map> <map>
@@ -280,6 +292,8 @@
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>BuildPrefs_Material</key> <key>BuildPrefs_Material</key>
<map> <map>
@@ -291,6 +305,8 @@
<string>String</string> <string>String</string>
<key>Value</key> <key>Value</key>
<string>Wood</string> <string>Wood</string>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Color</key> <key>EmeraldBuildPrefs_Color</key>
<map> <map>
@@ -307,6 +323,8 @@
<real>1.0</real> <real>1.0</real>
<real>1.0</real> <real>1.0</real>
</array> </array>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Texture</key> <key>EmeraldBuildPrefs_Texture</key>
<map> <map>
@@ -318,6 +336,8 @@
<string>String</string> <string>String</string>
<key>Value</key> <key>Value</key>
<string>89556747-24cb-43ed-920b-47caed15465f</string> <string>89556747-24cb-43ed-920b-47caed15465f</string>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Alpha</key> <key>EmeraldBuildPrefs_Alpha</key>
<map> <map>
@@ -329,6 +349,8 @@
<string>F32</string> <string>F32</string>
<key>Value</key> <key>Value</key>
<real>0.0</real> <real>0.0</real>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Glow</key> <key>EmeraldBuildPrefs_Glow</key>
<map> <map>
@@ -340,6 +362,8 @@
<string>F32</string> <string>F32</string>
<key>Value</key> <key>Value</key>
<real>0.0</real> <real>0.0</real>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_FullBright</key> <key>EmeraldBuildPrefs_FullBright</key>
<map> <map>
@@ -351,6 +375,8 @@
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
<key>EmeraldBuildPrefs_Shiny</key> <key>EmeraldBuildPrefs_Shiny</key>
<map> <map>
@@ -362,6 +388,21 @@
<string>String</string> <string>String</string>
<key>Value</key> <key>Value</key>
<string>None</string> <string>None</string>
<key>IsCOA</key>
<integer>1</integer>
</map>
<key>LiruEnableBuildPrefs</key>
<map>
<key>Comment</key>
<string>When false, disables all defaults set in the building preferences panel, without resetting them.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<string>1</string>
<key>IsCOA</key>
<integer>1</integer>
</map> </map>
</map> </map>
</llsd> </llsd>

View File

@@ -40,6 +40,28 @@
<string>Boolean</string> <string>Boolean</string>
<key>Value</key> <key>Value</key>
<integer>0</integer> <integer>0</integer>
</map>
<key>SHFMODExStreamBufferSize</key>
<map>
<key>Comment</key>
<string>Sets the streaming buffer size (in milliseconds)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>7000</integer>
</map>
<key>SHFMODExDecodeBufferSize</key>
<map>
<key>Comment</key>
<string>Sets the streaming decode buffer size (in milliseconds)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>1000</integer>
</map> </map>
<key>SHAllowScriptCommands</key> <key>SHAllowScriptCommands</key>
<map> <map>

View File

@@ -0,0 +1,28 @@
<llsd>
<array>
<array>
<real>0.003472220851108431816101074</real>
<string>[NB] Aftermath 0000</string>
</array>
<array>
<real>0.2083332538604736328125</real>
<string>[NB] Aftermath 0500</string>
</array>
<array>
<real>0.4131942689418792724609375</real>
<string>[NB] Aftermath 1200</string>
</array>
<array>
<real>0.652777493000030517578125</real>
<string>[NB] Aftermath 1630</string>
</array>
<array>
<real>0.760416328907012939453125</real>
<string>[NB] Aftermath 1750</string>
</array>
<array>
<real>0.843749701976776123046875</real>
<string>[NB] Aftermath 2000</string>
</array>
</array>
</llsd>

View File

@@ -0,0 +1,32 @@
<llsd>
<array>
<array>
<real>0.003472220851108431816101074</real>
<string>[NB] P-Haze 0000</string>
</array>
<array>
<real>0.1840276867151260375976562</real>
<string>[NB] P-Haze 0430</string>
</array>
<array>
<real>0.333333194255828857421875</real>
<string>[NB] P-Haze 0800</string>
</array>
<array>
<real>0.4999997913837432861328125</real>
<string>[NB] P-Haze 1200</string>
</array>
<array>
<real>0.66666638851165771484375</real>
<string>[NB] P-Haze 1700</string>
</array>
<array>
<real>0.749999701976776123046875</real>
<string>[NB] P-Haze 1800</string>
</array>
<array>
<real>0.83333301544189453125</real>
<string>[NB] P-Haze 2000</string>
</array>
</array>
</llsd>

View File

@@ -0,0 +1,32 @@
<llsd>
<array>
<array>
<real>0.003472220851108431816101074</real>
<string>[NB] Sepia 0000</string>
</array>
<array>
<real>0.1840276867151260375976562</real>
<string>[NB] Sepia 0430</string>
</array>
<array>
<real>0.333333194255828857421875</real>
<string>[NB] Sepia 0800</string>
</array>
<array>
<real>0.4999997913837432861328125</real>
<string>[NB] Sepia 1200</string>
</array>
<array>
<real>0.66666638851165771484375</real>
<string>[NB] Sepia 1700</string>
</array>
<array>
<real>0.749999701976776123046875</real>
<string>[NB] Sepia 1800</string>
</array>
<array>
<real>0.83333301544189453125</real>
<string>[NB] Sepia 2000</string>
</array>
</array>
</llsd>

View File

@@ -0,0 +1,44 @@
<llsd>
<array>
<array>
<real>0.1666665971279144287109375</real>
<string>[NB]-MistyDay-4am</string>
</array>
<array>
<real>0.229166567325592041015625</real>
<string>[NB]-MistyDay-5am</string>
</array>
<array>
<real>0.2499998956918716430664062</real>
<string>[NB]-MistyDay-6am</string>
</array>
<array>
<real>0.4999997913837432861328125</real>
<string>[NB]-MistyDay-12pm</string>
</array>
<array>
<real>0.66666638851165771484375</real>
<string>[NB]-MistyDay-4pm</string>
</array>
<array>
<real>0.70833301544189453125</real>
<string>[NB]-MistyDay-5pm</string>
</array>
<array>
<real>0.743055284023284912109375</real>
<string>[NB]-MistyDay-6pm</string>
</array>
<array>
<real>0.77083301544189453125</real>
<string>[NB]-MistyDay-7pm</string>
</array>
<array>
<real>0.874999582767486572265625</real>
<string>[NB]-MistyDay-9pm</string>
</array>
<array>
<real>0.996527373790740966796875</real>
<string>[NB]-MistyDay-12am</string>
</array>
</array>
</llsd>

View File

@@ -0,0 +1,20 @@
<llsd>
<array>
<array>
<real>0.24652767181396484</real>
<string>[Tarnix] Ultrabright Night</string>
</array>
<array>
<real>0.24999989569187164</real>
<string>[Tarnix] Ultrabright Morning</string>
</array>
<array>
<real>0.49652755260467529</real>
<string>[Tarnix] Ultrabright Day</string>
</array>
<array>
<real>0.90277743339538574</real>
<string>[Tarnix] Ultrabright Night</string>
</array>
</array>
</llsd>

View File

@@ -0,0 +1,36 @@
<llsd>
<array>
<array>
<real>0</real>
<string>Realistic Night</string>
</array>
<array>
<real>0.12499994784593582</real>
<string>Realistic 3AM</string>
</array>
<array>
<real>0.24652767181396484</real>
<string>Realistic 6AM</string>
</array>
<array>
<real>0.37499985098838806</real>
<string>A-9AM</string>
</array>
<array>
<real>0.49999979138374329</real>
<string>Realistic</string>
</array>
<array>
<real>0.62499970197677612</real>
<string>A-3PM</string>
</array>
<array>
<real>0.74999970197677612</real>
<string>Realistic 6PM</string>
</array>
<array>
<real>0.87499958276748657</real>
<string>Realistic 9PM</string>
</array>
</array>
</llsd>

View File

@@ -2,17 +2,17 @@
<map> <map>
<key>ambient</key> <key>ambient</key>
<array> <array>
<real>0.51940256357192993</real> <real>1.4699999094009399</real>
<real>0.61718720197677612</real> <real>1.4699999094009399</real>
<real>0.84000003337860107</real> <real>1.4699999094009399</real>
<real>0.2800000011920929</real> <real>0.48999997973442078</real>
</array> </array>
<key>blue_density</key> <key>blue_density</key>
<array> <array>
<real>0.14522500336170197</real> <real>0.099999994039535522</real>
<real>0.39999699592590332</real> <real>0.037499997764825821</real>
<real>0.80000197887420654</real> <real>0.067499987781047821</real>
<real>1</real> <real>0.049999997019767761</real>
</array> </array>
<key>blue_horizon</key> <key>blue_horizon</key>
<array> <array>
@@ -23,60 +23,60 @@
</array> </array>
<key>cloud_color</key> <key>cloud_color</key>
<array> <array>
<real>0.12862999737262726</real> <real>0.22999998927116394</real>
<real>0.12862999737262726</real> <real>0.22999998927116394</real>
<real>0.12862999737262726</real> <real>0.22999998927116394</real>
<real>1</real> <real>0.22999998927116394</real>
</array> </array>
<key>cloud_pos_density1</key> <key>cloud_pos_density1</key>
<array> <array>
<real>0.88419097661972046</real> <real>0.88419097661972046</real>
<real>0.53047597408294678</real> <real>0.53047597408294678</real>
<real>0.4270470142364502</real> <real>0.52999997138977051</real>
<real>1</real> <real>1</real>
</array> </array>
<key>cloud_pos_density2</key> <key>cloud_pos_density2</key>
<array> <array>
<real>0.38419300317764282</real> <real>0.2800000011920929</real>
<real>0.5</real> <real>0.19999998807907104</real>
<real>0.125</real> <real>0.31999999284744263</real>
<real>1</real> <real>1</real>
</array> </array>
<key>cloud_scale</key> <key>cloud_scale</key>
<array> <array>
<real>0.41999998688697815</real> <real>0.0099999997764825821</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>cloud_scroll_rate</key> <key>cloud_scroll_rate</key>
<array> <array>
<real>10</real> <real>0</real>
<real>10</real> <real>15.329999446868896</real>
</array> </array>
<key>cloud_shadow</key> <key>cloud_shadow</key>
<array> <array>
<real>0.59999996423721313</real> <real>0</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>density_multiplier</key> <key>density_multiplier</key>
<array> <array>
<real>7.9999997979030013e-005</real> <real>0.00022000000171829015</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>distance_multiplier</key> <key>distance_multiplier</key>
<array> <array>
<real>11.40000057220459</real> <real>16.200000762939453</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>east_angle</key> <key>east_angle</key>
<real>0</real> <real>6.2831854820251465</real>
<key>enable_cloud_scroll</key> <key>enable_cloud_scroll</key>
<array> <array>
<boolean>1</boolean> <boolean>1</boolean>
@@ -84,42 +84,42 @@
</array> </array>
<key>gamma</key> <key>gamma</key>
<array> <array>
<real>1.0099999904632568</real> <real>1.4199999570846558</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>glow</key> <key>glow</key>
<array> <array>
<real>6.4079799652099609</real> <real>18.599998474121094</real>
<real>0.0012815999798476696</real> <real>0.0012815999798476696</real>
<real>-0.42292699217796326</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>haze_density</key> <key>haze_density</key>
<array> <array>
<real>4</real> <real>0</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>haze_horizon</key> <key>haze_horizon</key>
<array> <array>
<real>0.21744099259376526</real> <real>1</real>
<real>0.21744099259376526</real> <real>0.21744099259376526</real>
<real>0.21744099259376526</real> <real>0.21744099259376526</real>
<real>1</real> <real>1</real>
</array> </array>
<key>lightnorm</key> <key>lightnorm</key>
<array> <array>
<real>-0</real> <real>-1.7484555314695172e-007</real>
<real>0.21200713515281677</real> <real>0</real>
<real>0.97726809978485107</real> <real>1</real>
<real>0</real> <real>0</real>
</array> </array>
<key>max_y</key> <key>max_y</key>
<array> <array>
<real>4000</real> <real>403</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
@@ -129,13 +129,13 @@
<key>star_brightness</key> <key>star_brightness</key>
<real>0</real> <real>0</real>
<key>sun_angle</key> <key>sun_angle</key>
<real>0.21362832188606262</real> <real>0</real>
<key>sunlight_color</key> <key>sunlight_color</key>
<array> <array>
<real>3</real> <real>0</real>
<real>3</real> <real>0</real>
<real>3</real> <real>0</real>
<real>1</real> <real>0</real>
</array> </array>
</map> </map>
</llsd> </llsd>

View File

@@ -2,24 +2,24 @@
<map> <map>
<key>ambient</key> <key>ambient</key>
<array> <array>
<real>0.2226010262966156</real> <real>1.4699999094009399</real>
<real>0.26450860500335693</real> <real>1.4699999094009399</real>
<real>0.35999998450279236</real> <real>1.4699999094009399</real>
<real>0.11999999731779099</real> <real>0.48999997973442078</real>
</array> </array>
<key>blue_density</key> <key>blue_density</key>
<array> <array>
<real>0.14522500336170197</real> <real>0.14000000059604645</real>
<real>0.39999699592590332</real> <real>0.14000000059604645</real>
<real>0.80000197887420654</real> <real>0.14000000059604645</real>
<real>1</real> <real>0.070000000298023224</real>
</array> </array>
<key>blue_horizon</key> <key>blue_horizon</key>
<array> <array>
<real>0.15130999684333801</real> <real>0.83809572458267212</real>
<real>0.30000001192092896</real> <real>1.0735483169555664</real>
<real>0.35131001472473145</real> <real>1.2799999713897705</real>
<real>1</real> <real>0.63999998569488525</real>
</array> </array>
<key>cloud_color</key> <key>cloud_color</key>
<array> <array>
@@ -30,7 +30,7 @@
</array> </array>
<key>cloud_pos_density1</key> <key>cloud_pos_density1</key>
<array> <array>
<real>0.88419097661972046</real> <real>0.70999997854232788</real>
<real>0.53047597408294678</real> <real>0.53047597408294678</real>
<real>0.4270470142364502</real> <real>0.4270470142364502</real>
<real>1</real> <real>1</real>
@@ -44,7 +44,7 @@
</array> </array>
<key>cloud_scale</key> <key>cloud_scale</key>
<array> <array>
<real>0.41999998688697815</real> <real>0.72999995946884155</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
@@ -56,14 +56,14 @@
</array> </array>
<key>cloud_shadow</key> <key>cloud_shadow</key>
<array> <array>
<real>0</real> <real>0.2199999988079071</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>density_multiplier</key> <key>density_multiplier</key>
<array> <array>
<real>0.0001250890054507181</real> <real>0.00017999998817685992</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
@@ -76,7 +76,7 @@
<real>1</real> <real>1</real>
</array> </array>
<key>east_angle</key> <key>east_angle</key>
<real>1.8849555253982544</real> <real>0</real>
<key>enable_cloud_scroll</key> <key>enable_cloud_scroll</key>
<array> <array>
<boolean>1</boolean> <boolean>1</boolean>
@@ -84,42 +84,42 @@
</array> </array>
<key>gamma</key> <key>gamma</key>
<array> <array>
<real>1.7300000190734863</real> <real>1.6899999380111694</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>glow</key> <key>glow</key>
<array> <array>
<real>0.19999980926513672</real> <real>6.4079799652099609</real>
<real>0.0012815999798476696</real> <real>0.0012815999798476696</real>
<real>0</real> <real>-0.39999997615814209</real>
<real>1</real> <real>1</real>
</array> </array>
<key>haze_density</key> <key>haze_density</key>
<array> <array>
<real>1.6499999761581421</real> <real>1.4900000095367432</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
</array> </array>
<key>haze_horizon</key> <key>haze_horizon</key>
<array> <array>
<real>0.14999999105930328</real> <real>0</real>
<real>0.21744099259376526</real> <real>0.21744099259376526</real>
<real>0.21744099259376526</real> <real>0.21744099259376526</real>
<real>1</real> <real>1</real>
</array> </array>
<key>lightnorm</key> <key>lightnorm</key>
<array> <array>
<real>-0.95105654001235962</real>
<real>0</real> <real>0</real>
<real>-0.30901694297790527</real> <real>0</real>
<real>1</real>
<real>0</real> <real>0</real>
</array> </array>
<key>max_y</key> <key>max_y</key>
<array> <array>
<real>4000</real> <real>805</real>
<real>0</real> <real>0</real>
<real>0</real> <real>0</real>
<real>1</real> <real>1</real>
@@ -127,7 +127,7 @@
<key>preset_num</key> <key>preset_num</key>
<integer>2</integer> <integer>2</integer>
<key>star_brightness</key> <key>star_brightness</key>
<real>0</real> <real>1.5699999332427979</real>
<key>sun_angle</key> <key>sun_angle</key>
<real>0</real> <real>0</real>
<key>sunlight_color</key> <key>sunlight_color</key>

View File

@@ -1,141 +0,0 @@
<llsd>
<map>
<key>ambient</key>
<array>
<real>1.0384939114611456</real>
<real>0.95795135955843591</real>
<real>0.95795135955843591</real>
<real>0.60696905358246056</real>
</array>
<key>blue_density</key>
<array>
<real>0.20658362946772124</real>
<real>0.43003502308076946</real>
<real>0.77534221609780829</real>
<real>0.61779229342937469</real>
</array>
<key>blue_horizon</key>
<array>
<real>0.34674560611608651</real>
<real>0.38732792231055679</real>
<real>0.49042100459337234</real>
<real>0.58080440759658813</real>
</array>
<key>cloud_color</key>
<array>
<real>0.33948845342081757</real>
<real>0.33948845342081757</real>
<real>0.33948845342081757</real>
<real>0.6362861692905426</real>
</array>
<key>cloud_pos_density1</key>
<array>
<real>1.6884100437164307</real>
<real>0.52609699964523315</real>
<real>0.95397572096092276</real>
<real>1.0000000298023224</real>
</array>
<key>cloud_pos_density2</key>
<array>
<real>1.6884100437164307</real>
<real>0.52609699964523315</real>
<real>0.1250000037252903</real>
<real>1.0000000298023224</real>
</array>
<key>cloud_scale</key>
<array>
<real>0.41999998722208165</real>
<real>0</real>
<real>0</real>
<real>1.0000000298023224</real>
</array>
<key>cloud_scroll_rate</key>
<array>
<real>10.314831098603321</real>
<real>10.011000171161356</real>
</array>
<key>cloud_shadow</key>
<array>
<real>0.26999998092651367</real>
<real>0</real>
<real>0</real>
<real>1.0000000298023224</real>
</array>
<key>density_multiplier</key>
<array>
<real>0.0002873900482277883</real>
<real>0</real>
<real>0</real>
<real>1.0000000298023224</real>
</array>
<key>distance_multiplier</key>
<array>
<real>0.87670719623565674</real>
<real>0</real>
<real>0</real>
<real>1.0000000298023224</real>
</array>
<key>east_angle</key>
<real>0</real>
<key>enable_cloud_scroll</key>
<array>
<boolean>1</boolean>
<boolean>1</boolean>
</array>
<key>gamma</key>
<array>
<real>1.0000000298023224</real>
<real>0</real>
<real>0</real>
<real>1.0000000298023224</real>
</array>
<key>glow</key>
<array>
<real>5.0000001490116119</real>
<real>0.0010000000917914607</real>
<real>-0.48000001257440683</real>
<real>1.0000000298023224</real>
</array>
<key>haze_density</key>
<array>
<real>0.70000002224998603</real>
<real>0</real>
<real>0</real>
<real>1.0000000298023224</real>
</array>
<key>haze_horizon</key>
<array>
<real>0.1784939272396473</real>
<real>0.1991560042470284</real>
<real>0.1991560042470284</real>
<real>1.0000000298023224</real>
</array>
<key>lightnorm</key>
<array>
<real>0</real>
<real>0.49086946249008179</real>
<real>-0.87123316526412964</real>
<real>0</real>
</array>
<key>max_y</key>
<array>
<real>1205.163865879178</real>
<real>0</real>
<real>0</real>
<real>1.0000000298023224</real>
</array>
<key>preset_num</key>
<integer>22</integer>
<key>star_brightness</key>
<real>0</real>
<key>sun_angle</key>
<real>2.6285052299499512</real>
<key>sunlight_color</key>
<array>
<real>1.5413080077610317</real>
<real>1.5705089192829433</real>
<real>1.6435112576923672</real>
<real>0.56847512722015381</real>
</array>
</map>
</llsd>

View File

@@ -1,141 +0,0 @@
<llsd>
<map>
<key>ambient</key>
<array>
<real>1.0499999460917593</real>
<real>1.0499999460917593</real>
<real>1.0499999460917593</real>
<real>0.34999999512411506</real>
</array>
<key>blue_density</key>
<array>
<real>0.2447581519847149</real>
<real>0.44872328351986113</real>
<real>0.75999999517881633</real>
<real>0.38000003464613324</real>
</array>
<key>blue_horizon</key>
<array>
<real>0.49548381839263711</real>
<real>0.49548381254157786</real>
<real>0.63999999116870609</real>
<real>0.31999999558435305</real>
</array>
<key>cloud_color</key>
<array>
<real>0.40999999615399413</real>
<real>0.40999999615399413</real>
<real>0.40999999615399413</real>
<real>0.40999999615399413</real>
</array>
<key>cloud_pos_density1</key>
<array>
<real>1.6884100437164307</real>
<real>0.52609699964523315</real>
<real>0.99999999999999423</real>
<real>1</real>
</array>
<key>cloud_pos_density2</key>
<array>
<real>1.6884100437164307</real>
<real>0.52609699964523315</real>
<real>0.125</real>
<real>1</real>
</array>
<key>cloud_scale</key>
<array>
<real>0.41999998778293413</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>cloud_scroll_rate</key>
<array>
<real>10.199999843971682</real>
<real>10.010999677075688</real>
</array>
<key>cloud_shadow</key>
<array>
<real>0.26999998092651367</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>density_multiplier</key>
<array>
<real>0.00017999998844229546</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>distance_multiplier</key>
<array>
<real>0.80000000975177565</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>east_angle</key>
<real>0</real>
<key>enable_cloud_scroll</key>
<array>
<boolean>1</boolean>
<boolean>1</boolean>
</array>
<key>gamma</key>
<array>
<real>1</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>glow</key>
<array>
<real>5</real>
<real>0.0010000000429292444</real>
<real>-0.47999999271352323</real>
<real>1</real>
</array>
<key>haze_density</key>
<array>
<real>0.69999999024823012</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>haze_horizon</key>
<array>
<real>0.18999999879470264</real>
<real>0.19915600203784933</real>
<real>0.19915600203784933</real>
<real>1</real>
</array>
<key>lightnorm</key>
<array>
<real>0</real>
<real>0.80060893297195435</real>
<real>-0.59918725490570068</real>
<real>0</real>
</array>
<key>max_y</key>
<array>
<real>1604.9999940395355</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>preset_num</key>
<integer>22</integer>
<key>star_brightness</key>
<real>0</real>
<key>sun_angle</key>
<real>2.2132818698883057</real>
<key>sunlight_color</key>
<array>
<real>0.73421055652810585</real>
<real>0.78157895060378157</real>
<real>0.89999998049645447</real>
<real>0.29999998164705199</real>
</array>
</map>
</llsd>

View File

@@ -1,141 +0,0 @@
<llsd>
<map>
<key>ambient</key>
<array>
<real>0.71999996900558472</real>
<real>0.71999996900558472</real>
<real>0.71999996900558472</real>
<real>0.23999999463558197</real>
</array>
<key>blue_density</key>
<array>
<real>0</real>
<real>0</real>
<real>0</real>
<real>0</real>
</array>
<key>blue_horizon</key>
<array>
<real>0</real>
<real>0</real>
<real>0.43999999761581421</real>
<real>0.2199999988079071</real>
</array>
<key>cloud_color</key>
<array>
<real>0.14000000059604645</real>
<real>0.14000000059604645</real>
<real>0.14000000059604645</real>
<real>0.14000000059604645</real>
</array>
<key>cloud_pos_density1</key>
<array>
<real>0.74000000953674316</real>
<real>0.93999999761581421</real>
<real>0.20999999344348907</real>
<real>1</real>
</array>
<key>cloud_pos_density2</key>
<array>
<real>0.65999996662139893</real>
<real>0.52999997138977051</real>
<real>0.0099999997764825821</real>
<real>1</real>
</array>
<key>cloud_scale</key>
<array>
<real>0.070000000298023224</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>cloud_scroll_rate</key>
<array>
<real>18</real>
<real>20</real>
</array>
<key>cloud_shadow</key>
<array>
<real>0.34000000357627869</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>density_multiplier</key>
<array>
<real>0.00018000000272877514</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>distance_multiplier</key>
<array>
<real>6.7000002861022949</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>east_angle</key>
<real>3.5185837745666504</real>
<key>enable_cloud_scroll</key>
<array>
<boolean>1</boolean>
<boolean>1</boolean>
</array>
<key>gamma</key>
<array>
<real>1.0399999618530273</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>glow</key>
<array>
<real>17.399999618530273</real>
<real>0.0010000000474974513</real>
<real>-0.64999997615814209</real>
<real>1</real>
</array>
<key>haze_density</key>
<array>
<real>0.34999999403953552</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>haze_horizon</key>
<array>
<real>0.17000000178813934</real>
<real>0.19915600121021271</real>
<real>0.19915600121021271</real>
<real>1</real>
</array>
<key>lightnorm</key>
<array>
<real>0.36812454462051392</real>
<real>1.7484555314695172e-007</real>
<real>-0.92977648973464966</real>
<real>0</real>
</array>
<key>max_y</key>
<array>
<real>263</real>
<real>0</real>
<real>0</real>
<real>1</real>
</array>
<key>preset_num</key>
<integer>24</integer>
<key>star_brightness</key>
<real>1.0399999618530273</real>
<key>sun_angle</key>
<real>6.2831854820251465</real>
<key>sunlight_color</key>
<array>
<real>1.5899999141693115</real>
<real>1.5899999141693115</real>
<real>1.5899999141693115</real>
<real>1.5899999141693115</real>
</array>
</map>
</llsd>

Some files were not shown because too many files have changed in this diff Show More