Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
93ecdb2e
Commit
93ecdb2e
authored
Jan 06, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimizations for parallelexecution plugin
parent
1c18f53f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
library/Solarium/Client/Adapter/Curl.php
library/Solarium/Client/Adapter/Curl.php
+4
-0
library/Solarium/Plugin/ParallelExecution.php
library/Solarium/Plugin/ParallelExecution.php
+9
-7
No files found.
library/Solarium/Client/Adapter/Curl.php
View file @
93ecdb2e
...
...
@@ -91,6 +91,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
public
function
getResponse
(
$handle
,
$httpResponse
)
{
// @codeCoverageIgnoreStart
if
(
$httpResponse
!==
false
)
{
$data
=
$httpResponse
;
$info
=
curl_getinfo
(
$handle
);
...
...
@@ -101,8 +102,10 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$data
=
''
;
}
curl_close
(
$handle
);
$this
->
check
(
$data
,
$headers
);
return
new
Solarium_Client_Response
(
$data
,
$headers
);
// @codeCoverageIgnoreEnd
}
/**
...
...
@@ -151,6 +154,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
}
return
$ch
;
// @codeCoverageIgnoreEnd
}
/**
...
...
library/Solarium/Plugin/ParallelExecution.php
View file @
93ecdb2e
...
...
@@ -61,19 +61,17 @@ class Solarium_Plugin_ParallelExecution extends Solarium_Plugin_Abstract
*/
public
function
execute
(
$queries
)
{
// @codeCoverageIgnoreStart
$adapter
=
$this
->
_client
->
setAdapter
(
'Solarium_Client_Adapter_Curl'
)
->
getAdapter
();
// create handles
// create handles and add all handles to the multihandle
$multiHandle
=
curl_multi_init
();
$handles
=
array
();
foreach
(
$queries
as
$key
=>
$query
)
{
$request
=
$this
->
_client
->
createRequest
(
$query
);
$handles
[
$key
]
=
$adapter
->
createHandle
(
$request
);
}
// add all handles to the multihandle
$multiHandle
=
curl_multi_init
();
foreach
(
$handles
as
$handle
)
{
$handle
=
$adapter
->
createHandle
(
$request
);
curl_multi_add_handle
(
$multiHandle
,
$handle
);
$handles
[
$key
]
=
$handle
;
}
// executing multihandle (all requests)
...
...
@@ -87,6 +85,7 @@ class Solarium_Plugin_ParallelExecution extends Solarium_Plugin_Abstract
$results
=
array
();
foreach
(
$handles
as
$key
=>
$handle
)
{
try
{
curl_multi_remove_handle
(
$multiHandle
,
$handle
);
$response
=
$adapter
->
getResponse
(
$handle
,
curl_multi_getcontent
(
$handle
));
$results
[
$key
]
=
$this
->
_client
->
createResult
(
$queries
[
$key
],
$response
);
}
catch
(
Solarium_Client_HttpException
$e
)
{
...
...
@@ -94,7 +93,10 @@ class Solarium_Plugin_ParallelExecution extends Solarium_Plugin_Abstract
}
}
curl_multi_close
(
$multiHandle
);
return
$results
;
// @codeCoverageIgnoreEnd
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment