Skip to content

Commit

Permalink
url: remove dummy protocol handler
Browse files Browse the repository at this point in the history
Just two added checks were needed saves a whole handler struct.

Closes #10727
  • Loading branch information
bagder committed Mar 10, 2023
1 parent dc141a3 commit f384d40
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
2 changes: 1 addition & 1 deletion lib/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ void Curl_attach_connection(struct Curl_easy *data,
data->conn = conn;
Curl_llist_insert_next(&conn->easyq, conn->easyq.tail, data,
&data->conn_queue);
if(conn->handler->attach)
if(conn->handler && conn->handler->attach)
conn->handler->attach(data, conn);
Curl_conn_ev_data_attach(conn, data);
}
Expand Down
33 changes: 1 addition & 32 deletions lib/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,33 +288,6 @@ static const struct Curl_handler * const protocols[] = {
(struct Curl_handler *) NULL
};

/*
* Dummy handler for undefined protocol schemes.
*/

static const struct Curl_handler Curl_handler_dummy = {
"<no protocol>", /* scheme */
ZERO_NULL, /* setup_connection */
ZERO_NULL, /* do_it */
ZERO_NULL, /* done */
ZERO_NULL, /* do_more */
ZERO_NULL, /* connect_it */
ZERO_NULL, /* connecting */
ZERO_NULL, /* doing */
ZERO_NULL, /* proto_getsock */
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* domore_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
ZERO_NULL, /* connection_check */
ZERO_NULL, /* attach connection */
0, /* defport */
0, /* protocol */
0, /* family */
PROTOPT_NONE /* flags */
};

void Curl_freeset(struct Curl_easy *data)
{
/* Free all dynamic strings stored in the data->set substructure. */
Expand Down Expand Up @@ -825,7 +798,7 @@ void Curl_disconnect(struct Curl_easy *data,
disconnect and shutdown */
Curl_attach_connection(data, conn);

if(conn->handler->disconnect)
if(conn->handler && conn->handler->disconnect)
/* This is set if protocol-specific cleanups should be made */
conn->handler->disconnect(data, conn, dead_connection);

Expand Down Expand Up @@ -1509,10 +1482,6 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
if(!conn)
return NULL;

conn->handler = &Curl_handler_dummy; /* Be sure we have a handler defined
already from start to avoid NULL
situations and checks */

/* and we setup a few fields in case we end up actually using this struct */

conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */
Expand Down

0 comments on commit f384d40

Please sign in to comment.