summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/pipeline.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/pipeline.c')
-rw-r--r--Utilities/cmcurl/lib/pipeline.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/Utilities/cmcurl/lib/pipeline.c b/Utilities/cmcurl/lib/pipeline.c
index 4a14fdd..b8d2037 100644
--- a/Utilities/cmcurl/lib/pipeline.c
+++ b/Utilities/cmcurl/lib/pipeline.c
@@ -38,16 +38,15 @@
#include "memdebug.h"
struct site_blacklist_entry {
- char *hostname;
+ struct curl_llist_element list;
unsigned short port;
+ char hostname[1];
};
static void site_blacklist_llist_dtor(void *user, void *element)
{
struct site_blacklist_entry *entry = element;
(void)user;
-
- Curl_safefree(entry->hostname);
free(entry);
}
@@ -94,8 +93,8 @@ bool Curl_pipeline_penalized(struct Curl_easy *data,
static CURLcode addHandleToPipeline(struct Curl_easy *data,
struct curl_llist *pipeline)
{
- if(!Curl_llist_insert_next(pipeline, pipeline->tail, data))
- return CURLE_OUT_OF_MEMORY;
+ Curl_llist_insert_next(pipeline, pipeline->tail, data,
+ &data->pipeline_queue);
return CURLE_OK;
}
@@ -114,7 +113,7 @@ CURLcode Curl_add_handle_to_pipeline(struct Curl_easy *handle,
if(pipeline == &conn->send_pipe && sendhead != conn->send_pipe.head) {
/* this is a new one as head, expire it */
Curl_pipeline_leave_write(conn); /* not in use yet */
- Curl_expire(conn->send_pipe.head->ptr, 0);
+ Curl_expire(conn->send_pipe.head->ptr, 0, EXPIRE_RUN_NOW);
}
#if 0 /* enable for pipeline debugging */
@@ -149,7 +148,7 @@ void Curl_move_handle_from_send_to_recv_pipe(struct Curl_easy *handle,
infof(conn->data, "%p is at send pipe head B!\n",
(void *)conn->send_pipe.head->ptr);
#endif
- Curl_expire(conn->send_pipe.head->ptr, 0);
+ Curl_expire(conn->send_pipe.head->ptr, 0, EXPIRE_RUN_NOW);
}
/* The receiver's list is not really interesting here since either this
@@ -202,24 +201,17 @@ CURLMcode Curl_pipeline_set_site_blacklist(char **sites,
/* Parse the URLs and populate the list */
while(*sites) {
- char *hostname;
char *port;
struct site_blacklist_entry *entry;
- hostname = strdup(*sites);
- if(!hostname) {
- Curl_llist_destroy(list, NULL);
- return CURLM_OUT_OF_MEMORY;
- }
-
- entry = malloc(sizeof(struct site_blacklist_entry));
+ entry = malloc(sizeof(struct site_blacklist_entry) + strlen(*sites));
if(!entry) {
- free(hostname);
Curl_llist_destroy(list, NULL);
return CURLM_OUT_OF_MEMORY;
}
+ strcpy(entry->hostname, *sites);
- port = strchr(hostname, ':');
+ port = strchr(entry->hostname, ':');
if(port) {
*port = '\0';
port++;
@@ -230,14 +222,7 @@ CURLMcode Curl_pipeline_set_site_blacklist(char **sites,
entry->port = 80;
}
- entry->hostname = hostname;
-
- if(!Curl_llist_insert_next(list, list->tail, entry)) {
- site_blacklist_llist_dtor(NULL, entry);
- Curl_llist_destroy(list, NULL);
- return CURLM_OUT_OF_MEMORY;
- }
-
+ Curl_llist_insert_next(list, list->tail, entry, &entry->list);
sites++;
}
}
@@ -274,6 +259,11 @@ bool Curl_pipeline_server_blacklisted(struct Curl_easy *handle,
return FALSE;
}
+struct blacklist_node {
+ struct curl_llist_element list;
+ char server_name[1];
+};
+
CURLMcode Curl_pipeline_set_server_blacklist(char **servers,
struct curl_llist *list)
{
@@ -286,20 +276,18 @@ CURLMcode Curl_pipeline_set_server_blacklist(char **servers,
/* Parse the URLs and populate the list */
while(*servers) {
- char *server_name;
-
- server_name = strdup(*servers);
- if(!server_name) {
- Curl_llist_destroy(list, NULL);
- return CURLM_OUT_OF_MEMORY;
- }
+ struct blacklist_node *n;
+ size_t len = strlen(*servers);
- if(!Curl_llist_insert_next(list, list->tail, server_name)) {
+ n = malloc(sizeof(struct blacklist_node) + len);
+ if(!n) {
Curl_llist_destroy(list, NULL);
- Curl_safefree(server_name);
return CURLM_OUT_OF_MEMORY;
}
+ strcpy(n->server_name, *servers);
+ Curl_llist_insert_next(list, list->tail, n->server_name,
+ &n->list);
servers++;
}
}