Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
55f1d95d
Commit
55f1d95d
authored
13 years ago
by
Oz Linden
Browse files
Options
Downloads
Plain Diff
merge changes for vmrg-210
parents
5dc8e44c
ec06aa12
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
indra/llcommon/llthread.h
+5
-2
5 additions, 2 deletions
indra/llcommon/llthread.h
indra/llmessage/llcurl.cpp
+85
-46
85 additions, 46 deletions
indra/llmessage/llcurl.cpp
indra/llmessage/llcurl.h
+5
-0
5 additions, 0 deletions
indra/llmessage/llcurl.h
with
95 additions
and
48 deletions
indra/llcommon/llthread.h
+
5
−
2
View file @
55f1d95d
...
...
@@ -187,10 +187,13 @@ class LLMutexLock
LLMutexLock
(
LLMutex
*
mutex
)
{
mMutex
=
mutex
;
if
(
mMutex
)
mMutex
->
lock
();
}
~
LLMutexLock
()
{
if
(
mMutex
)
mMutex
->
unlock
();
}
private
:
...
...
This diff is collapsed.
Click to expand it.
indra/llmessage/llcurl.cpp
+
85
−
46
View file @
55f1d95d
...
...
@@ -219,11 +219,15 @@ namespace boost
std
::
set
<
CURL
*>
LLCurl
::
Easy
::
sFreeHandles
;
std
::
set
<
CURL
*>
LLCurl
::
Easy
::
sActiveHandles
;
LLMutex
*
LLCurl
::
Easy
::
sHandleMutexp
=
NULL
;
//static
CURL
*
LLCurl
::
Easy
::
allocEasyHandle
()
{
CURL
*
ret
=
NULL
;
LLMutexLock
lock
(
sHandleMutexp
)
;
if
(
sFreeHandles
.
empty
())
{
ret
=
curl_easy_init
();
...
...
@@ -251,6 +255,7 @@ void LLCurl::Easy::releaseEasyHandle(CURL* handle)
llerrs
<<
"handle cannot be NULL!"
<<
llendl
;
}
LLMutexLock
lock
(
sHandleMutexp
)
;
if
(
sActiveHandles
.
find
(
handle
)
!=
sActiveHandles
.
end
())
{
sActiveHandles
.
erase
(
handle
);
...
...
@@ -512,20 +517,21 @@ void LLCurl::Easy::prepRequest(const std::string& url,
}
////////////////////////////////////////////////////////////////////////////
LLMutex
*
LLCurl
::
Multi
::
sMultiInitMutexp
=
NULL
;
LLCurl
::
Multi
::
Multi
()
:
mQueued
(
0
),
mErrorCount
(
0
),
mState
(
STATE_READY
),
mDead
(
FALSE
),
mMutexp
(
NULL
),
mDeletionMutexp
(
NULL
)
mDeletionMutexp
(
NULL
),
mEasyMutexp
(
NULL
)
{
mCurlMultiHandle
=
curl_multi_init
();
mCurlMultiHandle
=
initMulti
();
if
(
!
mCurlMultiHandle
)
{
llwarns
<<
"curl_multi_init() returned NULL! Easy handles: "
<<
gCurlEasyCount
<<
" Multi handles: "
<<
gCurlMultiCount
<<
llendl
;
mCurlMultiHandle
=
curl_multi_init
();
mCurlMultiHandle
=
initMulti
();
}
llassert_always
(
mCurlMultiHandle
);
...
...
@@ -534,6 +540,7 @@ LLCurl::Multi::Multi()
{
mMutexp
=
new
LLMutex
(
NULL
)
;
mDeletionMutexp
=
new
LLMutex
(
NULL
)
;
mEasyMutexp
=
new
LLMutex
(
NULL
)
;
}
LLCurl
::
getCurlThread
()
->
addMulti
(
this
)
;
...
...
@@ -563,10 +570,19 @@ LLCurl::Multi::~Multi()
mMutexp
=
NULL
;
delete
mDeletionMutexp
;
mDeletionMutexp
=
NULL
;
delete
mEasyMutexp
;
mEasyMutexp
=
NULL
;
--
gCurlMultiCount
;
}
CURLM
*
LLCurl
::
Multi
::
initMulti
()
{
LLMutexLock
lock
(
sMultiInitMutexp
)
;
return
curl_multi_init
()
;
}
void
LLCurl
::
Multi
::
lock
()
{
if
(
mMutexp
)
...
...
@@ -585,39 +601,26 @@ void LLCurl::Multi::unlock()
void
LLCurl
::
Multi
::
markDead
()
{
if
(
mDeletionMutexp
)
{
mDeletionMutexp
->
lock
()
;
}
LLMutexLock
lock
(
mDeletionMutexp
)
;
mDead
=
TRUE
;
if
(
mDeletionMutexp
)
{
mDeletionMutexp
->
unlock
()
;
}
}
void
LLCurl
::
Multi
::
setState
(
LLCurl
::
Multi
::
ePerformState
state
)
{
lock
()
;
mState
=
state
;
unlock
()
;
if
(
mState
==
STATE_READY
)
{
LLCurl
::
getCurlThread
()
->
setPriority
(
mHandle
,
LLQueuedThread
::
PRIORITY_NORMAL
)
;
}
unlock
()
;
}
LLCurl
::
Multi
::
ePerformState
LLCurl
::
Multi
::
getState
()
{
ePerformState
state
;
lock
()
;
state
=
mState
;
unlock
()
;
return
state
;
return
mState
;
}
bool
LLCurl
::
Multi
::
isCompleted
()
...
...
@@ -633,21 +636,19 @@ bool LLCurl::Multi::waitToComplete()
return
true
;
}
bool
completed
;
lock
()
;
completed
=
(
STATE_COMPLETED
==
mState
)
;
bool
completed
=
(
STATE_COMPLETED
==
mState
)
;
if
(
!
completed
)
{
LLCurl
::
getCurlThread
()
->
setPriority
(
mHandle
,
LLQueuedThread
::
PRIORITY_URGENT
)
;
}
unlock
()
;
return
completed
;
}
CURLMsg
*
LLCurl
::
Multi
::
info_read
(
S32
*
msgs_in_queue
)
{
LLMutexLock
lock
(
mMutexp
)
;
CURLMsg
*
curlmsg
=
curl_multi_info_read
(
mCurlMultiHandle
,
msgs_in_queue
);
return
curlmsg
;
}
...
...
@@ -655,10 +656,8 @@ CURLMsg* LLCurl::Multi::info_read(S32* msgs_in_queue)
//return true if dead
bool
LLCurl
::
Multi
::
doPerform
()
{
if
(
mDeletionMutexp
)
{
mDeletionMutexp
->
lock
()
;
}
LLMutexLock
lock
(
mDeletionMutexp
)
;
bool
dead
=
mDead
;
if
(
mDead
)
...
...
@@ -675,6 +674,7 @@ bool LLCurl::Multi::doPerform()
call_count
<
MULTI_PERFORM_CALL_REPEAT
;
call_count
++
)
{
LLMutexLock
lock
(
mMutexp
)
;
CURLMcode
code
=
curl_multi_perform
(
mCurlMultiHandle
,
&
q
);
if
(
CURLM_CALL_MULTI_PERFORM
!=
code
||
q
==
0
)
{
...
...
@@ -688,11 +688,6 @@ bool LLCurl::Multi::doPerform()
setState
(
STATE_COMPLETED
)
;
}
if
(
mDeletionMutexp
)
{
mDeletionMutexp
->
unlock
()
;
}
return
dead
;
}
...
...
@@ -715,10 +710,19 @@ S32 LLCurl::Multi::process()
if
(
msg
->
msg
==
CURLMSG_DONE
)
{
U32
response
=
0
;
Easy
*
easy
=
NULL
;
{
LLMutexLock
lock
(
mEasyMutexp
)
;
easy_active_map_t
::
iterator
iter
=
mEasyActiveMap
.
find
(
msg
->
easy_handle
);
if
(
iter
!=
mEasyActiveMap
.
end
())
{
Easy
*
easy
=
iter
->
second
;
easy
=
iter
->
second
;
}
}
if
(
easy
)
{
response
=
easy
->
report
(
msg
->
data
.
result
);
removeEasy
(
easy
);
}
...
...
@@ -751,11 +755,13 @@ LLCurl::Easy* LLCurl::Multi::allocEasy()
}
else
{
LLMutexLock
lock
(
mEasyMutexp
)
;
easy
=
*
(
mEasyFreeList
.
begin
());
mEasyFreeList
.
erase
(
easy
);
}
if
(
easy
)
{
LLMutexLock
lock
(
mEasyMutexp
)
;
mEasyActiveList
.
insert
(
easy
);
mEasyActiveMap
[
easy
->
getCurlHandle
()]
=
easy
;
}
...
...
@@ -764,6 +770,7 @@ LLCurl::Easy* LLCurl::Multi::allocEasy()
bool
LLCurl
::
Multi
::
addEasy
(
Easy
*
easy
)
{
LLMutexLock
lock
(
mMutexp
)
;
CURLMcode
mcode
=
curl_multi_add_handle
(
mCurlMultiHandle
,
easy
->
getCurlHandle
());
check_curl_multi_code
(
mcode
);
//if (mcode != CURLM_OK)
...
...
@@ -776,22 +783,41 @@ bool LLCurl::Multi::addEasy(Easy* easy)
void
LLCurl
::
Multi
::
easyFree
(
Easy
*
easy
)
{
if
(
mEasyMutexp
)
{
mEasyMutexp
->
lock
()
;
}
mEasyActiveList
.
erase
(
easy
);
mEasyActiveMap
.
erase
(
easy
->
getCurlHandle
());
if
(
mEasyFreeList
.
size
()
<
EASY_HANDLE_POOL_SIZE
)
{
easy
->
resetState
();
mEasyFreeList
.
insert
(
easy
);
if
(
mEasyMutexp
)
{
mEasyMutexp
->
unlock
()
;
}
easy
->
resetState
();
}
else
{
if
(
mEasyMutexp
)
{
mEasyMutexp
->
unlock
()
;
}
delete
easy
;
}
}
void
LLCurl
::
Multi
::
removeEasy
(
Easy
*
easy
)
{
{
LLMutexLock
lock
(
mMutexp
)
;
check_curl_multi_code
(
curl_multi_remove_handle
(
mCurlMultiHandle
,
easy
->
getCurlHandle
()));
}
easyFree
(
easy
);
}
...
...
@@ -834,11 +860,17 @@ void LLCurlThread::CurlRequest::finishRequest(bool completed)
LLCurlThread
::
LLCurlThread
(
bool
threaded
)
:
LLQueuedThread
(
"curlthread"
,
threaded
)
{
if
(
!
LLCurl
::
Multi
::
sMultiInitMutexp
)
{
LLCurl
::
Multi
::
sMultiInitMutexp
=
new
LLMutex
(
NULL
)
;
}
}
//virtual
LLCurlThread
::~
LLCurlThread
()
{
delete
LLCurl
::
Multi
::
sMultiInitMutexp
;
LLCurl
::
Multi
::
sMultiInitMutexp
=
NULL
;
}
S32
LLCurlThread
::
update
(
U32
max_time_ms
)
...
...
@@ -1290,6 +1322,10 @@ void LLCurl::initClass(bool multi_threaded)
#endif
sCurlThread
=
new
LLCurlThread
(
multi_threaded
)
;
if
(
multi_threaded
)
{
Easy
::
sHandleMutexp
=
new
LLMutex
(
NULL
)
;
}
}
void
LLCurl
::
cleanupClass
()
...
...
@@ -1319,6 +1355,9 @@ void LLCurl::cleanupClass()
Easy
::
sFreeHandles
.
clear
();
delete
Easy
::
sHandleMutexp
;
Easy
::
sHandleMutexp
=
NULL
;
llassert
(
Easy
::
sActiveHandles
.
empty
());
}
...
...
This diff is collapsed.
Click to expand it.
indra/llmessage/llcurl.h
+
5
−
0
View file @
55f1d95d
...
...
@@ -253,6 +253,7 @@ class LLCurl::Easy
static
std
::
set
<
CURL
*>
sFreeHandles
;
static
std
::
set
<
CURL
*>
sActiveHandles
;
static
LLMutex
*
sHandleMutexp
;
};
class
LLCurl
::
Multi
...
...
@@ -298,6 +299,7 @@ class LLCurl::Multi
S32
mQueued
;
S32
mErrorCount
;
static
CURLM
*
initMulti
()
;
private
:
void
easyFree
(
LLCurl
::
Easy
*
);
...
...
@@ -316,6 +318,9 @@ class LLCurl::Multi
BOOL
mDead
;
LLMutex
*
mMutexp
;
LLMutex
*
mDeletionMutexp
;
LLMutex
*
mEasyMutexp
;
static
LLMutex
*
sMultiInitMutexp
;
};
class
LLCurlThread
:
public
LLQueuedThread
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment