Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Oct 29, 2024
1 parent f133584 commit 8d697ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/network/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1111,8 +1111,7 @@ static void Client_onTimeout(Timer *timer, TimerNode *tnode) {
}

static void Client_onResolveCompleted(AsyncEvent *event) {
auto async_req = event->data;
GethostbynameRequest *req = dynamic_cast<GethostbynameRequest *>(async_req.get());
GethostbynameRequest *req = dynamic_cast<GethostbynameRequest *>(event->data.get());

Client *cli = (Client *) event->object;
cli->wait_dns = 0;
Expand Down
6 changes: 2 additions & 4 deletions src/os/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ namespace async {

void handler_gethostbyname(AsyncEvent *event) {
char addr[INET6_ADDRSTRLEN];
std::shared_ptr<AsyncRequest> async_req = event->data;
auto req = dynamic_cast<GethostbynameRequest *>(async_req.get());
auto req = dynamic_cast<GethostbynameRequest *>(event->data.get());
int ret = network::gethostbyname(req->family, req->name.c_str(), addr);
sw_memset_zero(req->addr, req->addr_len);

Expand All @@ -113,8 +112,7 @@ void handler_gethostbyname(AsyncEvent *event) {
}

void handler_getaddrinfo(AsyncEvent *event) {
std::shared_ptr<AsyncRequest> async_req = event->data;
auto req = dynamic_cast<GetaddrinfoRequest *>(async_req.get());
auto req = dynamic_cast<GetaddrinfoRequest *>(event->data.get());
event->retval = network::getaddrinfo(req);
event->error = req->error;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/swoole_coroutine_system/getaddrinfo.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ skip_if_offline();
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
go(function () {
Co\run(function () {
$ip_list = Swoole\Coroutine\System::getaddrinfo('www.baidu.com', AF_INET);
Assert::assert(!empty($ip_list) and is_array($ip_list));
foreach ($ip_list as $ip) {
Expand Down

0 comments on commit 8d697ec

Please sign in to comment.