mirror of
https://github.com/curl/curl.git
synced 2026-08-26 08:13:32 +03:00
lib: reduce use of data->conn->
If there are more than two of them in a function, use a local 'conn' variable instead. Closes #19063
This commit is contained in:
parent
9441127394
commit
ae5fb4188d
6 changed files with 62 additions and 50 deletions
46
lib/multi.c
46
lib/multi.c
|
|
@ -939,11 +939,12 @@ static CURLcode mstate_connecting_pollset(struct Curl_easy *data,
|
|||
static CURLcode mstate_protocol_pollset(struct Curl_easy *data,
|
||||
struct easy_pollset *ps)
|
||||
{
|
||||
if(data->conn) {
|
||||
struct connectdata *conn = data->conn;
|
||||
if(conn) {
|
||||
curl_socket_t sockfd;
|
||||
if(data->conn->handler->proto_pollset)
|
||||
return data->conn->handler->proto_pollset(data, ps);
|
||||
sockfd = data->conn->sock[FIRSTSOCKET];
|
||||
if(conn->handler->proto_pollset)
|
||||
return conn->handler->proto_pollset(data, ps);
|
||||
sockfd = conn->sock[FIRSTSOCKET];
|
||||
if(sockfd != CURL_SOCKET_BAD) {
|
||||
/* Default is to wait to something from the server */
|
||||
return Curl_pollset_change(data, ps, sockfd, CURL_POLL_IN, 0);
|
||||
|
|
@ -955,13 +956,14 @@ static CURLcode mstate_protocol_pollset(struct Curl_easy *data,
|
|||
static CURLcode mstate_do_pollset(struct Curl_easy *data,
|
||||
struct easy_pollset *ps)
|
||||
{
|
||||
if(data->conn) {
|
||||
if(data->conn->handler->doing_pollset)
|
||||
return data->conn->handler->doing_pollset(data, ps);
|
||||
else if(CONN_SOCK_IDX_VALID(data->conn->send_idx)) {
|
||||
struct connectdata *conn = data->conn;
|
||||
if(conn) {
|
||||
if(conn->handler->doing_pollset)
|
||||
return conn->handler->doing_pollset(data, ps);
|
||||
else if(CONN_SOCK_IDX_VALID(conn->send_idx)) {
|
||||
/* Default is that we want to send something to the server */
|
||||
return Curl_pollset_add_out(
|
||||
data, ps, data->conn->sock[data->conn->send_idx]);
|
||||
data, ps, conn->sock[conn->send_idx]);
|
||||
}
|
||||
}
|
||||
return CURLE_OK;
|
||||
|
|
@ -970,13 +972,14 @@ static CURLcode mstate_do_pollset(struct Curl_easy *data,
|
|||
static CURLcode mstate_domore_pollset(struct Curl_easy *data,
|
||||
struct easy_pollset *ps)
|
||||
{
|
||||
if(data->conn) {
|
||||
if(data->conn->handler->domore_pollset)
|
||||
return data->conn->handler->domore_pollset(data, ps);
|
||||
else if(CONN_SOCK_IDX_VALID(data->conn->send_idx)) {
|
||||
struct connectdata *conn = data->conn;
|
||||
if(conn) {
|
||||
if(conn->handler->domore_pollset)
|
||||
return conn->handler->domore_pollset(data, ps);
|
||||
else if(CONN_SOCK_IDX_VALID(conn->send_idx)) {
|
||||
/* Default is that we want to send something to the server */
|
||||
return Curl_pollset_add_out(
|
||||
data, ps, data->conn->sock[data->conn->send_idx]);
|
||||
data, ps, conn->sock[conn->send_idx]);
|
||||
}
|
||||
}
|
||||
return CURLE_OK;
|
||||
|
|
@ -985,22 +988,23 @@ static CURLcode mstate_domore_pollset(struct Curl_easy *data,
|
|||
static CURLcode mstate_perform_pollset(struct Curl_easy *data,
|
||||
struct easy_pollset *ps)
|
||||
{
|
||||
if(!data->conn)
|
||||
struct connectdata *conn = data->conn;
|
||||
if(!conn)
|
||||
return CURLE_OK;
|
||||
else if(data->conn->handler->perform_pollset)
|
||||
return data->conn->handler->perform_pollset(data, ps);
|
||||
else if(conn->handler->perform_pollset)
|
||||
return conn->handler->perform_pollset(data, ps);
|
||||
else {
|
||||
/* Default is to obey the data->req.keepon flags for send/recv */
|
||||
CURLcode result = CURLE_OK;
|
||||
if(CURL_WANT_RECV(data) && CONN_SOCK_IDX_VALID(data->conn->recv_idx)) {
|
||||
if(CURL_WANT_RECV(data) && CONN_SOCK_IDX_VALID(conn->recv_idx)) {
|
||||
result = Curl_pollset_add_in(
|
||||
data, ps, data->conn->sock[data->conn->recv_idx]);
|
||||
data, ps, conn->sock[conn->recv_idx]);
|
||||
}
|
||||
|
||||
if(!result && Curl_req_want_send(data) &&
|
||||
CONN_SOCK_IDX_VALID(data->conn->send_idx)) {
|
||||
CONN_SOCK_IDX_VALID(conn->send_idx)) {
|
||||
result = Curl_pollset_add_out(
|
||||
data, ps, data->conn->sock[data->conn->send_idx]);
|
||||
data, ps, conn->sock[conn->send_idx]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue