Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
andarut committed Dec 24, 2023
1 parent 9893b78 commit 6cd209e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Dockerfile.focal
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
git unzip cmake make clang g++ g++-10 gperf netcat \
python3.7 python3-pip python3.7-distutils python3.7-dev libpython3.7-dev python3-jsonschema python3-setuptools mysql-server libmysqlclient-dev && \
wget https://github.com/curl/curl/releases/download/curl-7_65_0/curl-7.65.0.zip && unzip curl-7.65.0.zip && cd curl-7.65.0 && ./configure --disable-shared --with-openssl --disable-lpad --disable-ldaps && make -j$(nproc) && make install && cd .. && \
wget https://github.com/curl/curl/releases/download/curl-7_68_0/curl-7.68.0.zip && unzip curl-7.68.0.zip && cd curl-7.68.0 && ./configure --disable-shared --with-openssl --disable-lpad --disable-ldaps && make -j$(nproc) && make install && cd .. && \
mkdir /opt/curl840 && mkdir /opt/curl840/lib && mkdir /opt/curl840/include && cp /usr/local/lib/libcurl.a /opt/curl840/lib/ && cp -R /usr/local/include/curl/ /opt/curl840/include/ && \
python3.7 -m pip install pip && python3.7 -m pip install -r /tmp/requirements.txt && \
apt-get install -y --no-install-recommends kphp-timelib libuber-h3-dev libfmt-dev libgtest-dev libgmock-dev libre2-dev libpcre3-dev \
Expand Down
1 change: 1 addition & 0 deletions runtime/curl-async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class curl_exec_concurrently final : public Resumable {
resumable_id = vk::singleton<CurlAdaptor>::get().launch_request_resumable(request);
response = f$wait<std::unique_ptr<CurlResponse>, false>(resumable_id, timeout_s);
TRY_WAIT(curl_exec_concurrently_label, response, std::unique_ptr<CurlResponse>);
// kprintf("run %s\n", response->response.val().c_str());
vk::singleton<CurlAdaptor>::get().finish_request(request);
RETURN(response ? response->response : ReturnT{false});
RESUMABLE_END
Expand Down
3 changes: 2 additions & 1 deletion runtime/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ bool f$curl_setopt_array(curl_easy easy_id, const array<mixed> &options) noexcep
mixed f$curl_exec(curl_easy easy_id) noexcept {
constexpr double long_curl_query = 2 * 1e-1; // 0.2 sec
auto *easy_context = get_context<EasyContext>(easy_id);
kprintf("enter\n");
if (!easy_context) {
kprintf("bad1\n");
return false;
Expand Down Expand Up @@ -698,7 +699,7 @@ mixed f$curl_exec(curl_easy easy_id) noexcept {
}
if (easy_context->return_transfer) {
kprintf("good\n");
return easy_context->received_data.concat_and_get_string();
return easy_context->received_data.concat_and_get_string();
}

return true;
Expand Down
10 changes: 6 additions & 4 deletions test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "nonexistent_url");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$out = curl_setopt($ch, CURLOPT_URL, "hsdfm");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec_concurrently($ch, 1);


var_dump($out);
var_dump($output);
var_dump(curl_getinfo($ch, CURLINFO_RESPONSE_CODE));

curl_close($ch);
20 changes: 12 additions & 8 deletions test2.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

// создаём оба ресурса cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "sadfsadfs");
//создаём набор дескрипторов cURL
$mh = curl_multi_init();

// curl_setopt($ch, CURLOPT_URL, "nonexistent_url");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//добавляем два дескриптора
curl_multi_add_handle($mh,$ch);

$output = curl_exec_concurrently($ch, 1);
var_dump($output);
//запускаем множественный обработчик
$status = curl_multi_exec($mh, $active);
var_dump($status);

curl_close($ch);
//закрываем все дескрипторы
curl_multi_remove_handle($mh, $ch);
curl_multi_close($mh);
5 changes: 4 additions & 1 deletion test3.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

curl_setopt($ch, CURLOPT_URL, "nonexistent_url");

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);


// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec_concurrently($ch, 1);
$output = curl_exec($ch);

var_dump($output);

Expand Down

0 comments on commit 6cd209e

Please sign in to comment.