Compare commits
241 Commits
V2MultiWea
...
curlthread
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8c2087d74 | ||
|
|
7adc0e24ab | ||
|
|
ba65f29a72 | ||
|
|
76eef6fe59 | ||
|
|
fe38f59bbb | ||
|
|
2bcabce1d6 | ||
|
|
ed4c6b7c92 | ||
|
|
785729abdf | ||
|
|
2830b35aa6 | ||
|
|
fb38f6adea | ||
|
|
3a30f1dc71 | ||
|
|
8802d5033f | ||
|
|
3d39564605 | ||
|
|
a8a30ae3b9 | ||
|
|
15af410e6f | ||
|
|
9e5cbf330f | ||
|
|
2fa9334090 | ||
|
|
fcdf5d377e | ||
|
|
756a284048 | ||
|
|
32e2b584b9 | ||
|
|
add52b4d57 | ||
|
|
a4d2cb3d12 | ||
|
|
72fbb3f63e | ||
|
|
c62290accb | ||
|
|
8ad40c5d66 | ||
|
|
cd5a721c23 | ||
|
|
643844c01d | ||
|
|
c84f080fc8 | ||
|
|
5fcdbfdd9e | ||
|
|
96fa4af939 | ||
|
|
2334793554 | ||
|
|
20e445b4be | ||
|
|
051263117d | ||
|
|
085db93fc8 | ||
|
|
8fe6925414 | ||
|
|
57ad7e62d2 | ||
|
|
03608103b8 | ||
|
|
675d171104 | ||
|
|
405af67f45 | ||
|
|
f772cbee51 | ||
|
|
72d93b8723 | ||
|
|
7f78870295 | ||
|
|
706b9c55c2 | ||
|
|
48ae0d003d | ||
|
|
51c5933b76 | ||
|
|
0204d09a89 | ||
|
|
465c6b9ed6 | ||
|
|
39847c4688 | ||
|
|
7721c6e3da | ||
|
|
648ed00ce2 | ||
|
|
87c9358813 | ||
|
|
64b968b262 | ||
|
|
c0fbf4bf55 | ||
|
|
900e533b4b | ||
|
|
01818582cf | ||
|
|
9a0620f140 | ||
|
|
0216925e05 | ||
|
|
32b24a98ca | ||
|
|
93d7a4938a | ||
|
|
56265b78ec | ||
|
|
6ee76aa6f7 | ||
|
|
32d6aefe00 | ||
|
|
84795863e5 | ||
|
|
9deb3e433c | ||
|
|
92a5b14347 | ||
|
|
891a330955 | ||
|
|
3cee90fe8b | ||
|
|
2bb58bac2e | ||
|
|
9dc1897b35 | ||
|
|
7a7da24df5 | ||
|
|
46f7250f08 | ||
|
|
58bfe23e5a | ||
|
|
ccb914ea83 | ||
|
|
10fe67f4a6 | ||
|
|
a34247ebf4 | ||
|
|
53e96b02c0 | ||
|
|
7c022d6061 | ||
|
|
14e5b46687 | ||
|
|
0243c61ea1 | ||
|
|
d73d4e9d48 | ||
|
|
3d60d9e3c5 | ||
|
|
329b708aaf | ||
|
|
59e0367dd4 | ||
|
|
56c85813ee | ||
|
|
a6bb2604f6 | ||
|
|
b2c71c099f | ||
|
|
102eca7d65 | ||
|
|
55a1d54b8e | ||
|
|
0c313807ff | ||
|
|
d5e685aaf2 | ||
|
|
214fc0419d | ||
|
|
1e24b889dd | ||
|
|
08dd79fafd | ||
|
|
988e2c3fdf | ||
|
|
92dc20850d | ||
|
|
fa9c366076 | ||
|
|
08ab36a5d9 | ||
|
|
c1c04b489c | ||
|
|
0caa321fe5 | ||
|
|
3acaf773b8 | ||
|
|
5080746fa0 | ||
|
|
66c95af093 | ||
|
|
9241816a71 | ||
|
|
07e1f0e802 | ||
|
|
340f8f1f17 | ||
|
|
0316b7ff9a | ||
|
|
7416d2aaf1 | ||
|
|
cb61342e58 | ||
|
|
d99de40b2b | ||
|
|
533675416c | ||
|
|
8baceee06c | ||
|
|
f7bf5c33bc | ||
|
|
f8445030c7 | ||
|
|
1d60131df7 | ||
|
|
539b6410fa | ||
|
|
75f067d5c9 | ||
|
|
518e9b7513 | ||
|
|
0314bb4d38 | ||
|
|
ddfe004204 | ||
|
|
07375e7a39 | ||
|
|
44b69f3d3e | ||
|
|
bca4cf8584 | ||
|
|
4f3f503953 | ||
|
|
1df635a164 | ||
|
|
f3ae5789be | ||
|
|
cf7cd21474 | ||
|
|
0f8fbcfcc1 | ||
|
|
a1f9109392 | ||
|
|
c648be6410 | ||
|
|
6fa0b668ba | ||
|
|
1925b24512 | ||
|
|
1101b4075a | ||
|
|
edb144bd1d | ||
|
|
bcefad1a97 | ||
|
|
fe65e19b67 | ||
|
|
1b6ef97f45 | ||
|
|
ce0e0a2d38 | ||
|
|
e7aeffc271 | ||
|
|
648766ad44 | ||
|
|
176c91097a | ||
|
|
515b1488c6 | ||
|
|
6868e2f7c1 | ||
|
|
c71c7ca7cc | ||
|
|
2f743fe2ce | ||
|
|
b19c284eb7 | ||
|
|
0419f8bee9 | ||
|
|
18638cd47c | ||
|
|
23e6c9c9e8 | ||
|
|
fa9c48a376 | ||
|
|
a67fe755cd | ||
|
|
f012f664d2 | ||
|
|
80e44fe414 | ||
|
|
42c7a30280 | ||
|
|
e9ec04a449 | ||
|
|
f7d9cd1b8e | ||
|
|
5cc687f5dc | ||
|
|
e7f8206c96 | ||
|
|
6581cb2929 | ||
|
|
b8f7e193d6 | ||
|
|
95b0421074 | ||
|
|
1228732432 | ||
|
|
191787e5c3 | ||
|
|
ca07daebc7 | ||
|
|
8ec8acf610 | ||
|
|
cb0f4f8f10 | ||
|
|
81123a80f2 | ||
|
|
045caad8f5 | ||
|
|
a76a77a330 | ||
|
|
36a95ec36e | ||
|
|
744563a150 | ||
|
|
389074d1e9 | ||
|
|
93778eccbb | ||
|
|
5637e89568 | ||
|
|
4508ea1cc1 | ||
|
|
6b11776fcf | ||
|
|
525e9d9a8e | ||
|
|
b40a9c7a06 | ||
|
|
0b757aaad5 | ||
|
|
7f1d9a01e6 | ||
|
|
f46d8e8a10 | ||
|
|
d1b6b78206 | ||
|
|
d8c191490f | ||
|
|
24ec85febd | ||
|
|
9565d96006 | ||
|
|
822098b5ac | ||
|
|
02ae36b427 | ||
|
|
f5bfab139c | ||
|
|
259a9ff0cc | ||
|
|
d238cfe753 | ||
|
|
df20f918ba | ||
|
|
b8fc1f634e | ||
|
|
ae9dadb5d8 | ||
|
|
d31c062693 | ||
|
|
31ca817dc0 | ||
|
|
544928a039 | ||
|
|
14276b3cf8 | ||
|
|
07e7eeedd1 | ||
|
|
5748de1f9d | ||
|
|
d0c1c4d753 | ||
|
|
7af331c50d | ||
|
|
125a10bb44 | ||
|
|
9db7bcde00 | ||
|
|
9b8e5c8719 | ||
|
|
a803507d67 | ||
|
|
cb5efad026 | ||
|
|
26922a1578 | ||
|
|
90493b6571 | ||
|
|
2dee921cd5 | ||
|
|
433c7c3f99 | ||
|
|
fef461fd13 | ||
|
|
1f56645b69 | ||
|
|
69ca6cd5b2 | ||
|
|
8805e3fb27 | ||
|
|
64d8397ea5 | ||
|
|
4d4496fc4d | ||
|
|
af67342969 | ||
|
|
d9cbd52ea8 | ||
|
|
8b25d44bcf | ||
|
|
3d6733bed8 | ||
|
|
c3f3db518b | ||
|
|
385ec62e53 | ||
|
|
881524831f | ||
|
|
376be8b990 | ||
|
|
96ddbf2a8b | ||
|
|
c2ee420917 | ||
|
|
74a1ba0d1e | ||
|
|
0dc05a39e6 | ||
|
|
72fe406f64 | ||
|
|
90ac174260 | ||
|
|
b555e02220 | ||
|
|
507c94c24c | ||
|
|
2699fa8cf9 | ||
|
|
513002416c | ||
|
|
22530cd77e | ||
|
|
81521b98fd | ||
|
|
73c2feee97 | ||
|
|
d4212d390d | ||
|
|
2b8a55f396 | ||
|
|
f253da09ec | ||
|
|
e232abdab2 | ||
|
|
fae40e0bdf |
@@ -1,19 +0,0 @@
|
||||
ELFIO.h - ELF reader and producer.
|
||||
Copyright (C) 2001 Serge Lamikhov-Center <to_serge@users.sourceforge.net>
|
||||
|
||||
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; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
The GNU Library GPL is available at http://www.gnu.org/copyleft/lesser.html
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
http://www.jclark.com/xml/copying.txt
|
||||
|
||||
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
http://xmlsoft.org/
|
||||
http://www.opensource.org/licenses/mit-license.html
|
||||
|
||||
Open Source Initiative OSI - The MIT License:Licensing
|
||||
Tue, 2006-10-31 04:56 . nelson
|
||||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@@ -1,484 +0,0 @@
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
The pristine version of Qt corresponding to this build is available at:
|
||||
http://viewer-source-downloads.s3.amazonaws.com/install_pkgs/qt-all-opensource-src-4.5.2.tar.bz2
|
||||
|
||||
The patches we applied to the above package to get this build are available at:
|
||||
http://hg.secondlife.com/llqtwebkit/src/tip/qt_patches/
|
||||
@@ -565,6 +565,14 @@
|
||||
<boolean>false</boolean>
|
||||
</map>
|
||||
|
||||
<key>ObjectPhysicsProperties</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>llsd</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>true</boolean>
|
||||
</map>
|
||||
|
||||
<!-- Server to client -->
|
||||
<key>DisplayNameUpdate</key>
|
||||
<map>
|
||||
|
||||
@@ -33,8 +33,8 @@ include(UnixInstall)
|
||||
set (DISABLE_FATAL_WARNINGS TRUE)
|
||||
|
||||
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE ReleaseSSE2 CACHE STRING
|
||||
"Build type. One of: Debug Release ReleaseSSE2 RelWithDebInfo" FORCE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
||||
"Build type. One of: Debug Release RelWithDebInfo" FORCE)
|
||||
endif (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
# Create a 'prepare' target in which to perform setup actions. This
|
||||
|
||||
@@ -12,17 +12,12 @@ set(CMAKE_CXX_FLAGS_RELEASE
|
||||
"-DLL_RELEASE=1 -DLL_RELEASE_FOR_DOWNLOAD=1 -D_SECURE_SCL=0 -DLL_SEND_CRASH_REPORTS=1 -DNDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2
|
||||
"-DLL_RELEASE=1 -DLL_RELEASE_FOR_DOWNLOAD=1 -D_SECURE_SCL=0 -DLL_SEND_CRASH_REPORTS=1 -DNDEBUG")
|
||||
#llimage now requires this (?)
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2
|
||||
"${CMAKE_CXX_FLAGS_RELEASESSE2}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
"-DLL_RELEASE=1 -D_SECURE_SCL=0 -DLL_SEND_CRASH_REPORTS=0 -DNDEBUG -DLL_RELEASE_WITH_DEBUG_INFO=1")
|
||||
|
||||
# Don't bother with a MinSizeRel build.
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;ReleaseSSE2;Debug" CACHE STRING
|
||||
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;Debug" CACHE STRING
|
||||
"Supported build types." FORCE)
|
||||
|
||||
# Platform-specific compilation flags.
|
||||
@@ -40,23 +35,17 @@ if (WINDOWS)
|
||||
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MD /MP /arch:SSE2"
|
||||
CACHE STRING "C++ compiler release-with-debug options" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP /arch:SSE /fp:fast"
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP /arch:SSE2 /fp:fast"
|
||||
CACHE STRING "C++ compiler release options" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE
|
||||
"${CMAKE_C_FLAGS_RELEASE} ${LL_C_FLAGS} /O2 /Zi /MD /MP /arch:SSE /fp:fast"
|
||||
"${CMAKE_C_FLAGS_RELEASE} ${LL_C_FLAGS} /O2 /Zi /MD /MP /arch:SSE2 /fp:fast"
|
||||
CACHE STRING "C compiler release options" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2
|
||||
"${CMAKE_CXX_FLAGS_RELEASESSE2} ${LL_CXX_FLAGS} /O2 /Zi /MD /MP /arch:SSE2 /fp:fast"
|
||||
CACHE STRING "C++ compiler release-SSE2 options" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2
|
||||
"${CMAKE_C_FLAGS_RELEASESSE2} ${LL_C_FLAGS} /O2 /Zi /MD /MP /arch:SSE2 /fp:fast"
|
||||
CACHE STRING "C compiler release-SSE2 options" FORCE)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LARGEADDRESSAWARE")
|
||||
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "")
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "")
|
||||
|
||||
|
||||
add_definitions(
|
||||
/DLL_WINDOWS=1
|
||||
/DUNICODE
|
||||
@@ -78,12 +67,9 @@ if (WINDOWS)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
|
||||
CACHE STRING "C++ compiler release options" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2
|
||||
"${CMAKE_CXX_FLAGS_RELEASESSE2} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
|
||||
CACHE STRING "C++ compiler release-SSE2 options" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2
|
||||
"${CMAKE_CXX_FLAGS_RELEASESSE2} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
|
||||
CACHE STRING "C compiler release-SSE2 options" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} -D_SECURE_STL=0 -D_HAS_ITERATOR_DEBUGGING=0"
|
||||
CACHE STRING "C compiler release options" FORCE)
|
||||
add_definitions(
|
||||
/Zc:wchar_t-
|
||||
)
|
||||
@@ -144,7 +130,6 @@ if (LINUX)
|
||||
add_definitions(-DLL_IGNORE_SIGCHLD)
|
||||
|
||||
if(${CMAKE_C_COMPILER} MATCHES "gcc*")
|
||||
|
||||
find_program(GXX g++)
|
||||
mark_as_advanced(GXX)
|
||||
|
||||
@@ -197,9 +182,6 @@ if (LINUX)
|
||||
|
||||
# End of hacks.
|
||||
|
||||
#GCC Specific
|
||||
add_definitions(-DCC_GCC)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
||||
|
||||
if (NOT STANDALONE)
|
||||
@@ -208,8 +190,8 @@ if (LINUX)
|
||||
endif (NOT STANDALONE)
|
||||
if (${ARCH} STREQUAL "x86_64")
|
||||
add_definitions(-DLINUX64=1 -pipe)
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -fomit-frame-pointer -mmmx -msse -mfpmath=sse -msse2 -ffast-math -ftree-vectorize -fweb -fexpensive-optimizations -frename-registers")
|
||||
else (${ARCH} STREQUAL "x86_64")
|
||||
@@ -218,18 +200,19 @@ if (LINUX)
|
||||
endif (NOT STANDALONE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
endif (${ARCH} STREQUAL "x86_64")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "clang*")
|
||||
|
||||
find_program(CLANG clang++)
|
||||
find_program(CLANG clang)
|
||||
mark_as_advanced(CLANG)
|
||||
|
||||
find_program(CLANGXX clang++)
|
||||
mark_as_advanced(CLANGXX)
|
||||
|
||||
add_definitions(
|
||||
-DCC_CLANG
|
||||
-D_FORTIFY_SOURCE=2
|
||||
)
|
||||
|
||||
@@ -244,18 +227,39 @@ if (LINUX)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${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")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "icc*" AND ${CMAKE_CXX_COMPILER} MATCHES "icpc*")
|
||||
find_program(ICC icc)
|
||||
mark_as_advanced(ICC)
|
||||
|
||||
add_definitions(
|
||||
-D_FORTIFY_SOURCE=2
|
||||
)
|
||||
|
||||
if (NOT STANDALONE)
|
||||
# this stops us requiring a really recent glibc at runtime
|
||||
add_definitions(-fno-stack-protector)
|
||||
endif (NOT STANDALONE)
|
||||
|
||||
if (NOT STANDALONE)
|
||||
set(MARCH_FLAG " -axsse4.1 -msse2")
|
||||
endif (NOT STANDALONE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline-functions")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline-functions")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${MARCH_FLAG} -parallel -fp-model fast=1")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${MARCH_FLAG} -parallel -fp-model fast=1")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -parallel -fp-model fast=1")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -parallel -fp-model fast=1")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 ${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASESSE2 "-O3 ${CMAKE_CXX_FLAGS_RELEASESSE2}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "-O3 ${CMAKE_C_FLAGS_RELEASESSE2}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
endif (LINUX)
|
||||
@@ -265,16 +269,23 @@ if (DARWIN)
|
||||
add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE)
|
||||
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch")
|
||||
# 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_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}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -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_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2} -O3 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -O3 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
if(${CMAKE_C_COMPILER} MATCHES "gcc*")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch")
|
||||
# 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 -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_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)
|
||||
|
||||
|
||||
@@ -283,8 +294,11 @@ if (LINUX OR DARWIN)
|
||||
set(UNIX_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs")
|
||||
set(UNIX_CXX_WARNINGS "${UNIX_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Woverloaded-virtual")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "clang*")
|
||||
set(UNIX_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-tautological-compare -Wno-char-subscripts -Wno-gnu -Wno-logical-op-parentheses
|
||||
-Wno-non-virtual-dtor -Woverloaded-virtual -Wno-parentheses-equality -Wno-reorder -Wno-unused-function -Wno-unused-value -Wno-unused-variable")
|
||||
set(UNIX_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs -Wno-tautological-compare -Wno-char-subscripts -Wno-gnu -Wno-logical-op-parentheses -Wno-non-virtual-dtor ")
|
||||
set(UNIX_WARNINGS "${UNIX_WARNINGS} -Woverloaded-virtual -Wno-parentheses-equality -Wno-reorder -Wno-unused-function -Wno-unused-value -Wno-unused-variable")
|
||||
set(UNIX_CXX_WARNINGS "${UNIX_WARNINGS}")
|
||||
elseif(${CMAKE_C_COMPILER} MATCHES "icc")
|
||||
set(UNIX_WARNINGS "-wd327 -wd597 -wd858")
|
||||
set(UNIX_CXX_WARNINGS "${UNIX_WARNINGS}")
|
||||
endif()
|
||||
|
||||
@@ -327,16 +341,17 @@ if(1 EQUAL 1)
|
||||
endif (NOT "$ENV{SHY_MOD}" STREQUAL "")
|
||||
endif(1 EQUAL 1)
|
||||
|
||||
SET( CMAKE_EXE_LINKER_FLAGS_RELEASESSE2
|
||||
SET( CMAKE_EXE_LINKER_FLAGS_RELEASE
|
||||
"${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING
|
||||
"Flags used for linking binaries under SSE2 build."
|
||||
"Flags used for linking binaries under build."
|
||||
FORCE )
|
||||
SET( CMAKE_SHARED_LINKER_FLAGS_RELEASESSE2
|
||||
SET( CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_RELEASE}" CACHE STRING
|
||||
"Flags used by the shared libraries linker under SSE2 build."
|
||||
"Flags used by the shared libraries linker under build."
|
||||
FORCE )
|
||||
MARK_AS_ADVANCED(
|
||||
CMAKE_CXX_FLAGS_RELEASESSE2
|
||||
CMAKE_C_FLAGS_RELEASESSE2
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASESSE2
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASESSE2 )
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
)
|
||||
|
||||
@@ -33,8 +33,8 @@ else (STANDALONE)
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.dylib
|
||||
)
|
||||
set(APRUTIL_LIBRARIES
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.0.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.dylib
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libaprutil-1.dylib
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.dylib
|
||||
)
|
||||
set(APRICONV_LIBRARIES iconv)
|
||||
else (WINDOWS)
|
||||
|
||||
@@ -9,7 +9,7 @@ if (STANDALONE)
|
||||
pkg_check_modules(VORBISFILE REQUIRED vorbisfile)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(ogg-vorbis)
|
||||
set(VORBIS_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(VORBIS_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
set(VORBISENC_INCLUDE_DIRS ${VORBIS_INCLUDE_DIRS})
|
||||
set(VORBISFILE_INCLUDE_DIRS ${VORBIS_INCLUDE_DIRS})
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
set(DB_FIND_QUIETLY ON)
|
||||
set(DB_FIND_REQUIRED ON)
|
||||
@@ -8,9 +8,10 @@ if (STANDALONE)
|
||||
else (STANDALONE)
|
||||
if (LINUX)
|
||||
# Need to add dependency pthread explicitely to support ld.gold.
|
||||
set(DB_LIBRARIES db-4.2 pthread)
|
||||
use_prebuilt_binary(db)
|
||||
set(DB_LIBRARIES db-5.1 pthread)
|
||||
else (LINUX)
|
||||
set(DB_LIBRARIES db-4.2)
|
||||
endif (LINUX)
|
||||
set(DB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(DB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -13,7 +13,7 @@ if (STANDALONE)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system-mt)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(boost)
|
||||
set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
|
||||
if (WINDOWS)
|
||||
set(BOOST_VERSION 1_45)
|
||||
@@ -40,10 +40,10 @@ else (STANDALONE)
|
||||
debug libboost_regex-vc${MSVC_SUFFIX}-${BOOST_DEBUG_SUFFIX}-${BOOST_VERSION})
|
||||
|
||||
elseif (DARWIN)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex-mt)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system-mt)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem)
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex)
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system)
|
||||
elseif (LINUX)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt)
|
||||
set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options-mt)
|
||||
|
||||
@@ -29,17 +29,16 @@ set(cmake_SOURCE_FILES
|
||||
FindELFIO.cmake
|
||||
FindGooglePerfTools.cmake
|
||||
FindHunSpell.cmake
|
||||
FindMono.cmake
|
||||
FindMT.cmake
|
||||
FindMySQL.cmake
|
||||
FindNDOF.cmake
|
||||
FindOpenJPEG.cmake
|
||||
FindXmlRpcEpi.cmake
|
||||
FMOD.cmake
|
||||
FMOD.cmake
|
||||
FMODEX.cmake
|
||||
FreeType.cmake
|
||||
GStreamer010Plugin.cmake
|
||||
GooglePerfTools.cmake
|
||||
HUNSPELL.cmake
|
||||
Hunspell.cmake
|
||||
JPEG.cmake
|
||||
LLAddBuildTest.cmake
|
||||
LLAudio.cmake
|
||||
@@ -63,8 +62,6 @@ set(cmake_SOURCE_FILES
|
||||
LLXML.cmake
|
||||
LScript.cmake
|
||||
Linking.cmake
|
||||
MonoEmbed.cmake
|
||||
MySQL.cmake
|
||||
NDOF.cmake
|
||||
OPENAL.cmake
|
||||
OpenGL.cmake
|
||||
@@ -83,10 +80,6 @@ set(cmake_SOURCE_FILES
|
||||
ZLIB.cmake
|
||||
)
|
||||
|
||||
if(FMODEX)
|
||||
list(APPEND cmake_SOURCE_FILES FMODEX.cmake)
|
||||
endif(FMODEX)
|
||||
|
||||
source_group("Shared Rules" FILES ${cmake_SOURCE_FILES})
|
||||
|
||||
set(master_SOURCE_FILES
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
set(CURL_FIND_QUIETLY ON)
|
||||
set(CURL_FIND_QUIETLY OFF)
|
||||
set(CURL_FIND_REQUIRED ON)
|
||||
|
||||
if (STANDALONE)
|
||||
@@ -14,6 +14,9 @@ else (STANDALONE)
|
||||
optimized libcurl)
|
||||
else (WINDOWS)
|
||||
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)
|
||||
set(CURL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -29,6 +29,8 @@ set(debug_files
|
||||
libapr-1.dll
|
||||
libaprutil-1.dll
|
||||
libapriconv-1.dll
|
||||
libeay32.dll
|
||||
ssleay32.dll
|
||||
)
|
||||
|
||||
copy_if_different(
|
||||
@@ -43,10 +45,6 @@ set(all_targets ${all_targets} ${out_targets})
|
||||
set(plugintest_debug_src_dir "${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/debug")
|
||||
set(plugintest_debug_files
|
||||
libeay32.dll
|
||||
libglib-2.0-0.dll
|
||||
libgmodule-2.0-0.dll
|
||||
libgobject-2.0-0.dll
|
||||
libgthread-2.0-0.dll
|
||||
qtcored4.dll
|
||||
qtguid4.dll
|
||||
qtnetworkd4.dll
|
||||
@@ -92,11 +90,6 @@ set(all_targets ${all_targets} ${out_targets})
|
||||
set(plugintest_release_src_dir "${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/release")
|
||||
set(plugintest_release_files
|
||||
libeay32.dll
|
||||
libglib-2.0-0.dll
|
||||
libgmodule-2.0-0.dll
|
||||
libgobject-2.0-0.dll
|
||||
libgthread-2.0-0.dll
|
||||
# llkdu.dll (not required for plugin test)
|
||||
qtcore4.dll
|
||||
qtgui4.dll
|
||||
qtnetwork4.dll
|
||||
@@ -112,14 +105,6 @@ copy_if_different(
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugintest_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/ReleaseSSE2"
|
||||
out_targets
|
||||
${plugintest_release_files}
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugintest_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/RelWithDebInfo"
|
||||
@@ -146,14 +131,6 @@ copy_if_different(
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugintest_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/ReleaseSSE2/imageformats"
|
||||
out_targets
|
||||
${plugintest_release_files}
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugintest_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/../test_apps/llplugintest/RelWithDebInfo/imageformats"
|
||||
@@ -170,14 +147,6 @@ copy_if_different(
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugintest_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2/llplugin/imageformats"
|
||||
out_targets
|
||||
${plugintest_release_files}
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugintest_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/llplugin/imageformats"
|
||||
@@ -224,14 +193,6 @@ copy_if_different(
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugins_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2/llplugin"
|
||||
out_targets
|
||||
${plugins_release_files}
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${plugins_release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/llplugin"
|
||||
@@ -247,46 +208,44 @@ set(release_files
|
||||
libapr-1.dll
|
||||
libaprutil-1.dll
|
||||
libapriconv-1.dll
|
||||
libeay32.dll
|
||||
ssleay32.dll
|
||||
)
|
||||
|
||||
if(FMODEX)
|
||||
find_path(FMODEX_BINARY_DIR fmodex.dll
|
||||
find_path(FMODEX_BINARY_DIR fmodex.dll
|
||||
${release_src_dir}
|
||||
${FMODEX_SDK_DIR}/api
|
||||
${FMODEX_SDK_DIR}
|
||||
)
|
||||
|
||||
if(FMODEX_BINARY_DIR)
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
endif(FMODEX_BINARY_DIR)
|
||||
if(FMODEX_BINARY_DIR)
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMODEX_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets fmodex.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
endif(FMODEX_BINARY_DIR)
|
||||
endif(FMODEX)
|
||||
|
||||
if(FMOD)
|
||||
find_path(FMOD_BINARY_DIR fmod.dll
|
||||
find_path(FMOD_BINARY_DIR fmod.dll
|
||||
${release_src_dir}
|
||||
${FMOD_SDK_DIR}/api
|
||||
${FMOD_SDK_DIR}
|
||||
)
|
||||
|
||||
if(FMOD_BINARY_DIR)
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
else(FMOD_BINARY_DIR)
|
||||
list(APPEND release_files fmod.dll) #Required for compile. This will cause an error in copying binaries.
|
||||
endif(FMOD_BINARY_DIR)
|
||||
if(FMOD_BINARY_DIR)
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Release" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
copy_if_different("${FMOD_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/Debug" out_targets fmod.dll)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
else(FMOD_BINARY_DIR)
|
||||
list(APPEND release_files fmod.dll) #Required for compile. This will cause an error in copying binaries.
|
||||
endif(FMOD_BINARY_DIR)
|
||||
endif(FMOD)
|
||||
|
||||
copy_if_different(
|
||||
@@ -305,22 +264,6 @@ copy_if_different(
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2"
|
||||
out_targets
|
||||
${release_files}
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${vivox_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2"
|
||||
out_targets
|
||||
${vivox_files}
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${release_src_dir}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo"
|
||||
@@ -371,15 +314,6 @@ else(EXISTS ${internal_llkdu_path})
|
||||
COMMENT "Copying llkdu.dll ${CMAKE_CURRENT_BINARY_DIR}/Release"
|
||||
)
|
||||
set(all_targets ${all_targets} ${release_llkdu_dst})
|
||||
|
||||
set(releasesse2_llkdu_dst "${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2/llkdu.dll")
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${releasesse2_llkdu_dst}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${release_llkdu_src} ${releasesse2_llkdu_dst}
|
||||
DEPENDS ${release_llkdu_src}
|
||||
COMMENT "Copying llkdu.dll ${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2"
|
||||
)
|
||||
set(all_targets ${all_targets} ${releasesse2_llkdu_dst})
|
||||
|
||||
set(relwithdebinfo_llkdu_dst "${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/llkdu.dll")
|
||||
ADD_CUSTOM_COMMAND(
|
||||
@@ -455,14 +389,6 @@ if (MSVC80)
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${release_msvc8_redist_path}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2"
|
||||
out_targets
|
||||
${release_msvc8_files}
|
||||
)
|
||||
set(all_targets ${all_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${release_msvc8_redist_path}
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo"
|
||||
@@ -483,19 +409,6 @@ if (MSVC80)
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Release/Microsoft.VC80.CRT.manifest
|
||||
COMMENT "Creating release app config file"
|
||||
)
|
||||
|
||||
set(releasesse2_appconfig_file ${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2/${VIEWER_BINARY_NAME}.exe.config)
|
||||
add_custom_command(
|
||||
OUTPUT ${releasesse2_appconfig_file}
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
ARGS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/build_win32_appConfig.py
|
||||
${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2/Microsoft.VC80.CRT.manifest
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SecondLife.exe.config
|
||||
${releasesse2_appconfig_file}
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ReleaseSSE2/Microsoft.VC80.CRT.manifest
|
||||
COMMENT "Creating release-sse2 app config file"
|
||||
)
|
||||
|
||||
set(relwithdebinfo_appconfig_file ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/${VIEWER_BINARY_NAME}.exe.config)
|
||||
add_custom_command(
|
||||
@@ -517,7 +430,6 @@ add_custom_target(copy_win_libs ALL
|
||||
DEPENDS
|
||||
${all_targets}
|
||||
${release_appconfig_file}
|
||||
${releasesse2_appconfig_file}
|
||||
${relwithdebinfo_appconfig_file}
|
||||
${debug_appconfig_file}
|
||||
)
|
||||
|
||||
@@ -7,15 +7,14 @@ if (STANDALONE)
|
||||
pkg_check_modules(DBUSGLIB REQUIRED dbus-glib-1)
|
||||
|
||||
elseif (LINUX)
|
||||
use_prebuilt_binary(glib) # dbusglib needs glib
|
||||
use_prebuilt_binary(dbusglib)
|
||||
set(DBUSGLIB_FOUND ON FORCE BOOL)
|
||||
set(DBUSGLIB_INCLUDE_DIRS
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/glib-2.0
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/dbus
|
||||
)
|
||||
|
||||
# We don't need to explicitly link against dbus-glib itself, because
|
||||
# the viewer probes for the system's copy at runtime.
|
||||
set(DBUSGLIB_LIBRARIES
|
||||
dbus-glib-1
|
||||
gobject-2.0
|
||||
glib-2.0
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ if (STANDALONE)
|
||||
elseif (LINUX)
|
||||
use_prebuilt_binary(elfio)
|
||||
set(ELFIO_LIBRARIES ELFIO)
|
||||
set(ELFIO_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include)
|
||||
set(ELFIO_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
set(ELFIO_FOUND "YES")
|
||||
endif (STANDALONE)
|
||||
|
||||
|
||||
@@ -13,5 +13,5 @@ else (STANDALONE)
|
||||
else (WINDOWS)
|
||||
set(EXPAT_LIBRARIES expat)
|
||||
endif (WINDOWS)
|
||||
set(EXPAT_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(EXPAT_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -18,7 +18,7 @@ if (NOT FMODEX_LIBRARY)
|
||||
set(FMODEX_SDK_DIR CACHE PATH "Path to the FMOD Ex SDK.")
|
||||
if (FMODEX_SDK_DIR)
|
||||
find_library(FMODEX_LIBRARY
|
||||
fmodex fmodex_vc fmodexL_vc
|
||||
fmodex_vc fmodexL_vc fmodex fmodexL fmodex64 fmodexL64
|
||||
PATHS
|
||||
${FMODEX_SDK_DIR}/api/lib
|
||||
${FMODEX_SDK_DIR}/api
|
||||
|
||||
@@ -24,8 +24,8 @@ EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
|
||||
# Try to find a library that was compiled with the same compiler version as we currently use.
|
||||
SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so)
|
||||
IF (STANDALONE)
|
||||
# On standalone, assume that the system installed library was compiled with the used compiler.
|
||||
SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson.so)
|
||||
# On standalone, assume that the system installed library was compiled with the used compiler.
|
||||
SET(JSONCPP_NAMES ${JSONCPP_NAMES} libjson.so)
|
||||
ENDIF (STANDALONE)
|
||||
FIND_LIBRARY(JSONCPP_LIBRARY
|
||||
NAMES ${JSONCPP_NAMES}
|
||||
|
||||
@@ -35,7 +35,7 @@ find_path(LLQTWEBKIT_INCLUDE_DIR llqtwebkit.h NO_SYSTEM_ENVIRONMENT_PATH HINTS $
|
||||
|
||||
find_library(LLQTWEBKIT_LIBRARY NAMES llqtwebkit NO_SYSTEM_ENVIRONMENT_PATH HINTS ${LLQTWEBKIT_LIBRARY_DIRS})
|
||||
|
||||
if (NOT PKG_CONFIG_FOUND OR NOT LLQTWEBKIT_FOUND) # If pkg-config couldn't find it, pretend we don't have pkg-config.
|
||||
if (NOT PKG_CONFIG_FOUND OR NOT LLQTWEBKIT_FOUND) # If pkg-config couldn't find it, pretend we don't have pkg-config.
|
||||
set(LLQTWEBKIT_LIBRARIES llqtwebkit)
|
||||
get_filename_component(LLQTWEBKIT_LIBRARY_DIRS ${LLQTWEBKIT_LIBRARY} PATH)
|
||||
endif (NOT PKG_CONFIG_FOUND OR NOT LLQTWEBKIT_FOUND)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#Find the windows manifest tool.
|
||||
if (MSVC80)
|
||||
FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt
|
||||
PATHS
|
||||
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin"
|
||||
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
|
||||
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
|
||||
IF(HAVE_MANIFEST_TOOL)
|
||||
MESSAGE(STATUS "Found Mainfest Tool. Embedding custom manifests.")
|
||||
ELSE(HAVE_MANIFEST_TOOL)
|
||||
MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.")
|
||||
ENDIF(HAVE_MANIFEST_TOOL)
|
||||
|
||||
STRING(REPLACE "/MANIFEST " "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
|
||||
${CMAKE_EXE_LINKER_FLAGS})
|
||||
|
||||
endif (MSVC80)
|
||||
#Find the windows manifest tool.
|
||||
if (MSVC80)
|
||||
FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt
|
||||
PATHS
|
||||
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin"
|
||||
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
|
||||
"$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
|
||||
IF(HAVE_MANIFEST_TOOL)
|
||||
MESSAGE(STATUS "Found Mainfest Tool. Embedding custom manifests.")
|
||||
ELSE(HAVE_MANIFEST_TOOL)
|
||||
MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.")
|
||||
ENDIF(HAVE_MANIFEST_TOOL)
|
||||
|
||||
STRING(REPLACE "/MANIFEST " "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
|
||||
${CMAKE_EXE_LINKER_FLAGS})
|
||||
|
||||
endif (MSVC80)
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
# - Try to find the mono, mcs, gmcs and gacutil
|
||||
#
|
||||
# defines
|
||||
#
|
||||
# MONO_FOUND - system has mono, mcs, gmcs and gacutil
|
||||
# MONO_PATH - where to find 'mono'
|
||||
# MCS_PATH - where to find 'mcs'
|
||||
# GMCS_PATH - where to find 'gmcs'
|
||||
# GACUTIL_PATH - where to find 'gacutil'
|
||||
#
|
||||
# copyright (c) 2007 Arno Rehn arno@arnorehn.de
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the GPL license.
|
||||
# Removed the check for gmcs
|
||||
|
||||
FIND_PROGRAM (MONO_EXECUTABLE mono
|
||||
"$ENV{PROGRAMFILES}/Mono-1.9.1/bin"
|
||||
"$ENV{PROGRAMFILES}/Mono-1.2.6/bin"
|
||||
/bin
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
)
|
||||
FIND_PROGRAM (MCS_EXECUTABLE mcs
|
||||
"$ENV{PROGRAMFILES}/Mono-1.9.1/bin"
|
||||
"$ENV{PROGRAMFILES}/Mono-1.2.6/bin"
|
||||
/bin
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
)
|
||||
FIND_PROGRAM (GMCS_EXECUTABLE gmcs
|
||||
"$ENV{PROGRAMFILES}/Mono-1.9.1/bin"
|
||||
"$ENV{PROGRAMFILES}/Mono-1.2.6/bin"
|
||||
/bin
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
)
|
||||
FIND_PROGRAM (GACUTIL_EXECUTABLE gacutil
|
||||
"$ENV{PROGRAMFILES}/Mono-1.9.1/bin"
|
||||
"$ENV{PROGRAMFILES}/Mono-1.2.6/bin"
|
||||
/bin
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
)
|
||||
FIND_PROGRAM (ILASM_EXECUTABLE
|
||||
ilasm
|
||||
NO_DEFAULT_PATH
|
||||
PATHS "$ENV{PROGRAMFILES}/Mono-1.9.1/bin" "$ENV{PROGRAMFILES}/Mono-1.2.6/bin" /bin /usr/bin /usr/local/bin
|
||||
)
|
||||
|
||||
SET (MONO_FOUND FALSE)
|
||||
|
||||
IF (MONO_EXECUTABLE AND MCS_EXECUTABLE AND GACUTIL_EXECUTABLE)
|
||||
SET (MONO_FOUND TRUE)
|
||||
ENDIF (MONO_EXECUTABLE AND MCS_EXECUTABLE AND GACUTIL_EXECUTABLE)
|
||||
|
||||
IF (MONO_FOUND)
|
||||
IF (NOT Mono_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found mono: ${MONO_EXECUTABLE}")
|
||||
MESSAGE(STATUS "Found mcs: ${MCS_EXECUTABLE}")
|
||||
MESSAGE(STATUS "Found gacutil: ${GACUTIL_EXECUTABLE}")
|
||||
ENDIF (NOT Mono_FIND_QUIETLY)
|
||||
ELSE (MONO_FOUND)
|
||||
IF (Mono_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find one or more of the following programs: mono, mcs, gacutil")
|
||||
ENDIF (Mono_FIND_REQUIRED)
|
||||
ENDIF (MONO_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(MONO_EXECUTABLE MCS_EXECUTABLE GACUTIL_EXECUTABLE)
|
||||
@@ -1,48 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
# - Find MySQL
|
||||
# Find the MySQL includes and library
|
||||
# This module defines
|
||||
# MYSQL_INCLUDE_DIR, where to find mysql.h, etc.
|
||||
# MYSQL_LIBRARIES, the libraries needed to use Mysql.
|
||||
# MYSQL_FOUND, If false, do not try to use Mysql.
|
||||
# also defined, but not for general use are
|
||||
# MYSQL_LIBRARY, where to find the Mysql library.
|
||||
|
||||
FIND_PATH(MYSQL_INCLUDE_DIR mysql/mysql.h
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
SET(MYSQL_NAMES ${MYSQL_NAMES} mysqlclient)
|
||||
FIND_LIBRARY(MYSQL_LIBRARY
|
||||
NAMES ${MYSQL_NAMES}
|
||||
PATHS /usr/lib/mysql /usr/lib /usr/local/lib/mysql /usr/local/lib
|
||||
)
|
||||
|
||||
IF (MYSQL_LIBRARY AND MYSQL_INCLUDE_DIR)
|
||||
SET(MYSQL_LIBRARIES ${MYSQL_LIBRARY})
|
||||
SET(MYSQL_FOUND "YES")
|
||||
ELSE (MYSQL_LIBRARY AND MYSQL_INCLUDE_DIR)
|
||||
SET(MYSQL_FOUND "NO")
|
||||
ENDIF (MYSQL_LIBRARY AND MYSQL_INCLUDE_DIR)
|
||||
|
||||
|
||||
IF (MYSQL_FOUND)
|
||||
IF (NOT MYSQL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARIES}")
|
||||
ENDIF (NOT MYSQL_FIND_QUIETLY)
|
||||
ELSE (MYSQL_FOUND)
|
||||
IF (MYSQL_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find MySQL library")
|
||||
ENDIF (MYSQL_FIND_REQUIRED)
|
||||
ENDIF (MYSQL_FOUND)
|
||||
|
||||
# Deprecated declarations.
|
||||
SET (NATIVE_MYSQL_INCLUDE_PATH ${MYSQL_INCLUDE_DIR} )
|
||||
GET_FILENAME_COMPONENT (NATIVE_MYSQL_LIB_PATH ${MYSQL_LIBRARY} PATH)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MYSQL_LIBRARY
|
||||
MYSQL_INCLUDE_DIR
|
||||
)
|
||||
@@ -11,7 +11,7 @@ else (STANDALONE)
|
||||
set(FREETYPE_INCLUDE_DIRS
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
else (LINUX)
|
||||
set(FREETYPE_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(FREETYPE_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (LINUX)
|
||||
|
||||
set(FREETYPE_LIBRARIES freetype)
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if(WORD_SIZE EQUAL 64)
|
||||
set(DISABLE_TCMALLOC TRUE)
|
||||
endif(WORD_SIZE EQUAL 64)
|
||||
|
||||
if (STANDALONE)
|
||||
include(FindGooglePerfTools)
|
||||
else (STANDALONE)
|
||||
if (LINUX OR WINDOWS)
|
||||
use_prebuilt_binary(google)
|
||||
endif (LINUX OR WINDOWS)
|
||||
if (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
|
||||
use_prebuilt_binary(gperftools)
|
||||
endif (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
|
||||
if (WINDOWS)
|
||||
set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib)
|
||||
set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"")
|
||||
|
||||
@@ -6,10 +6,10 @@ if (STANDALONE)
|
||||
else (STANDALONE)
|
||||
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)
|
||||
set(HUNSPELL_LIBRARY hunspell-1.2)
|
||||
set(HUNSPELL_LIBRARY hunspell-1.3)
|
||||
else (LINUX OR DARWIN)
|
||||
set(HUNSPELL_LIBRARY libhunspell)
|
||||
endif (LINUX OR DARWIN)
|
||||
@@ -13,11 +13,11 @@ else (STANDALONE)
|
||||
set(JPEG_LIBRARIES jpeg)
|
||||
elseif (DARWIN)
|
||||
set(JPEG_LIBRARIES
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/liblljpeg.a
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/liblljpeg.a
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libjpeg.a
|
||||
)
|
||||
elseif (WINDOWS)
|
||||
set(JPEG_LIBRARIES jpeglib)
|
||||
endif (LINUX)
|
||||
set(JPEG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(JPEG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -14,9 +14,9 @@ else (STANDALONE)
|
||||
debug json_vc${MSVC_SUFFIX}d
|
||||
optimized json_vc${MSVC_SUFFIX})
|
||||
elseif (DARWIN)
|
||||
set(JSONCPP_LIBRARIES json_mac-universal-gcc_libmt)
|
||||
set(JSONCPP_LIBRARIES json_linux-gcc-4.0.1_libmt)
|
||||
elseif (LINUX)
|
||||
set(JSONCPP_LIBRARIES jsoncpp)
|
||||
endif (WINDOWS)
|
||||
set(JSONCPP_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/jsoncpp)
|
||||
set(JSONCPP_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/jsoncpp)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -13,15 +13,17 @@ if (STANDALONE)
|
||||
SDL_LIBRARY
|
||||
)
|
||||
else (STANDALONE)
|
||||
if (NOT DARWIN)
|
||||
if (LINUX)
|
||||
use_prebuilt_binary(mesa)
|
||||
endif (NOT DARWIN)
|
||||
if (LINUX AND VIEWER)
|
||||
use_prebuilt_binary(SDL)
|
||||
set (SDL_FOUND TRUE)
|
||||
set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/i686-linux)
|
||||
set (SDL_LIBRARY SDL)
|
||||
endif (LINUX AND VIEWER)
|
||||
set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR})
|
||||
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 (STANDALONE)
|
||||
|
||||
if (SDL_FOUND)
|
||||
|
||||
@@ -6,17 +6,13 @@ if (NOT STANDALONE)
|
||||
set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release)
|
||||
set(ARCH_PREBUILT_DIRS_DEBUG ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/debug)
|
||||
elseif (LINUX)
|
||||
if (VIEWER)
|
||||
set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release_client)
|
||||
else (VIEWER)
|
||||
set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release)
|
||||
endif (VIEWER)
|
||||
set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release)
|
||||
set(ARCH_PREBUILT_DIRS_RELEASE ${ARCH_PREBUILT_DIRS})
|
||||
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS})
|
||||
elseif (DARWIN)
|
||||
set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib_release)
|
||||
set(ARCH_PREBUILT_DIRS ${ARCH_PREBUILT_DIRS_RELEASE})
|
||||
set(ARCH_PREBUILT_DIRS_DEBUG ${ARCH_PREBUILT_DIRS_RELEASE})
|
||||
set(ARCH_PREBUILT_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib)
|
||||
set(ARCH_PREBUILT_DIRS_RELEASE ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/release)
|
||||
set(ARCH_PREBUILT_DIRS_DEBUG ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/lib/debug)
|
||||
endif (WINDOWS)
|
||||
endif (NOT STANDALONE)
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
set(MONO_PREBUILT_LIBRARIES_DIR ${LIBS_PREBUILT_DIR}/mono/1.0)
|
||||
|
||||
set(MONO_PREBUILT_LIBRARIES
|
||||
Iesi.Collections.dll
|
||||
Iesi.Collections.pdb
|
||||
Mono.CompilerServices.SymbolWriter.dll
|
||||
Mono.PEToolkit.dll
|
||||
Mono.PEToolkit.pdb
|
||||
Mono.Security.dll
|
||||
PEAPI.dll
|
||||
RAIL.dll
|
||||
RAIL.pdb
|
||||
)
|
||||
|
||||
set(MONO_CORE_LIBRARIES
|
||||
System.dll
|
||||
System.Xml.dll
|
||||
mscorlib.dll)
|
||||
|
||||
if(WINDOWS)
|
||||
set(MONO_DEPENDENCIES
|
||||
DomainCreator
|
||||
DomainRegister
|
||||
LslLibrary
|
||||
LslUserScript
|
||||
Script
|
||||
ScriptTypes
|
||||
TestFormat
|
||||
UserScript
|
||||
UThread
|
||||
UThreadInjector
|
||||
)
|
||||
else(WINDOWS)
|
||||
set(MONO_DEPENDENCIES
|
||||
DomainCreator_POST_BUILD
|
||||
DomainRegister_POST_BUILD
|
||||
LslLibrary_POST_BUILD
|
||||
LslUserScript_POST_BUILD
|
||||
Script_POST_BUILD
|
||||
ScriptTypes_POST_BUILD
|
||||
TestFormat_POST_BUILD
|
||||
UserScript_POST_BUILD
|
||||
UThread_POST_BUILD
|
||||
UThreadInjector_POST_BUILD
|
||||
)
|
||||
endif(WINDOWS)
|
||||
@@ -1,57 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(Prebuilt)
|
||||
use_prebuilt_binary(libmono)
|
||||
|
||||
SET(GLIB_2_0 glib-2.0)
|
||||
|
||||
if (WINDOWS)
|
||||
SET(MONO_LIB mono)
|
||||
else (WINDOWS)
|
||||
SET(MONO_LIB mono)
|
||||
SET(M_LIBRARIES m)
|
||||
SET(GTHREAD_2_0 gthread-2.0)
|
||||
endif(WINDOWS)
|
||||
|
||||
|
||||
IF (DARWIN)
|
||||
|
||||
FIND_LIBRARY(MONO_LIBRARY NAMES Mono)
|
||||
# Find_file doesnt work as expected. Hardcode relative to Mono.framework.
|
||||
#FIND_FILE(GLIB_CONFIG glibconfig.h ${MONO_LIBRARY})
|
||||
#FIND_FILE(MONO_GLIB_LIBRARY glib.h ${MONO_LIBRARY})
|
||||
SET(MONO_GLIB_LIBRARY ${MONO_LIBRARY}/Headers/glib-2.0/)
|
||||
SET(GLIB_CONFIG ${MONO_LIBRARY}/Libraries/glib-2.0/include/)
|
||||
SET(MONO_LIB_DIRECTORY ${MONO_LIBRARY}/Libraries)
|
||||
|
||||
IF (MONO_LIBRARY AND MONO_GLIB_LIBRARY AND GLIB_CONFIG)
|
||||
MESSAGE(STATUS "Found Mono for embedding")
|
||||
INCLUDE_DIRECTORIES(${MONO_GLIB_LIBRARY} ${GLIB_CONFIG})
|
||||
LINK_DIRECTORIES(${MONO_LIB_DIRECTORY})
|
||||
ELSE (MONO_LIBRARY AND MONO_GLIB_LIBRARY AND GLIB_CONFIG)
|
||||
MESSAGE(FATAL_ERROR "Mono not found for embedding")
|
||||
MESSAGE(${MONO_LIBRARY})
|
||||
MESSAGE(${MONO_GLIB_LIBRARY})
|
||||
MESSAGE(${GLIB_CONFIG})
|
||||
ENDIF (MONO_LIBRARY AND MONO_GLIB_LIBRARY AND GLIB_CONFIG)
|
||||
|
||||
ELSE (DARWIN)
|
||||
|
||||
SET(MONO_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
SET(GLIB_2_0_PLATFORM_INCLUDE_DIR
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/glib-2.0)
|
||||
SET(GLIB_2_0_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/glib-2.0)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${MONO_INCLUDE_DIR}
|
||||
${GLIB_2_0_PLATFORM_INCLUDE_DIR}
|
||||
${GLIB_2_0_INCLUDE_DIR})
|
||||
|
||||
ENDIF (DARWIN)
|
||||
|
||||
SET(MONO_LIBRARIES
|
||||
${MONO_LIB}
|
||||
${M_LIBRARIES}
|
||||
${GLIB_2_0}
|
||||
${GTHREAD_2_0}
|
||||
)
|
||||
@@ -1,26 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
include(Linking)
|
||||
include(Prebuilt)
|
||||
|
||||
use_prebuilt_binary(mysql)
|
||||
|
||||
if (LINUX)
|
||||
if (WORD_SIZE EQUAL 32 OR DEBIAN_VERSION STREQUAL "3.1")
|
||||
set(MYSQL_LIBRARIES mysqlclient)
|
||||
set(MYSQL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
else (WORD_SIZE EQUAL 32 OR DEBIAN_VERSION STREQUAL "3.1")
|
||||
# Use the native MySQL library on a 64-bit system.
|
||||
set(MYSQL_FIND_QUIETLY ON)
|
||||
set(MYSQL_FIND_REQUIRED ON)
|
||||
include(FindMySQL)
|
||||
endif (WORD_SIZE EQUAL 32 OR DEBIAN_VERSION STREQUAL "3.1")
|
||||
elseif (WINDOWS)
|
||||
set(MYSQL_LIBRARIES mysqlclient)
|
||||
set(MYSQL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
elseif (DARWIN)
|
||||
set(MYSQL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
set(MYSQL_LIBRARIES
|
||||
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libmysqlclient.a
|
||||
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libmysqlclient.a
|
||||
)
|
||||
endif (LINUX)
|
||||
@@ -15,7 +15,7 @@ else (STANDALONE)
|
||||
set(NDOF_LIBRARY ndofdev)
|
||||
endif (WINDOWS)
|
||||
|
||||
set(NDOF_INCLUDE_DIR ${ARCH_PREBUILT_DIRS}/include/ndofdev)
|
||||
set(NDOF_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/ndofdev)
|
||||
set(NDOF_FOUND 1)
|
||||
endif (STANDALONE)
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ if (OPENAL)
|
||||
openal
|
||||
alut
|
||||
)
|
||||
set(OPENAL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (OPENAL)
|
||||
|
||||
if (OPENAL)
|
||||
|
||||
@@ -6,5 +6,5 @@ if (NOT (STANDALONE OR DARWIN))
|
||||
# possible glh_linear should have its own .cmake file instead
|
||||
#use_prebuilt_binary(glh_linear)
|
||||
# actually... not any longer, it's now in git -SG
|
||||
set(GLEXT_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include)
|
||||
set(GLEXT_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif ()
|
||||
|
||||
@@ -16,8 +16,6 @@ else (STANDALONE)
|
||||
set(OPENSSL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
if (LINUX)
|
||||
if (LINUX OR DARWIN)
|
||||
set(CRYPTO_LIBRARIES crypto)
|
||||
elseif (DARWIN)
|
||||
set(CRYPTO_LIBRARIES llcrypto)
|
||||
endif (LINUX)
|
||||
endif (LINUX OR DARWIN)
|
||||
|
||||
@@ -10,8 +10,10 @@ else (STANDALONE)
|
||||
use_prebuilt_binary(libpng)
|
||||
if (WINDOWS)
|
||||
set(PNG_LIBRARIES libpng15)
|
||||
else (WINDOWS)
|
||||
set(PNG_LIBRARIES png12)
|
||||
endif (WINDOWS)
|
||||
set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
elseif(DARWIN)
|
||||
set(PNG_LIBRARIES png15)
|
||||
else(LINUX)
|
||||
set(PNG_LIBRARIES png15)
|
||||
endif()
|
||||
set(PNG_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/libpng15)
|
||||
endif (STANDALONE)
|
||||
|
||||
2
indra/cmake/PulseAudio.cmake
Executable file → Normal file
2
indra/cmake/PulseAudio.cmake
Executable file → Normal file
@@ -13,7 +13,7 @@ if (PULSEAUDIO)
|
||||
use_prebuilt_binary(pulseaudio)
|
||||
set(PULSEAUDIO_FOUND ON FORCE BOOL)
|
||||
set(PULSEAUDIO_INCLUDE_DIRS
|
||||
${LIBS_PREBUILT_DIR}/include
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include
|
||||
)
|
||||
# We don't need to explicitly link against pulseaudio itself, because
|
||||
# the viewer probes for the system's copy at runtime.
|
||||
|
||||
@@ -31,11 +31,9 @@ if (STANDALONE)
|
||||
add_definitions(${${pkg}_CFLAGS_OTHERS})
|
||||
endforeach(pkg)
|
||||
else (STANDALONE)
|
||||
if (NOT DARWIN)
|
||||
if (LINUX)
|
||||
use_prebuilt_binary(glib) # gtk-etc needs glib
|
||||
use_prebuilt_binary(gtk-atk-pango-glib)
|
||||
endif (NOT DARWIN)
|
||||
if (LINUX)
|
||||
set(UI_LIBRARIES
|
||||
atk-1.0
|
||||
X11
|
||||
@@ -60,7 +58,6 @@ else (STANDALONE)
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/cairo
|
||||
${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/pixman-1
|
||||
${LIBS_PREBUILT_DIR}/include
|
||||
)
|
||||
foreach(include ${${LL_ARCH}_INCLUDES})
|
||||
include_directories(${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/${include})
|
||||
|
||||
@@ -76,37 +76,36 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(DARWIN 1)
|
||||
|
||||
#SDK Compiler and Deployment targets for XCode
|
||||
if (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
|
||||
set(CMAKE_XCODE_ATTIBUTE_GCC_VERSION "4.2")
|
||||
else (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
if(${CMAKE_GENERATOR} MATCHES Xcode)
|
||||
#SDK Compiler and Deployment targets for XCode
|
||||
if (${XCODE_VERSION} VERSION_LESS 4.0.0)
|
||||
set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.5.sdk)
|
||||
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_DEPLOYMENT_TARGET 10.6)
|
||||
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:
|
||||
# -DCMAKE_OSX_ARCHITECTURES:STRING='i386;ppc'
|
||||
# Build only for i386 by default, system default on MacOSX 10.6 is x86_64
|
||||
if (NOT CMAKE_OSX_ARCHITECTURES)
|
||||
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")
|
||||
## But if you want to compile for mixed 32/64 bit, try these:
|
||||
# set(CMAKE_OSX_ARCHITECTURES i386;x86_64)
|
||||
# set(ARCH universal)
|
||||
# set(WORD_SIZE 64)
|
||||
|
||||
## Finally, set up the build output directories
|
||||
set(LL_ARCH ${ARCH}_darwin)
|
||||
set(LL_ARCH_DIR universal-darwin)
|
||||
set(WORD_SIZE 32)
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ if (STANDALONE)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(xmlrpc-epi)
|
||||
set(XMLRPCEPI_LIBRARIES xmlrpc-epi)
|
||||
set(XMLRPCEPI_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(XMLRPCEPI_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -17,6 +17,6 @@ else (STANDALONE)
|
||||
set(ZLIB_LIBRARIES z)
|
||||
endif (WINDOWS)
|
||||
if (WINDOWS OR LINUX)
|
||||
set(ZLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/zlib)
|
||||
set(ZLIB_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/${LL_ARCH_DIR}/include/zlib)
|
||||
endif (WINDOWS OR LINUX)
|
||||
endif (STANDALONE)
|
||||
|
||||
@@ -173,6 +173,8 @@ void stop_recording_backtraces(void)
|
||||
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 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 DEBUGCHANNELS
|
||||
|
||||
@@ -118,6 +118,8 @@ extern CWD_API channel_ct sdl;
|
||||
extern CWD_API channel_ct backtrace;
|
||||
extern CWD_API channel_ct statemachine;
|
||||
extern CWD_API channel_ct caps;
|
||||
extern CWD_API channel_ct curl;
|
||||
extern CWD_API channel_ct curlio;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ def quote(opts):
|
||||
class PlatformSetup(object):
|
||||
generator = None
|
||||
build_types = {}
|
||||
for t in ('Debug', 'Release', 'ReleaseSSE2', 'RelWithDebInfo'):
|
||||
for t in ('Debug', 'Release', 'RelWithDebInfo'):
|
||||
build_types[t.lower()] = t
|
||||
|
||||
build_type = build_types['relwithdebinfo']
|
||||
@@ -764,7 +764,7 @@ Options:
|
||||
--unattended build unattended, do not invoke any tools requiring
|
||||
a human response
|
||||
--universal build a universal binary on Mac OS X (unsupported)
|
||||
-t | --type=NAME build type ("Debug", "Release", "ReleaseSSE2", or "RelWithDebInfo")
|
||||
-t | --type=NAME build type ("Debug", "Release", or "RelWithDebInfo")
|
||||
-m32 | -m64 build architecture (32-bit or 64-bit)
|
||||
-N | --no-distcc disable use of distcc
|
||||
-G | --generator=NAME generator name
|
||||
|
||||
@@ -120,7 +120,7 @@ ARGUMENTS=[
|
||||
On Linux this would try to use Linux_i686Manifest.""",
|
||||
default=""),
|
||||
dict(name='build', description='Build directory.', default=DEFAULT_SRCTREE),
|
||||
dict(name='buildtype', description="""The build type used. ('Debug', 'Release', 'ReleaseSSE2' or 'RelWithDebInfo')
|
||||
dict(name='buildtype', description="""The build type used. ('Debug', 'Release', or 'RelWithDebInfo')
|
||||
Default is Release """,
|
||||
default="Release"),
|
||||
dict(name='branding_id', description="""Identifier for the branding set to
|
||||
|
||||
@@ -35,7 +35,7 @@ include_directories(
|
||||
${VORBISENC_INCLUDE_DIRS}
|
||||
${VORBISFILE_INCLUDE_DIRS}
|
||||
${VORBIS_INCLUDE_DIRS}
|
||||
${OPENAL_LIB_INCLUDE_DIRS}
|
||||
${OPENAL_INCLUDE_DIRS}
|
||||
${FREEAULT_LIB_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
@@ -95,6 +95,28 @@ inline bool Check_FMOD_Error(FMOD_RESULT result, const char *string)
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -108,6 +130,10 @@ bool LLAudioEngine_FMODEX::init(const S32 num_channels, void* userdata)
|
||||
|
||||
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);
|
||||
if(Check_FMOD_Error(result, "FMOD::System_Create"))
|
||||
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;
|
||||
}
|
||||
|
||||
#if LL_WINDOWS
|
||||
int numdrivers;
|
||||
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
|
||||
result = mSystem->setSoftwareFormat(44100, FMOD_SOUND_FORMAT_PCM16, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
|
||||
Check_FMOD_Error(result,"FMOD::System::setSoftwareFormat");
|
||||
|
||||
// In this case, all sounds, PLUS wind and stream will be software.
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
return true;
|
||||
@@ -365,6 +358,7 @@ bool LLAudioEngine_FMODEX::initWind()
|
||||
FMOD_DSP_DESCRIPTION dspdesc;
|
||||
memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); //Set everything to zero
|
||||
strncpy(dspdesc.name,"Wind Unit", sizeof(dspdesc.name)); //Set name to "Wind Unit"
|
||||
dspdesc.channels=2;
|
||||
dspdesc.read = &windCallback; //Assign callback.
|
||||
if(Check_FMOD_Error(mSystem->createDSP(&dspdesc, &mWindDSP), "FMOD::createDSP"))
|
||||
return false;
|
||||
|
||||
@@ -58,6 +58,9 @@ class LLStreamingAudioInterface
|
||||
virtual const LLSD *getMetaData() = 0;
|
||||
virtual bool supportsWaveData() = 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
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
const std::string& getURL() { return mInternetStreamURL; }
|
||||
|
||||
FMOD_OPENSTATE getOpenState();
|
||||
FMOD_OPENSTATE getOpenState(unsigned int* percentbuffered=NULL, bool* starving=NULL, bool* diskbusy=NULL);
|
||||
protected:
|
||||
FMOD::System* mSystem;
|
||||
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.
|
||||
// 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
|
||||
mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES);
|
||||
|
||||
@@ -145,7 +145,10 @@ void LLStreamingAudio_FMODEX::update()
|
||||
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)
|
||||
{
|
||||
@@ -158,6 +161,7 @@ void LLStreamingAudio_FMODEX::update()
|
||||
// Reset volume to previously set volume
|
||||
setGain(getGain());
|
||||
mFMODInternetStreamChannelp->setPaused(false);
|
||||
mLastStarved.stop();
|
||||
}
|
||||
}
|
||||
else if(open_state == FMOD_OPENSTATE_ERROR)
|
||||
@@ -168,6 +172,7 @@ void LLStreamingAudio_FMODEX::update()
|
||||
|
||||
if(mFMODInternetStreamChannelp)
|
||||
{
|
||||
//llinfos << "progress = " << progress << llendl;
|
||||
if(!mMetaData)
|
||||
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()
|
||||
{
|
||||
mLastStarved.stop();
|
||||
if(mMetaData)
|
||||
{
|
||||
delete mMetaData;
|
||||
@@ -341,6 +363,11 @@ void LLStreamingAudio_FMODEX::setGain(F32 vol)
|
||||
if(!mFMODInternetStreamChannelp || !mCurrentInternetStreamp)
|
||||
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.
|
||||
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);
|
||||
@@ -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;
|
||||
mInternetStream->getOpenState(&state,NULL,NULL,NULL);
|
||||
mInternetStream->getOpenState(&state,percentbuffered,starving,diskbusy);
|
||||
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);
|
||||
}
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "stdtypes.h" // from llcommon
|
||||
|
||||
#include "llstreamingaudio.h"
|
||||
#include "lltimer.h"
|
||||
|
||||
//Stubs
|
||||
class LLAudioStreamManagerFMODEX;
|
||||
@@ -66,6 +67,8 @@ class LLStreamingAudio_FMODEX : public LLStreamingAudioInterface
|
||||
/*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not playing.
|
||||
/*virtual*/ bool supportsWaveData(){return true;}
|
||||
/*virtual*/ bool getWaveData(float* arr, S32 count, S32 stride = 1);
|
||||
/*virtual*/ bool supportsAdjustableBufferSizes(){return true;}
|
||||
/*virtual*/ void setBufferSizes(U32 streambuffertime, U32 decodebuffertime);
|
||||
private:
|
||||
FMOD::System *mSystem;
|
||||
|
||||
@@ -76,6 +79,8 @@ private:
|
||||
std::string mURL;
|
||||
F32 mGain;
|
||||
|
||||
LLTimer mLastStarved;
|
||||
|
||||
LLSD *mMetaData;
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
LLApp::sErrorHandler = handler;
|
||||
|
||||
@@ -43,10 +43,14 @@ template <typename Type> class LLAtomic32;
|
||||
typedef LLAtomic32<U32> LLAtomicU32;
|
||||
class LLErrorThread;
|
||||
class LLLiveFile;
|
||||
|
||||
|
||||
#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
|
||||
|
||||
|
||||
typedef void (*LLAppErrorHandler)();
|
||||
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.
|
||||
*/
|
||||
void startErrorThread();
|
||||
/**
|
||||
* @brief This method is called at the end, just prior to deinitializing curl.
|
||||
*/
|
||||
void stopErrorThread();
|
||||
|
||||
private:
|
||||
void setupErrorHandling(); // Do platform-specific error-handling setup (signals, structured exceptions)
|
||||
|
||||
@@ -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*/\
|
||||
: 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
|
||||
#define llassert(func) llassert_always(func)
|
||||
|
||||
@@ -194,17 +194,17 @@ void LLErrorThread::run()
|
||||
if (LLApp::isError())
|
||||
{
|
||||
// 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
|
||||
LLApp::runErrorHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,17 +39,13 @@
|
||||
#include <hash_map>
|
||||
#include <algorithm>
|
||||
#elif LL_DARWIN || LL_LINUX
|
||||
#if CC_GCC
|
||||
# if GCC_VERSION >= 40300 // gcc 4.3 and up
|
||||
# include <backward/hashtable.h>
|
||||
# elif GCC_VERSION >= 30400 // gcc 3.4 and up
|
||||
# include <ext/hashtable.h>
|
||||
# elif __GNUC__ >= 3
|
||||
# include <ext/stl_hashtable.h>
|
||||
# else
|
||||
# include <hashtable.h>
|
||||
# endif
|
||||
#elif CC_CLANG
|
||||
#if GCC_VERSION >= 40300 || LL_ICC// gcc 4.3 or icc 11 and up
|
||||
# include <backward/hashtable.h>
|
||||
#elif GCC_VERSION >= 30400 // gcc 3.4 and up
|
||||
# include <ext/hashtable.h>
|
||||
#elif __GNUC__ >= 3
|
||||
# include <ext/stl_hashtable.h>
|
||||
#else
|
||||
# include <hashtable.h>
|
||||
#endif
|
||||
#elif LL_SOLARIS
|
||||
|
||||
@@ -75,7 +75,7 @@ LLHeartbeat::rawSend()
|
||||
|
||||
int result;
|
||||
#ifndef LL_DARWIN
|
||||
union sigval dummy;
|
||||
static union sigval dummy;
|
||||
result = sigqueue(getppid(), LL_HEARTBEAT_SIGNAL, dummy);
|
||||
#else
|
||||
result = kill(getppid(), LL_HEARTBEAT_SIGNAL);
|
||||
|
||||
@@ -78,7 +78,18 @@
|
||||
|
||||
|
||||
// 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 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
|
||||
@@ -55,10 +55,10 @@
|
||||
# define LL_X86 1
|
||||
#elif LL_MSVC && _M_IX86
|
||||
# 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 1
|
||||
#elif LL_GNUC && ( defined(__i386__) )
|
||||
#elif LL_GNUC || LL_ICC || LL_CLANG && ( defined(__i386__) )
|
||||
# define LL_X86 1
|
||||
#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
|
||||
# define LL_PPC 1
|
||||
|
||||
@@ -251,7 +251,7 @@ bool LLQueuedThread::addRequest(QueuedRequest* req)
|
||||
// MAIN thread
|
||||
bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_complete)
|
||||
{
|
||||
llassert (handle != nullHandle())
|
||||
llassert (handle != nullHandle());
|
||||
bool res = false;
|
||||
bool waspaused = isPaused();
|
||||
bool done = false;
|
||||
@@ -264,7 +264,7 @@ bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_co
|
||||
{
|
||||
done = true; // request does not exist
|
||||
}
|
||||
else if (req->getStatus() == STATUS_COMPLETE)
|
||||
else if (req->getStatus() == STATUS_COMPLETE && !(req->getFlags() & FLAG_LOCKED))
|
||||
{
|
||||
res = true;
|
||||
if (auto_complete)
|
||||
@@ -372,9 +372,17 @@ bool LLQueuedThread::completeRequest(handle_t handle)
|
||||
#if _DEBUG
|
||||
// llinfos << llformat("LLQueuedThread::Completed req [%08d]",handle) << llendl;
|
||||
#endif
|
||||
mRequestHash.erase(handle);
|
||||
req->deleteRequest();
|
||||
// check();
|
||||
if (!(req->getFlags() & FLAG_LOCKED))
|
||||
{
|
||||
mRequestHash.erase(handle);
|
||||
req->deleteRequest();
|
||||
// check();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cause deletion immediately after FLAG_LOCKED is released.
|
||||
req->setFlags(FLAG_AUTO_COMPLETE);
|
||||
}
|
||||
res = true;
|
||||
}
|
||||
unlockData();
|
||||
@@ -421,12 +429,44 @@ S32 LLQueuedThread::processNextRequest()
|
||||
if ((req->getFlags() & FLAG_ABORT) || (mStatus == QUITTING))
|
||||
{
|
||||
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);
|
||||
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);
|
||||
req->deleteRequest();
|
||||
// check();
|
||||
unlockData();
|
||||
req->deleteRequest();
|
||||
lockData();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -453,14 +493,23 @@ S32 LLQueuedThread::processNextRequest()
|
||||
{
|
||||
lockData();
|
||||
req->setStatus(STATUS_COMPLETE);
|
||||
req->finishRequest(true);
|
||||
if (req->getFlags() & FLAG_AUTO_COMPLETE)
|
||||
{
|
||||
mRequestHash.erase(req);
|
||||
req->deleteRequest();
|
||||
// check();
|
||||
}
|
||||
req->setFlags(FLAG_LOCKED);
|
||||
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
|
||||
{
|
||||
|
||||
@@ -72,7 +72,8 @@ public:
|
||||
enum flags_t {
|
||||
FLAG_AUTO_COMPLETE = 1,
|
||||
FLAG_AUTO_DELETE = 2, // child-class dependent
|
||||
FLAG_ABORT = 4
|
||||
FLAG_ABORT = 4,
|
||||
FLAG_LOCKED = 8
|
||||
};
|
||||
|
||||
typedef U32 handle_t;
|
||||
@@ -110,6 +111,8 @@ public:
|
||||
return mPriority > second.mPriority;
|
||||
}
|
||||
|
||||
virtual void deleteRequest(); // Only method to delete a request
|
||||
|
||||
protected:
|
||||
status_t setStatus(status_t newstatus)
|
||||
{
|
||||
@@ -122,10 +125,13 @@ public:
|
||||
// NOTE: flags are |'d
|
||||
mFlags |= flags;
|
||||
}
|
||||
void resetFlags(U32 flags)
|
||||
{
|
||||
mFlags &= ~flags;
|
||||
}
|
||||
|
||||
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 deleteRequest(); // Only method to delete a request
|
||||
|
||||
void setPriority(U32 pri)
|
||||
{
|
||||
|
||||
@@ -310,15 +310,27 @@ void LLThread::wakeLocked()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHOW_ASSERT
|
||||
// This allows the use of llassert(is_main_thread()) to assure the current thread is the main thread.
|
||||
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()); }
|
||||
#endif
|
||||
//static
|
||||
apr_os_thread_t LLThread::sMainThreadID;
|
||||
|
||||
void LLThread::set_main_thread_id(void)
|
||||
{
|
||||
sMainThreadID = apr_os_thread_current();
|
||||
}
|
||||
|
||||
// The thread private handle to access the LLThreadLocalData instance.
|
||||
apr_threadkey_t* LLThreadLocalData::sThreadLocalDataKey;
|
||||
|
||||
LLThreadLocalData::LLThreadLocalData(char const* name) : mCurlMultiHandle(NULL), mCurlErrorBuffer(NULL), mName(name)
|
||||
{
|
||||
}
|
||||
|
||||
LLThreadLocalData::~LLThreadLocalData()
|
||||
{
|
||||
delete mCurlMultiHandle;
|
||||
delete [] mCurlErrorBuffer;
|
||||
}
|
||||
|
||||
//static
|
||||
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).
|
||||
LLThreadLocalData::create(NULL);
|
||||
|
||||
#ifdef SHOW_ASSERT
|
||||
// This function is called by the main thread.
|
||||
main_thread_id = apr_os_thread_current();
|
||||
#endif
|
||||
LLThread::set_main_thread_id();
|
||||
}
|
||||
|
||||
// This is called once for every thread when the thread is destructed.
|
||||
@@ -352,7 +362,7 @@ void LLThreadLocalData::destroy(void* thread_local_data)
|
||||
//static
|
||||
void LLThreadLocalData::create(LLThread* threadp)
|
||||
{
|
||||
LLThreadLocalData* new_tld = new LLThreadLocalData;
|
||||
LLThreadLocalData* new_tld = new LLThreadLocalData(threadp ? threadp->mName.c_str() : "main thread");
|
||||
if (threadp)
|
||||
{
|
||||
threadp->mThreadLocalData = new_tld;
|
||||
|
||||
@@ -40,13 +40,6 @@
|
||||
#include "llaprpool.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 LLMutex;
|
||||
class LLCondition;
|
||||
@@ -57,6 +50,12 @@ class LLCondition;
|
||||
#define ll_thread_local __thread
|
||||
#endif
|
||||
|
||||
class LL_COMMON_API LLThreadLocalDataMember
|
||||
{
|
||||
public:
|
||||
virtual ~LLThreadLocalDataMember() { };
|
||||
};
|
||||
|
||||
class LL_COMMON_API LLThreadLocalData
|
||||
{
|
||||
private:
|
||||
@@ -66,16 +65,24 @@ public:
|
||||
// Thread-local memory pool.
|
||||
LLAPRRootPool mRootPool;
|
||||
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 destroy(void* thread_local_data);
|
||||
static void create(LLThread* pthread);
|
||||
static LLThreadLocalData& tldata(void);
|
||||
|
||||
private:
|
||||
LLThreadLocalData(char const* name);
|
||||
~LLThreadLocalData();
|
||||
};
|
||||
|
||||
class LL_COMMON_API LLThread
|
||||
{
|
||||
private:
|
||||
static apr_os_thread_t sMainThreadID;
|
||||
static U32 sIDIter;
|
||||
static LLAtomicS32 sCount;
|
||||
static LLAtomicS32 sRunning;
|
||||
@@ -99,6 +106,7 @@ public:
|
||||
static S32 getCount() { return sCount; }
|
||||
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 bool is_main_thread(void) { return apr_os_thread_equal(LLThread::sMainThreadID, apr_os_thread_current()); }
|
||||
|
||||
public:
|
||||
// PAUSE / RESUME functionality. See source code for important usage notes.
|
||||
@@ -122,6 +130,9 @@ public:
|
||||
// Return thread-local data for the current thread.
|
||||
static LLThreadLocalData& tldata(void) { return LLThreadLocalData::tldata(); }
|
||||
|
||||
// Called once, from LLThreadLocalData::init().
|
||||
static void set_main_thread_id(void);
|
||||
|
||||
U32 getID() const { return mID; }
|
||||
|
||||
private:
|
||||
@@ -165,6 +176,13 @@ protected:
|
||||
// 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)
|
||||
@@ -206,6 +224,11 @@ protected:
|
||||
apr_thread_mutex_t* mAPRMutexp;
|
||||
mutable U32 mCount;
|
||||
mutable U32 mLockingThread;
|
||||
|
||||
private:
|
||||
// Disallow copy construction and assignment.
|
||||
LLMutexBase(LLMutexBase const&);
|
||||
LLMutexBase& operator=(LLMutexBase const&);
|
||||
};
|
||||
|
||||
class LL_COMMON_API LLMutex : public LLMutexBase
|
||||
@@ -225,10 +248,6 @@ public:
|
||||
|
||||
protected:
|
||||
LLAPRPool mPool;
|
||||
private:
|
||||
// Disable copy construction, as si teh bomb!!! -SG
|
||||
LLMutex(const LLMutex&);
|
||||
LLMutex& operator=(const LLMutex&);
|
||||
};
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define LL_LLVERSIONVIEWER_H
|
||||
|
||||
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_BUILD = ${vBUILD};
|
||||
|
||||
|
||||
@@ -226,7 +226,8 @@ LLWorkerClass::~LLWorkerClass()
|
||||
llerrs << "LLWorkerClass destroyed with stale work handle" << llendl;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -350,14 +351,10 @@ bool LLWorkerClass::checkWork(bool aborting)
|
||||
}
|
||||
|
||||
LLQueuedThread::status_t status = workreq->getStatus();
|
||||
if (status == LLWorkerThread::STATUS_ABORTED)
|
||||
if (status == LLWorkerThread::STATUS_COMPLETE || status == LLWorkerThread::STATUS_ABORTED)
|
||||
{
|
||||
complete = true;
|
||||
abort = true;
|
||||
}
|
||||
else if (status == LLWorkerThread::STATUS_COMPLETE)
|
||||
{
|
||||
complete = true;
|
||||
complete = !(workreq->getFlags() & LLWorkerThread::FLAG_LOCKED);
|
||||
abort = status == LLWorkerThread::STATUS_ABORTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -371,6 +371,9 @@ void LLCrashLogger::updateApplication(const std::string& message)
|
||||
|
||||
bool LLCrashLogger::init()
|
||||
{
|
||||
// Initialize curl
|
||||
AICurlInterface::initCurl();
|
||||
|
||||
// We assume that all the logs we're looking for reside on the current drive
|
||||
gDirUtilp->initAppDirs("SecondLife");
|
||||
|
||||
|
||||
@@ -8,12 +8,15 @@ include(LLCommon)
|
||||
include(LLImage)
|
||||
include(LLMath)
|
||||
include(LLVFS)
|
||||
include(JPEG)
|
||||
include(PNG)
|
||||
include(ZLIB)
|
||||
|
||||
include_directories(
|
||||
${LLCOMMON_INCLUDE_DIRS}
|
||||
${LLMATH_INCLUDE_DIRS}
|
||||
${LLVFS_INCLUDE_DIRS}
|
||||
${JPEG_INCLUDE_DIRS}
|
||||
${PNG_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
@@ -32,11 +32,7 @@
|
||||
#ifndef LL_LLPNGWRAPPER_H
|
||||
#define LL_LLPNGWRAPPER_H
|
||||
|
||||
#if LL_WINDOWS
|
||||
#include "libpng15/png.h"
|
||||
#else
|
||||
#include "libpng12/png.h"
|
||||
#endif
|
||||
#include "png.h"
|
||||
#include "llimage.h"
|
||||
|
||||
class LLPngWrapper
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "linden_common.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "llsaleinfo.h"
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ set(llmessage_SOURCE_FILES
|
||||
llchainio.cpp
|
||||
llcircuit.cpp
|
||||
llclassifiedflags.cpp
|
||||
llcurl.cpp
|
||||
aicurl.cpp
|
||||
aicurlthread.cpp
|
||||
lldatapacker.cpp
|
||||
lldispatcher.cpp
|
||||
llfiltersd2xmlrpc.cpp
|
||||
@@ -66,8 +67,6 @@ set(llmessage_SOURCE_FILES
|
||||
llsdmessage.cpp
|
||||
llsdmessagebuilder.cpp
|
||||
llsdmessagereader.cpp
|
||||
llsdrpcclient.cpp
|
||||
llsdrpcserver.cpp
|
||||
llservicebuilder.cpp
|
||||
llservice.cpp
|
||||
llstoredmessage.cpp
|
||||
@@ -117,6 +116,9 @@ set(llmessage_HEADER_FILES
|
||||
llcircuit.h
|
||||
llclassifiedflags.h
|
||||
llcurl.h
|
||||
aicurl.h
|
||||
aicurlprivate.h
|
||||
aicurlthread.h
|
||||
lldatapacker.h
|
||||
lldbstrings.h
|
||||
lldispatcher.h
|
||||
@@ -164,8 +166,6 @@ set(llmessage_HEADER_FILES
|
||||
llsdmessage.h
|
||||
llsdmessagebuilder.h
|
||||
llsdmessagereader.h
|
||||
llsdrpcclient.h
|
||||
llsdrpcserver.h
|
||||
llservice.h
|
||||
llservicebuilder.h
|
||||
llstoredmessage.h
|
||||
|
||||
1363
indra/llmessage/aicurl.cpp
Normal file
1363
indra/llmessage/aicurl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
322
indra/llmessage/aicurl.h
Normal file
322
indra/llmessage/aicurl.h
Normal 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
|
||||
414
indra/llmessage/aicurlprivate.h
Normal file
414
indra/llmessage/aicurlprivate.h
Normal 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
|
||||
1561
indra/llmessage/aicurlthread.cpp
Normal file
1561
indra/llmessage/aicurlthread.cpp
Normal file
File diff suppressed because it is too large
Load Diff
128
indra/llmessage/aicurlthread.h
Normal file
128
indra/llmessage/aicurlthread.h
Normal 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
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llares.h"
|
||||
#include "llscopedvolatileaprpool.h"
|
||||
|
||||
#include <ares_dns.h>
|
||||
#include <ares_version.h>
|
||||
|
||||
@@ -401,7 +401,7 @@ bool LLAssetStorage::findInStaticVFSAndInvokeCallback(const LLUUID& uuid, LLAsse
|
||||
if (user_data)
|
||||
{
|
||||
// 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);
|
||||
@@ -441,7 +441,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, LL
|
||||
if (user_data)
|
||||
{
|
||||
// The *user_data should not be passed without a callback to clean it up.
|
||||
llassert(callback != NULL)
|
||||
llassert(callback != NULL);
|
||||
}
|
||||
|
||||
if (mShutDown)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,457 +1,39 @@
|
||||
/**
|
||||
/**
|
||||
* @file llcurl.h
|
||||
* @author Zero / Donovan
|
||||
* @date 2006-10-15
|
||||
* @brief A wrapper around libcurl.
|
||||
* @brief Drop in replacement for old llcurl.h.
|
||||
*
|
||||
* $LicenseInfo:firstyear=2006&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,
|
||||
* 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
|
||||
* 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$
|
||||
* 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.
|
||||
*
|
||||
* 22/06/2012
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LL_LLCURL_H
|
||||
#define LL_LLCURL_H
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "aicurl.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#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);
|
||||
}
|
||||
// Map interface to old LLCurl names so this can be used as a drop-in replacement.
|
||||
namespace LLCurl = AICurlInterface;
|
||||
|
||||
#endif // LL_LLCURL_H
|
||||
|
||||
@@ -220,17 +220,28 @@ static void request(
|
||||
const LLSD& headers = LLSD()
|
||||
)
|
||||
{
|
||||
if (responder)
|
||||
{
|
||||
// For possible debug output from within the responder.
|
||||
responder->setURL(url);
|
||||
}
|
||||
|
||||
if (!LLHTTPClient::hasPump())
|
||||
{
|
||||
responder->completed(U32_MAX, "No pump", LLSD());
|
||||
responder->fatalError("No pump");
|
||||
return;
|
||||
}
|
||||
LLPumpIO::chain_t chain;
|
||||
|
||||
LLURLRequest* req = new LLURLRequest(method, url);
|
||||
if(!req->isValid())//failed
|
||||
LLURLRequest* req;
|
||||
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 ;
|
||||
}
|
||||
|
||||
@@ -282,11 +293,6 @@ static void request(
|
||||
}
|
||||
}
|
||||
|
||||
if (responder)
|
||||
{
|
||||
responder->setURL(url);
|
||||
}
|
||||
|
||||
req->setCallback(new LLHTTPClientURLAdaptor(responder));
|
||||
|
||||
if (method == LLURLRequest::HTTP_POST && gMessageSystem)
|
||||
@@ -333,7 +339,7 @@ void LLHTTPClient::getByteRange(
|
||||
std::string range = llformat("bytes=%d-%d", offset, offset+bytes-1);
|
||||
headers["Range"] = range;
|
||||
}
|
||||
request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers);
|
||||
}
|
||||
|
||||
void LLHTTPClient::head(
|
||||
@@ -372,12 +378,12 @@ class LLHTTPBuffer
|
||||
public:
|
||||
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;
|
||||
|
||||
size_t bytes = (size * nmemb);
|
||||
self->mBuffer.append((char*)ptr,bytes);
|
||||
self->mBuffer.append(ptr,bytes);
|
||||
return nmemb;
|
||||
}
|
||||
|
||||
@@ -428,104 +434,91 @@ static LLSD blocking_request(
|
||||
)
|
||||
{
|
||||
lldebugs << "blockingRequest of " << url << llendl;
|
||||
char curl_error_buffer[CURL_ERROR_SIZE] = "\0";
|
||||
CURL* curlp = LLCurl::newEasyHandle();
|
||||
llassert_always(curlp != NULL) ;
|
||||
|
||||
LLHTTPBuffer http_buffer;
|
||||
std::string body_str;
|
||||
|
||||
// other request method checks root cert first, we skip?
|
||||
S32 http_status = 499;
|
||||
LLSD response = LLSD::emptyMap();
|
||||
|
||||
// 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())
|
||||
try
|
||||
{
|
||||
LLSD::map_const_iterator iter = headers.beginMap();
|
||||
LLSD::map_const_iterator end = headers.endMap();
|
||||
for (; iter != end; ++iter)
|
||||
AICurlEasyRequest easy_request(false);
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*easy_request);
|
||||
|
||||
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;
|
||||
header << iter->first << ": " << iter->second.asString() ;
|
||||
lldebugs << "header = " << header.str() << llendl;
|
||||
headers_list = curl_slist_append(headers_list, header.str().c_str());
|
||||
LLSD::map_const_iterator iter = headers.beginMap();
|
||||
LLSD::map_const_iterator end = headers.endMap();
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// * Setup specific method / "verb" for the URI (currently only GET and POST supported + poppy)
|
||||
if (method == LLURLRequest::HTTP_GET)
|
||||
catch(AICurlNoEasyHandle const& error)
|
||||
{
|
||||
curl_easy_setopt(curlp, CURLOPT_HTTPGET, 1);
|
||||
}
|
||||
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;
|
||||
response["body"] = error.what();
|
||||
}
|
||||
|
||||
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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,9 @@ public:
|
||||
typedef LLCurl::Responder Responder;
|
||||
typedef LLCurl::ResponderPtr ResponderPtr;
|
||||
|
||||
|
||||
// The default actually already ignores responses.
|
||||
class ResponderIgnore : public Responder { };
|
||||
|
||||
/** @name non-blocking API */
|
||||
//@{
|
||||
static void head(
|
||||
|
||||
@@ -76,7 +76,14 @@ LLIOPipe::~LLIOPipe()
|
||||
}
|
||||
|
||||
//virtual
|
||||
bool LLIOPipe::isValid()
|
||||
bool LLIOPipe::hasExpiration(void) const
|
||||
{
|
||||
// LLIOPipe::hasNotExpired always returns true.
|
||||
return false;
|
||||
}
|
||||
|
||||
//virtual
|
||||
bool LLIOPipe::hasNotExpired(void) const
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
// The connection was lost.
|
||||
STATUS_LOST_CONNECTION = -5,
|
||||
|
||||
// The totoal process time has exceeded the timeout.
|
||||
// The total process time has exceeded the timeout.
|
||||
STATUS_EXPIRED = -6,
|
||||
|
||||
// Keep track of the count of codes here.
|
||||
@@ -231,7 +231,16 @@ public:
|
||||
*/
|
||||
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:
|
||||
/**
|
||||
|
||||
@@ -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 void tcp_close_channel(LLSocket::ptr_t* handle_ptr); // Close an open TCP channel
|
||||
|
||||
LLProxy::LLProxy():
|
||||
mHTTPProxyEnabled(false),
|
||||
mProxyMutex(),
|
||||
mUDPProxy(),
|
||||
mTCPProxy(),
|
||||
mHTTPProxy(),
|
||||
ProxyShared::ProxyShared(void):
|
||||
mProxyType(LLPROXY_SOCKS),
|
||||
mAuthMethodSelected(METHOD_NOAUTH),
|
||||
mSocksUsername(),
|
||||
mSocksPassword()
|
||||
mAuthMethodSelected(METHOD_NOAUTH)
|
||||
{
|
||||
}
|
||||
|
||||
LLProxy::LLProxy():
|
||||
mHTTPProxyEnabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
LLProxy::~LLProxy()
|
||||
{
|
||||
stopSOCKSProxy();
|
||||
disableHTTPProxy();
|
||||
Shared_wat shared_w(mShared);
|
||||
disableHTTPProxy(shared_w);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,15 +77,18 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
|
||||
{
|
||||
S32 result;
|
||||
|
||||
Unshared_rat unshared_r(mUnshared);
|
||||
Shared_rat shared_r(mShared);
|
||||
|
||||
/* SOCKS 5 Auth request */
|
||||
socks_auth_request_t socks_auth_request;
|
||||
socks_auth_response_t socks_auth_response;
|
||||
|
||||
socks_auth_request.version = SOCKS_VERSION; // SOCKS version 5
|
||||
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)),
|
||||
sizeof(socks_auth_request),
|
||||
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)
|
||||
{
|
||||
// The server has requested a username/password combination
|
||||
std::string socks_username(getSocksUser());
|
||||
std::string socks_password(getSocksPwd());
|
||||
std::string socks_username(getSocksUser(shared_r));
|
||||
std::string socks_password(getSocksPwd(shared_r));
|
||||
U32 request_size = socks_username.size() + socks_password.size() + 3;
|
||||
char * password_auth = new char[request_size];
|
||||
password_auth[0] = 0x01;
|
||||
@@ -121,7 +123,7 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
|
||||
|
||||
authmethod_password_reply_t password_reply;
|
||||
|
||||
result = tcp_blocking_handshake(mProxyControlChannel,
|
||||
result = tcp_blocking_handshake(unshared_r->mProxyControlChannel,
|
||||
password_auth,
|
||||
request_size,
|
||||
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,
|
||||
// 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)),
|
||||
sizeof(connect_request),
|
||||
static_cast<char*>(static_cast<void*>(&connect_reply)),
|
||||
@@ -176,10 +178,14 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
|
||||
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.
|
||||
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;
|
||||
}
|
||||
@@ -197,9 +203,11 @@ S32 LLProxy::proxyHandshake(LLHost proxy)
|
||||
*/
|
||||
S32 LLProxy::startSOCKSProxy(LLHost host)
|
||||
{
|
||||
Unshared_wat unshared_w(mUnshared);
|
||||
|
||||
if (host.isOk())
|
||||
{
|
||||
mTCPProxy = host;
|
||||
unshared_w->mTCPProxy = host;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -209,13 +217,13 @@ S32 LLProxy::startSOCKSProxy(LLHost host)
|
||||
// Close any running SOCKS connection.
|
||||
stopSOCKSProxy();
|
||||
|
||||
mProxyControlChannel = tcp_open_channel(mTCPProxy);
|
||||
if (!mProxyControlChannel)
|
||||
unshared_w->mProxyControlChannel = tcp_open_channel(unshared_w->mTCPProxy);
|
||||
if (!unshared_w->mProxyControlChannel)
|
||||
{
|
||||
return SOCKS_HOST_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
S32 status = proxyHandshake(mTCPProxy);
|
||||
S32 status = proxyHandshake(unshared_w->mTCPProxy);
|
||||
|
||||
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
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (mProxyControlChannel)
|
||||
Unshared_wat unshared_w(mUnshared);
|
||||
if (unshared_w->mProxyControlChannel)
|
||||
{
|
||||
tcp_close_channel(&mProxyControlChannel);
|
||||
tcp_close_channel(&unshared_w->mProxyControlChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,9 +272,7 @@ void LLProxy::stopSOCKSProxy()
|
||||
*/
|
||||
void LLProxy::setAuthNone()
|
||||
{
|
||||
LLMutexLock lock(&mProxyMutex);
|
||||
|
||||
mAuthMethodSelected = METHOD_NOAUTH;
|
||||
Shared_wat(mShared)->mAuthMethodSelected = METHOD_NOAUTH;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,11 +296,10 @@ bool LLProxy::setAuthPassword(const std::string &username, const std::string &pa
|
||||
return false;
|
||||
}
|
||||
|
||||
LLMutexLock lock(&mProxyMutex);
|
||||
|
||||
mAuthMethodSelected = METHOD_PASSWORD;
|
||||
mSocksUsername = username;
|
||||
mSocksPassword = password;
|
||||
Shared_wat shared_w(mShared);
|
||||
shared_w->mAuthMethodSelected = METHOD_PASSWORD;
|
||||
shared_w->mSocksUsername = username;
|
||||
shared_w->mSocksPassword = password;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -314,12 +321,10 @@ bool LLProxy::enableHTTPProxy(LLHost httpHost, LLHttpProxyType type)
|
||||
return false;
|
||||
}
|
||||
|
||||
LLMutexLock lock(&mProxyMutex);
|
||||
|
||||
mHTTPProxy = httpHost;
|
||||
mProxyType = type;
|
||||
|
||||
Shared_wat shared_w(mShared);
|
||||
mHTTPProxyEnabled = true;
|
||||
shared_w->mHTTPProxy = httpHost;
|
||||
shared_w->mProxyType = type;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -335,9 +340,8 @@ bool LLProxy::enableHTTPProxy()
|
||||
{
|
||||
bool ok;
|
||||
|
||||
LLMutexLock lock(&mProxyMutex);
|
||||
|
||||
ok = (mHTTPProxy.isOk());
|
||||
Shared_rat shared_r(mShared);
|
||||
ok = (shared_r->mHTTPProxy.isOk());
|
||||
if (ok)
|
||||
{
|
||||
mHTTPProxyEnabled = true;
|
||||
@@ -346,54 +350,6 @@ bool LLProxy::enableHTTPProxy()
|
||||
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.
|
||||
*
|
||||
@@ -406,57 +362,6 @@ void LLProxy::cleanupClass()
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "llmemory.h"
|
||||
#include "llsingleton.h"
|
||||
#include "llthread.h"
|
||||
#include "aithreadsafe.h"
|
||||
#include <string>
|
||||
|
||||
// SOCKS error codes returned from the StartProxy method
|
||||
@@ -206,41 +207,92 @@ enum LLSocks5AuthType
|
||||
* The implementation of HTTP proxying is handled by libcurl. LLProxy
|
||||
* is responsible for managing the HTTP proxy options and provides a
|
||||
* thread-safe method to apply those options to a curl request
|
||||
* (LLProxy::applyProxySettings()). This method is overloaded
|
||||
* 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.
|
||||
* (LLProxy::applyProxySettings()).
|
||||
*
|
||||
* To ensure thread safety, all LLProxy members that relate to the HTTP
|
||||
* 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>
|
||||
{
|
||||
LOG_CLASS(LLProxy);
|
||||
|
||||
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.
|
||||
LLProxy();
|
||||
|
||||
// Static check for enabled status for UDP packets. Call from main thread only.
|
||||
static bool isSOCKSProxyEnabled() { return sUDPProxyEnabled; }
|
||||
// Static check for enabled status for UDP packets. Called from main thread only.
|
||||
static bool isSOCKSProxyEnabled(void) { llassert(is_main_thread()); return sUDPProxyEnabled; }
|
||||
|
||||
// Get the UDP proxy address and port. Call from main thread only.
|
||||
LLHost getUDPProxy() const { return mUDPProxy; }
|
||||
// Get the UDP proxy address and port. Called from main thread only.
|
||||
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().
|
||||
~LLProxy();
|
||||
@@ -251,9 +303,7 @@ public:
|
||||
|
||||
// Apply the current proxy settings to a curl request. Doesn't do anything if mHTTPProxyEnabled is false.
|
||||
// Safe to call from any thread.
|
||||
void applyProxySettings(CURL* handle);
|
||||
void applyProxySettings(LLCurl::Easy* handle);
|
||||
void applyProxySettings(LLCurlEasyRequest* handle);
|
||||
void applyProxySettings(AICurlEasyRequest_wat const& curlEasyRequest_w);
|
||||
|
||||
// Start a connection to the SOCKS 5 proxy. Call from main thread only.
|
||||
S32 startSOCKSProxy(LLHost host);
|
||||
@@ -273,30 +323,37 @@ public:
|
||||
bool enableHTTPProxy();
|
||||
|
||||
// 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:
|
||||
/*###########################################################################################
|
||||
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.
|
||||
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:
|
||||
@@ -304,49 +361,16 @@ private:
|
||||
// Instead use enableHTTPProxy() and disableHTTPProxy() instead.
|
||||
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?
|
||||
static bool sUDPProxyEnabled;
|
||||
|
||||
// UDP proxy address and port
|
||||
LLHost mUDPProxy;
|
||||
// TCP proxy control channel address and port
|
||||
LLHost mTCPProxy;
|
||||
AIThreadSafeSingleThreadDC<ProxyUnshared> mUnshared;
|
||||
AIThreadSafeDC<ProxyShared> mShared;
|
||||
|
||||
// socket handle to proxy TCP control channel
|
||||
LLSocket::ptr_t mProxyControlChannel;
|
||||
|
||||
/*###########################################################################################
|
||||
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
|
||||
###########################################################################################*/
|
||||
public:
|
||||
// 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; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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);
|
||||
if(chain.empty()) return false;
|
||||
|
||||
#if LL_THREADS_APR
|
||||
LLScopedLock lock(mChainsMutex);
|
||||
#endif
|
||||
chain_t::const_iterator it = chain.begin();
|
||||
chain_t::const_iterator const end = chain.end();
|
||||
if (it == end) return false;
|
||||
|
||||
LLChainInfo info;
|
||||
info.mHasCurlRequest = has_curl_request;
|
||||
info.setTimeoutSeconds(timeout);
|
||||
info.mData = LLIOPipe::buffer_ptr_t(new LLBufferArray);
|
||||
info.mData->setThreaded(has_curl_request);
|
||||
LLLinkInfo link;
|
||||
#if LL_DEBUG_PIPE_TYPE_IN_PUMP
|
||||
lldebugs << "LLPumpIO::addChain() " << chain[0] << " '"
|
||||
@@ -218,14 +216,17 @@ bool LLPumpIO::addChain(const chain_t& chain, F32 timeout, bool has_curl_request
|
||||
#else
|
||||
lldebugs << "LLPumpIO::addChain() " << chain[0] <<llendl;
|
||||
#endif
|
||||
chain_t::const_iterator it = chain.begin();
|
||||
chain_t::const_iterator end = chain.end();
|
||||
for(; it != end; ++it)
|
||||
{
|
||||
info.mHasExpiration = info.mHasExpiration || (*it)->hasExpiration();
|
||||
link.mPipe = (*it);
|
||||
link.mChannels = info.mData->nextChannel();
|
||||
info.mChainLinks.push_back(link);
|
||||
}
|
||||
|
||||
#if LL_THREADS_APR
|
||||
LLScopedLock lock(mChainsMutex);
|
||||
#endif
|
||||
mPendingChains.push_back(info);
|
||||
return true;
|
||||
}
|
||||
@@ -242,11 +243,10 @@ bool LLPumpIO::addChain(
|
||||
// description, we need to have that description matched to a
|
||||
// particular buffer.
|
||||
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
|
||||
lldebugs << "LLPumpIO::addChain() " << links[0].mPipe << " '"
|
||||
<< typeid(*(links[0].mPipe)).name() << "'" << llendl;
|
||||
@@ -258,6 +258,17 @@ bool LLPumpIO::addChain(
|
||||
info.mChainLinks = links;
|
||||
info.mData = data;
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
@@ -1086,14 +1097,14 @@ void LLPumpIO::processChain(LLChainInfo& chain)
|
||||
|
||||
bool LLPumpIO::isChainExpired(LLChainInfo& chain)
|
||||
{
|
||||
if(!chain.mHasCurlRequest)
|
||||
if(!chain.mHasExpiration)
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
for(links_t::iterator iter = chain.mChainLinks.begin(); iter != chain.mChainLinks.end(); ++iter)
|
||||
{
|
||||
if(!(*iter).mPipe->isValid())
|
||||
if(!(*iter).mPipe->hasNotExpired())
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
@@ -1106,6 +1117,8 @@ bool LLPumpIO::handleChainError(
|
||||
LLChainInfo& chain,
|
||||
LLIOPipe::EStatus error)
|
||||
{
|
||||
DoutEntering(dc::notice, "LLPumpIO::handleChainError(" << (void*)&chain << ", " << LLIOPipe::lookupStatusString(error) << ")");
|
||||
|
||||
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
|
||||
links_t::reverse_iterator rit;
|
||||
if(chain.mHead == chain.mChainLinks.end())
|
||||
@@ -1168,7 +1181,7 @@ LLPumpIO::LLChainInfo::LLChainInfo() :
|
||||
mInit(false),
|
||||
mLock(0),
|
||||
mEOS(false),
|
||||
mHasCurlRequest(false),
|
||||
mHasExpiration(false),
|
||||
mDescriptorsPool(new LLAPRPool(LLThread::tldata().mRootPool))
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
|
||||
@@ -1180,9 +1193,7 @@ void LLPumpIO::LLChainInfo::setTimeoutSeconds(F32 timeout)
|
||||
LLMemType m1(LLMemType::MTYPE_IO_PUMP);
|
||||
if(timeout > 0.0f)
|
||||
{
|
||||
mTimer.start();
|
||||
mTimer.reset();
|
||||
mTimer.setTimerExpirySec(timeout);
|
||||
mTimer.start(timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -100,10 +100,9 @@ public:
|
||||
* @param chain The pipes for the chain
|
||||
* @param timeout The number of seconds in the future to
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
@@ -347,7 +346,7 @@ protected:
|
||||
// basic member data
|
||||
bool mInit;
|
||||
bool mEOS;
|
||||
bool mHasCurlRequest;
|
||||
bool mHasExpiration;
|
||||
S32 mLock;
|
||||
LLFrameTimer mTimer;
|
||||
links_t::iterator mHead;
|
||||
|
||||
@@ -151,11 +151,11 @@ bool LLSDMessage::ResponderAdapter::listener(const LLSD& payload, bool success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
mResponder->result(payload);
|
||||
mResponder->pubResult(payload);
|
||||
}
|
||||
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 ----------------*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
@@ -29,6 +29,10 @@
|
||||
#include "linden_common.h"
|
||||
#include "llurlrequest.h"
|
||||
|
||||
#ifdef CWDEBUG
|
||||
#include <libcwd/buf2str.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <openssl/x509_vfy.h>
|
||||
#include <openssl/ssl.h>
|
||||
@@ -48,13 +52,10 @@ static const U32 HTTP_STATUS_PIPE_ERROR = 499;
|
||||
/**
|
||||
* String constants
|
||||
*/
|
||||
const std::string CONTEXT_DEST_URI_SD_LABEL("dest_uri");
|
||||
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
|
||||
@@ -65,7 +66,7 @@ public:
|
||||
LLURLRequestDetail();
|
||||
~LLURLRequestDetail();
|
||||
std::string mURL;
|
||||
LLCurlEasyRequest* mCurlRequest;
|
||||
AICurlEasyRequest mCurlEasyRequest;
|
||||
LLIOPipe::buffer_ptr_t mResponseBuffer;
|
||||
LLChannelDescriptors mChannels;
|
||||
U8* mLastRead;
|
||||
@@ -76,36 +77,28 @@ public:
|
||||
};
|
||||
|
||||
LLURLRequestDetail::LLURLRequestDetail() :
|
||||
mCurlRequest(NULL),
|
||||
mCurlEasyRequest(false),
|
||||
mLastRead(NULL),
|
||||
mBodyLimit(0),
|
||||
mByteAccumulator(0),
|
||||
mIsBodyLimitSet(false),
|
||||
mSSLVerifyCallback(NULL)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
mCurlRequest = new LLCurlEasyRequest();
|
||||
|
||||
if(!mCurlRequest->isValid()) //failed.
|
||||
{
|
||||
delete mCurlRequest ;
|
||||
mCurlRequest = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
LLURLRequestDetail::~LLURLRequestDetail()
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
delete mCurlRequest;
|
||||
mLastRead = NULL;
|
||||
}
|
||||
|
||||
void LLURLRequest::setSSLVerifyCallback(SSLCertVerifyCallback callback, void *param)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
mDetail->mSSLVerifyCallback = callback;
|
||||
mDetail->mCurlRequest->setSSLCtxCallback(LLURLRequest::_sslCtxCallback, (void *)this);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_SSL_VERIFYPEER, true);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_SSL_VERIFYHOST, 2);
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
|
||||
curlEasyRequest_w->setSSLCtxCallback(LLURLRequest::_sslCtxCallback, (void *)this);
|
||||
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)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
initialize();
|
||||
}
|
||||
|
||||
@@ -168,6 +162,7 @@ LLURLRequest::LLURLRequest(
|
||||
mAction(action)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
initialize();
|
||||
setURL(url);
|
||||
}
|
||||
@@ -175,13 +170,16 @@ LLURLRequest::LLURLRequest(
|
||||
LLURLRequest::~LLURLRequest()
|
||||
{
|
||||
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;
|
||||
mDetail = NULL ;
|
||||
}
|
||||
|
||||
void LLURLRequest::setURL(const std::string& url)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
mDetail->mURL = url;
|
||||
}
|
||||
|
||||
@@ -193,7 +191,8 @@ std::string LLURLRequest::getURL() const
|
||||
void LLURLRequest::addHeader(const char* header)
|
||||
{
|
||||
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)
|
||||
@@ -206,7 +205,8 @@ void LLURLRequest::setCallback(LLURLRequestComplete* callback)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
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
|
||||
@@ -242,30 +242,39 @@ void LLURLRequest::useProxy(bool use_proxy)
|
||||
|
||||
lldebugs << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = \"" << env_proxy << "\"" << llendl;
|
||||
|
||||
if (use_proxy)
|
||||
{
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, env_proxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_PROXY, "");
|
||||
}
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
|
||||
curlEasyRequest_w->setoptString(CURLOPT_PROXY, use_proxy ? env_proxy : std::string(""));
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_COOKIEFILE, "");
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
|
||||
curlEasyRequest_w->setoptString(CURLOPT_COOKIEFILE, "");
|
||||
}
|
||||
|
||||
//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
|
||||
@@ -273,10 +282,24 @@ LLIOPipe::EStatus LLURLRequest::handleError(
|
||||
LLIOPipe::EStatus status,
|
||||
LLPumpIO* pump)
|
||||
{
|
||||
DoutEntering(dc::curl, "LLURLRequest::handleError(" << LLIOPipe::lookupStatusString(status) << ", " << (void*)pump << ")");
|
||||
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 ;
|
||||
}
|
||||
|
||||
@@ -294,6 +317,19 @@ LLIOPipe::EStatus LLURLRequest::handleError(
|
||||
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");
|
||||
|
||||
// virtual
|
||||
@@ -310,7 +346,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
|
||||
//llinfos << "LLURLRequest::process_impl()" << llendl;
|
||||
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.
|
||||
const S32 MIN_ACCUMULATION = 100000;
|
||||
if(pump && (mDetail->mByteAccumulator > MIN_ACCUMULATION))
|
||||
@@ -354,44 +390,36 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
|
||||
{
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
mRemoved = false;
|
||||
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;
|
||||
}
|
||||
case STATE_WAITING_FOR_RESPONSE:
|
||||
case STATE_PROCESSING_RESPONSE:
|
||||
{
|
||||
PUMP_DEBUG;
|
||||
LLIOPipe::EStatus status = STATUS_BREAK;
|
||||
static LLFastTimer::DeclareTimer FTM_URL_PERFORM("Perform");
|
||||
if (!mRemoved) // Not removed from multi handle yet?
|
||||
{
|
||||
LLFastTimer t(FTM_URL_PERFORM);
|
||||
if(!mDetail->mCurlRequest->wait())
|
||||
{
|
||||
return status ;
|
||||
}
|
||||
// Easy handle is still being processed.
|
||||
return STATUS_BREAK;
|
||||
}
|
||||
// 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;
|
||||
|
||||
static LLFastTimer::DeclareTimer FTM_PROCESS_URL_REQUEST_GET_RESULT("Get Result");
|
||||
|
||||
bool newmsg = false;
|
||||
{
|
||||
LLFastTimer t(FTM_PROCESS_URL_REQUEST_GET_RESULT);
|
||||
newmsg = mDetail->mCurlRequest->getResult(&result);
|
||||
}
|
||||
AICurlEasyRequest_wat(*mDetail->mCurlEasyRequest)->getResult(&result);
|
||||
|
||||
if(!newmsg)
|
||||
{
|
||||
// keep processing
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
mState = STATE_HAVE_RESPONSE;
|
||||
context[CONTEXT_REQUEST][CONTEXT_TRANSFERED_BYTES] = mRequestTransferedBytes;
|
||||
context[CONTEXT_RESPONSE][CONTEXT_TRANSFERED_BYTES] = mResponseTransferedBytes;
|
||||
@@ -423,6 +451,7 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
|
||||
}
|
||||
mCompletionCallback = NULL;
|
||||
}
|
||||
status = STATUS_BREAK; // This is what the old code returned. Does it make sense?
|
||||
break;
|
||||
case CURLE_FAILED_INIT:
|
||||
case CURLE_COULDNT_CONNECT:
|
||||
@@ -464,16 +493,15 @@ void LLURLRequest::initialize()
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
mState = STATE_INITIALIZED;
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
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;
|
||||
mResponseTransferedBytes = 0;
|
||||
}
|
||||
@@ -488,70 +516,74 @@ bool LLURLRequest::configure()
|
||||
S32 bytes = mDetail->mResponseBuffer->countAfter(
|
||||
mDetail->mChannels.in(),
|
||||
NULL);
|
||||
switch(mAction)
|
||||
{
|
||||
case HTTP_HEAD:
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_HEADER, 1);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_NOBODY, 1);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
rv = true;
|
||||
break;
|
||||
case HTTP_GET:
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_HTTPGET, 1);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
|
||||
switch(mAction)
|
||||
{
|
||||
case HTTP_HEAD:
|
||||
curlEasyRequest_w->setopt(CURLOPT_HEADER, 1);
|
||||
curlEasyRequest_w->setopt(CURLOPT_NOBODY, 1);
|
||||
curlEasyRequest_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
rv = true;
|
||||
break;
|
||||
case HTTP_GET:
|
||||
curlEasyRequest_w->setopt(CURLOPT_HTTPGET, 1);
|
||||
curlEasyRequest_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||
|
||||
// Set Accept-Encoding to allow response compression
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, "");
|
||||
rv = true;
|
||||
break;
|
||||
// Set Accept-Encoding to allow response compression
|
||||
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case HTTP_PUT:
|
||||
// Disable the expect http 1.1 extension. POST and PUT default
|
||||
// to turning this on, and I am not too sure what it means.
|
||||
addHeader("Expect:");
|
||||
case HTTP_PUT:
|
||||
// Disable the expect http 1.1 extension. POST and PUT default
|
||||
// to turning this on, and I am not too sure what it means.
|
||||
addHeader("Expect:");
|
||||
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_UPLOAD, 1);
|
||||
mDetail->mCurlRequest->setopt(CURLOPT_INFILESIZE, bytes);
|
||||
rv = true;
|
||||
break;
|
||||
curlEasyRequest_w->setopt(CURLOPT_UPLOAD, 1);
|
||||
curlEasyRequest_w->setopt(CURLOPT_INFILESIZE, bytes);
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case HTTP_POST:
|
||||
// Disable the expect http 1.1 extension. POST and PUT default
|
||||
// to turning this on, and I am not too sure what it means.
|
||||
addHeader("Expect:");
|
||||
case HTTP_POST:
|
||||
// Disable the expect http 1.1 extension. POST and PUT default
|
||||
// to turning this on, and I am not too sure what it means.
|
||||
addHeader("Expect:");
|
||||
|
||||
// Disable the content type http header.
|
||||
// *FIX: what should it be?
|
||||
addHeader("Content-Type:");
|
||||
// Disable the content type http header.
|
||||
// *FIX: what should it be?
|
||||
addHeader("Content-Type:");
|
||||
|
||||
// Set the handle for an http post
|
||||
mDetail->mCurlRequest->setPost(NULL, bytes);
|
||||
// Set the handle for an http post
|
||||
curlEasyRequest_w->setPost(NULL, bytes);
|
||||
|
||||
// Set Accept-Encoding to allow response compression
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, "");
|
||||
rv = true;
|
||||
break;
|
||||
// Set Accept-Encoding to allow response compression
|
||||
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case HTTP_DELETE:
|
||||
// Set the handle for an http post
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
rv = true;
|
||||
break;
|
||||
case HTTP_DELETE:
|
||||
// Set the handle for an http post
|
||||
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
case HTTP_MOVE:
|
||||
// Set the handle for an http post
|
||||
mDetail->mCurlRequest->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE");
|
||||
// *NOTE: should we check for the Destination header?
|
||||
rv = true;
|
||||
break;
|
||||
case HTTP_MOVE:
|
||||
// Set the handle for an http post
|
||||
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE");
|
||||
// *NOTE: should we check for the Destination header?
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
llwarns << "Unhandled URLRequest action: " << mAction << llendl;
|
||||
break;
|
||||
}
|
||||
if(rv)
|
||||
{
|
||||
mDetail->mCurlRequest->sendRequest(mDetail->mURL);
|
||||
default:
|
||||
llwarns << "Unhandled URLRequest action: " << mAction << llendl;
|
||||
break;
|
||||
}
|
||||
if(rv)
|
||||
{
|
||||
curlEasyRequest_w->finalizeRequest(mDetail->mURL);
|
||||
curlEasyRequest_w->send_events_to(this);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@@ -615,9 +647,8 @@ size_t LLURLRequest::upCallback(
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
|
||||
|
||||
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_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
|
||||
* socket.
|
||||
*/
|
||||
class LLURLRequest : public LLIOPipe
|
||||
class LLURLRequest : public LLIOPipe, protected AICurlEasyHandleEvents
|
||||
{
|
||||
LOG_CLASS(LLURLRequest);
|
||||
public:
|
||||
@@ -190,7 +189,8 @@ public:
|
||||
*/
|
||||
void allowCookies();
|
||||
|
||||
/*virtual*/ bool isValid() ;
|
||||
/*virtual*/ bool hasExpiration(void) const;
|
||||
/*virtual*/ bool hasNotExpired(void) const;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -217,6 +217,7 @@ protected:
|
||||
STATE_INITIALIZED,
|
||||
STATE_WAITING_FOR_RESPONSE,
|
||||
STATE_PROCESSING_RESPONSE,
|
||||
STATE_CURL_FINISHED,
|
||||
STATE_HAVE_RESPONSE,
|
||||
};
|
||||
EState mState;
|
||||
@@ -228,6 +229,14 @@ protected:
|
||||
|
||||
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:
|
||||
/**
|
||||
* @brief Initialize the object. Called during construction.
|
||||
@@ -266,42 +275,6 @@ private:
|
||||
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
|
||||
* @brief Class which can optionally be used with an LLURLRequest to
|
||||
@@ -374,11 +347,4 @@ protected:
|
||||
EStatus mRequestStatus;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* External constants
|
||||
*/
|
||||
extern const std::string CONTEXT_DEST_URI_SD_LABEL;
|
||||
|
||||
#endif // LL_LLURLREQUEST_H
|
||||
|
||||
@@ -52,15 +52,16 @@ LLPluginClassBasic::~LLPluginClassBasic()
|
||||
delete mPlugin;
|
||||
}
|
||||
|
||||
bool LLPluginClassBasic::init(std::string const& launcher_filename, std::string const& plugin_filename, bool debug)
|
||||
bool LLPluginClassBasic::init(std::string const& launcher_filename, std::string const& plugin_dir, std::string const& plugin_filename, bool debug)
|
||||
{
|
||||
LL_DEBUGS("Plugin") << "launcher: " << launcher_filename << LL_ENDL;
|
||||
LL_DEBUGS("Plugin") << "dir: " << plugin_dir << LL_ENDL;
|
||||
LL_DEBUGS("Plugin") << "plugin: " << plugin_filename << LL_ENDL;
|
||||
|
||||
mPlugin = new LLPluginProcessParent(this);
|
||||
mPlugin->setSleepTime(mSleepTime);
|
||||
|
||||
mPlugin->init(launcher_filename, plugin_filename, debug);
|
||||
mPlugin->init(launcher_filename, plugin_dir, plugin_filename, debug);
|
||||
|
||||
return init_impl();
|
||||
}
|
||||
|
||||
@@ -53,7 +53,10 @@ public:
|
||||
virtual ~LLPluginClassBasic();
|
||||
|
||||
// Local initialization, called when creating a plugin process. Return true if successful.
|
||||
bool init(std::string const& launcher_filename, std::string const& plugin_filename, bool debug);
|
||||
bool init(std::string const& launcher_filename,
|
||||
std::string const& plugin_dir,
|
||||
std::string const& plugin_filename,
|
||||
bool debug);
|
||||
|
||||
// Undoes everything init did. Called when destroying a plugin process.
|
||||
void reset(void);
|
||||
|
||||
@@ -484,6 +484,7 @@ void LLPluginClassMedia::jsAgentMaturityEvent( const std::string& maturity )
|
||||
message.setValue( "maturity", maturity );
|
||||
sendMessage( message );
|
||||
}
|
||||
|
||||
void LLPluginClassMedia::mouseEvent(EMouseEventType type, int button, int x, int y, MASK modifiers)
|
||||
{
|
||||
if(type == MOUSE_EVENT_MOVE)
|
||||
@@ -573,7 +574,15 @@ bool LLPluginClassMedia::keyEvent(EKeyEventType type, int key_code, MASK modifie
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#if LL_DARWIN
|
||||
if(modifiers & MASK_ALT)
|
||||
{
|
||||
// Option-key modified characters should be handled by the unicode input path instead of this one.
|
||||
result = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(result)
|
||||
{
|
||||
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "key_event");
|
||||
@@ -731,6 +740,14 @@ void LLPluginClassMedia::setJavascriptEnabled(const bool enabled)
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
|
||||
void LLPluginClassMedia::enableMediaPluginDebugging( bool enable )
|
||||
{
|
||||
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "enable_media_plugin_debugging");
|
||||
message.setValueBoolean( "enable", enable );
|
||||
sendMessage( message );
|
||||
}
|
||||
|
||||
void LLPluginClassMedia::setTarget(const std::string &target)
|
||||
{
|
||||
mTarget = target;
|
||||
@@ -795,7 +812,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
|
||||
mDirtyRect.unionWith(newDirtyRect);
|
||||
}
|
||||
|
||||
LL_DEBUGS("PluginUpdated") << "adjusted incoming rect is: ("
|
||||
LL_DEBUGS("PluginUpdated") << "adjusted incoming rect is: ("
|
||||
<< newDirtyRect.mLeft << ", "
|
||||
<< newDirtyRect.mTop << ", "
|
||||
<< newDirtyRect.mRight << ", "
|
||||
@@ -958,6 +975,12 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
|
||||
mAuthURL = message.getValue("url");
|
||||
mAuthRealm = message.getValue("realm");
|
||||
mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_AUTH_REQUEST);
|
||||
}
|
||||
else if(message_name == "debug_message")
|
||||
{
|
||||
mDebugMessageText = message.getValue("message_text");
|
||||
mDebugMessageLevel = message.getValue("message_level");
|
||||
mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_DEBUG_MESSAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1103,6 +1126,14 @@ void LLPluginClassMedia::focus(bool focused)
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void LLPluginClassMedia::set_page_zoom_factor( double factor )
|
||||
{
|
||||
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "set_page_zoom_factor");
|
||||
|
||||
message.setValueReal("factor", factor);
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void LLPluginClassMedia::clear_cache()
|
||||
{
|
||||
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "clear_cache");
|
||||
@@ -1186,6 +1217,13 @@ void LLPluginClassMedia::setBrowserUserAgent(const std::string& user_agent)
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void LLPluginClassMedia::showWebInspector( bool show )
|
||||
{
|
||||
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "show_web_inspector");
|
||||
message.setValueBoolean("show", true); // only open for now - closed manually by user
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void LLPluginClassMedia::proxyWindowOpened(const std::string &target, const std::string &uuid)
|
||||
{
|
||||
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "proxy_window_opened");
|
||||
|
||||
@@ -112,6 +112,9 @@ public:
|
||||
|
||||
void scrollEvent(int x, int y, MASK modifiers);
|
||||
|
||||
// enable/disable media plugin debugging messages and info spam
|
||||
void enableMediaPluginDebugging( bool enable );
|
||||
|
||||
// Javascript <-> viewer events
|
||||
void jsEnableObject( bool enable );
|
||||
void jsAgentLocationEvent( double x, double y, double z );
|
||||
@@ -167,6 +170,7 @@ public:
|
||||
bool pluginSupportsMediaBrowser(void);
|
||||
|
||||
void focus(bool focused);
|
||||
void set_page_zoom_factor( double factor );
|
||||
void clear_cache();
|
||||
void clear_cookies();
|
||||
void set_cookies(const std::string &cookies);
|
||||
@@ -178,6 +182,7 @@ public:
|
||||
void browse_back();
|
||||
void set_status_redirect(int code, const std::string &url);
|
||||
void setBrowserUserAgent(const std::string& user_agent);
|
||||
void showWebInspector( bool show );
|
||||
void proxyWindowOpened(const std::string &target, const std::string &uuid);
|
||||
void proxyWindowClosed(const std::string &uuid);
|
||||
void ignore_ssl_cert_errors(bool ignore);
|
||||
@@ -213,6 +218,10 @@ public:
|
||||
// This is valid during MEDIA_EVENT_CLICK_LINK_HREF and MEDIA_EVENT_GEOMETRY_CHANGE
|
||||
std::string getClickUUID() const { return mClickUUID; };
|
||||
|
||||
// These are valid during MEDIA_EVENT_DEBUG_MESSAGE
|
||||
std::string getDebugMessageText() const { return mDebugMessageText; };
|
||||
std::string getDebugMessageLevel() const { return mDebugMessageLevel; };
|
||||
|
||||
// This is valid after MEDIA_EVENT_NAVIGATE_ERROR_PAGE
|
||||
S32 getStatusCode() const { return mStatusCode; };
|
||||
|
||||
@@ -271,7 +280,7 @@ protected:
|
||||
|
||||
protected:
|
||||
LLPluginClassMediaOwner *mOwner;
|
||||
|
||||
|
||||
bool mTextureParamsReceived; // the mRequestedTexture* fields are only valid when this is true
|
||||
S32 mRequestedTextureDepth;
|
||||
LLGLenum mRequestedTextureInternalFormat;
|
||||
@@ -358,6 +367,8 @@ protected:
|
||||
std::string mClickNavType;
|
||||
std::string mClickTarget;
|
||||
std::string mClickUUID;
|
||||
std::string mDebugMessageText;
|
||||
std::string mDebugMessageLevel;
|
||||
S32 mGeometryX;
|
||||
S32 mGeometryY;
|
||||
S32 mGeometryWidth;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user