Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Sep 7, 2021
1 parent 3b9c9a5 commit 03e6f6d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/network/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,12 @@ static ssize_t Client_tcp_recv_no_buffer(Client *cli, char *data, size_t len, in
while (1) {
#ifdef HAVE_KQUEUE
int timeout_ms = (int) (cli->timeout * 1000);
if (cli->socket->wait_event(timeout_ms, SW_EVENT_READ) < 0) {
#ifdef SW_USE_OPENSSL
if (cli->socket->ssl) {
timeout_ms = 0;
}
#endif
if (timeout_ms > 0 && cli->socket->wait_event(timeout_ms, SW_EVENT_READ) < 0) {
return -1;
}
#endif
Expand All @@ -768,7 +773,7 @@ static ssize_t Client_tcp_recv_no_buffer(Client *cli, char *data, size_t len, in
}
}
#ifdef SW_USE_OPENSSL
if (errno == EAGAIN && cli->socket->ssl) {
if (cli->socket->catch_error(errno) == SW_WAIT && cli->socket->ssl) {
int timeout_ms = (int) (cli->timeout * 1000);
if (cli->socket->ssl_want_read && cli->socket->wait_event(timeout_ms, SW_EVENT_READ) == SW_OK) {
continue;
Expand Down
1 change: 1 addition & 0 deletions src/protocol/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "swoole_string.h"
#include "swoole_socket.h"
#include "swoole_protocol.h"

namespace swoole {
/**
* return the package total length
Expand Down
2 changes: 1 addition & 1 deletion src/server/master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void Server::call_command_callback(int64_t request_id, const std::string &result
auto iter = command_callbacks.find(request_id);
if (iter == command_callbacks.end()) {
swoole_error_log(
SW_LOG_ERROR, SW_ERROR_SERVER_INVALID_COMMAND, "Invalid command result[request_id=%lu]", request_id);
SW_LOG_ERROR, SW_ERROR_SERVER_INVALID_COMMAND, "Invalid command result[request_id=%ld]", request_id);
return;
}
iter->second(this, result);
Expand Down

0 comments on commit 03e6f6d

Please sign in to comment.