Author: brane
Date: Sun Jun  7 11:38:48 2026
New Revision: 1935100

Log:
On the serf-195 branch: Reorganize and rename the reqest list functions.

* serf_private.h
  (serf_reqlist_t): Add docstring.
  (serf__reqlist_push): Renamed from serf__push_request.
  (serf__reqlist_peek): Renamed from serf__peek_request.
  (serf__reqlist_pop): Renamed from serf__take_request.
  (serf__reqlist_delete): Renamed from serf__delete_from_reqlist.
  (serf__reqlist_recalc): Renamed from serf__req_list_recalc_length.

* protocols/http2_stream.c,
  src/outgoing.c,
  src/outgoing_request.c: Updated all references.

* src/outgoing_request.c:
  (serf__reqlist_push, serf__reqlist_peek, serf__reqlist_pop,
   serf__reqlist_delete, serf__reqlist_recalc): Moved implementations
   to the top of the file.

Modified:
   serf/branches/SERF-195/protocols/http2_stream.c
   serf/branches/SERF-195/serf_private.h
   serf/branches/SERF-195/src/outgoing.c
   serf/branches/SERF-195/src/outgoing_request.c

Modified: serf/branches/SERF-195/protocols/http2_stream.c
==============================================================================
--- serf/branches/SERF-195/protocols/http2_stream.c     Sun Jun  7 10:45:06 
2026        (r1935099)
+++ serf/branches/SERF-195/protocols/http2_stream.c     Sun Jun  7 11:38:48 
2026        (r1935100)
@@ -359,8 +359,8 @@ serf_http2__stream_setup_next_request(se
             return status;
     }
 
-    serf__take_request(&conn->unwritten_reqs, request);
-    serf__push_request(&conn->written_reqs, request);
+    serf__reqlist_pop(&conn->unwritten_reqs, request);
+    serf__reqlist_push(&conn->written_reqs, request);
 
     serf__bucket_request_read(request->req_bkt, &body, NULL, NULL);
     status = serf__bucket_hpack_create_from_request(
@@ -794,7 +794,7 @@ serf_http2__stream_processor(void *baton
              to remove it from the outstanding requests */
         {
             serf_connection_t *conn = serf_request_get_conn(sd->request);
-            serf__delete_from_reqlist(&conn->written_reqs, sd->request);
+            serf__reqlist_delete(&conn->written_reqs, sd->request);
             serf__destroy_request(sd->request);
             stream->data->request = NULL;
         }

Modified: serf/branches/SERF-195/serf_private.h
==============================================================================
--- serf/branches/SERF-195/serf_private.h       Sun Jun  7 10:45:06 2026        
(r1935099)
+++ serf/branches/SERF-195/serf_private.h       Sun Jun  7 11:38:48 2026        
(r1935100)
@@ -250,6 +250,22 @@ apr_status_t serf__init_once(struct serf
                              void *init_baton);
 
 
+/*** Request list handling ***/
+
+/* Maintains a linked list of requests. */
+typedef struct serf_reqlist_t {
+    struct serf_request_t *head;
+    struct serf_request_t *tail;
+    unsigned int count;
+} serf_reqlist_t;
+
+void serf__reqlist_push(serf_reqlist_t *list, serf_request_t *request);
+void serf__reqlist_peek(serf_reqlist_t *list, serf_request_t **requestp);
+void serf__reqlist_pop(serf_reqlist_t *list, serf_request_t *request);
+void serf__reqlist_delete(serf_reqlist_t *list, serf_request_t *request);
+void serf__reqlist_recalc(serf_reqlist_t *req);
+
+
 typedef struct serf__authn_scheme_t serf__authn_scheme_t;
 
 typedef struct serf_io_baton_t {
@@ -318,12 +334,6 @@ typedef enum serf_request_writing_t {
     SERF_WRITING_FINISHED       /* Safe to destroy */
 } serf_request_writing_t;
 
-typedef struct serf_reqlist_t {
-    struct serf_request_t *head;
-    struct serf_request_t *tail;
-    unsigned int count;
-} serf_reqlist_t;
-
 /* Holds all the information corresponding to a request/response pair. */
 struct serf_request_t {
     serf_connection_t *conn;
@@ -954,15 +964,10 @@ apr_status_t serf__bucket_hpack_create_f
                                         serf_bucket_alloc_t *allocator);
 
 /* From outgoing_request.c */
-void serf__push_request(serf_reqlist_t *list, serf_request_t *request);
-void serf__peek_request(serf_reqlist_t *list, serf_request_t **requestp);
-void serf__take_request(serf_reqlist_t *list, serf_request_t *request);
-void serf__delete_from_reqlist(serf_reqlist_t *list, serf_request_t *request);
 apr_status_t serf__destroy_request(serf_request_t *request);
 apr_status_t serf__cancel_request(serf_request_t *request,
                                   serf_reqlist_t *list,
                                   int notify_request);
-void serf__req_list_recalc_length(serf_reqlist_t *req);
 apr_status_t serf__setup_request(serf_request_t *request);
 
 apr_status_t serf__handle_response(serf_request_t *request,

Modified: serf/branches/SERF-195/src/outgoing.c
==============================================================================
--- serf/branches/SERF-195/src/outgoing.c       Sun Jun  7 10:45:06 2026        
(r1935099)
+++ serf/branches/SERF-195/src/outgoing.c       Sun Jun  7 11:38:48 2026        
(r1935100)
@@ -76,7 +76,7 @@ request_pending(serf_request_t **next_re
         /* Skip all requests that have been written completely but we're still
          waiting for a response. */
         serf_request_t *request;
-        serf__peek_request(&conn->unwritten_reqs, &request);
+        serf__reqlist_peek(&conn->unwritten_reqs, &request);
 
         if (next_req)
             *next_req = request;
@@ -248,7 +248,7 @@ void serf__connection_pre_cleanup(serf_c
 
     /* Destroy the requests that were queued up to destroy later */
     while ((rq = conn->done_reqs.head)) {
-        serf__take_request(&conn->done_reqs, rq);
+        serf__reqlist_pop(&conn->done_reqs, rq);
 
         rq->writing = SERF_WRITING_FINISHED;
         serf__destroy_request(rq);
@@ -523,8 +523,8 @@ static apr_status_t reset_connection(ser
         {
 
             serf_request_t *req = old_reqs.head;
-            serf__take_request(&old_reqs, req);
-            serf__push_request(&conn->unwritten_reqs, req);
+            serf__reqlist_pop(&old_reqs, req);
+            serf__reqlist_push(&conn->unwritten_reqs, req);
         }
         else
         {
@@ -582,8 +582,7 @@ static apr_status_t reset_connection(ser
     conn->seen_in_pollset |= APR_POLLHUP;
 
     /* Recalculate the current list length */
-    conn->written_reqs.count = 0;
-    serf__req_list_recalc_length(&conn->unwritten_reqs);
+    serf__reqlist_recalc(&conn->unwritten_reqs);
 
     /* Found the connection. Closed it. All done. */
     return APR_SUCCESS;
@@ -632,8 +631,8 @@ static apr_status_t request_writing_fini
 
         if (conn->unwritten_reqs.head == request) {
             /* Move the request to the written queue */
-            serf__take_request(&conn->unwritten_reqs, request);
-            serf__push_request(&conn->written_reqs, request);
+            serf__reqlist_pop(&conn->unwritten_reqs, request);
+            serf__reqlist_push(&conn->written_reqs, request);
         }
 
         /* If our connection has async responses enabled, we're not
@@ -807,10 +806,10 @@ static apr_status_t read_from_connection
         /* Whatever is coming in on the socket corresponds to the first request
          * on our chain.
          */
-        serf__peek_request(&conn->written_reqs, &request);
+        serf__reqlist_peek(&conn->written_reqs, &request);
         if (!request) {
             /* Request wasn't completely written yet! */
-            serf__peek_request(&conn->unwritten_reqs, &request);
+            serf__reqlist_peek(&conn->unwritten_reqs, &request);
         }
 
         /* We have a different codepath when we can have async responses. */
@@ -938,16 +937,16 @@ static apr_status_t read_from_connection
          * Remove it from our queue and loop to read another response.
          */
         if (request->list == &conn->written_reqs) {
-            serf__take_request(&conn->written_reqs, request);
+            serf__reqlist_pop(&conn->written_reqs, request);
         } else {
-            serf__take_request(&conn->unwritten_reqs, request);
+            serf__reqlist_pop(&conn->unwritten_reqs, request);
         }
 
         serf__destroy_request(request);
 
-        serf__peek_request(&conn->written_reqs, &request);
+        serf__reqlist_peek(&conn->written_reqs, &request);
         if (!request) {
-            serf__peek_request(&conn->unwritten_reqs, &request);
+            serf__reqlist_peek(&conn->unwritten_reqs, &request);
         }
 
         conn->completed_responses++;

Modified: serf/branches/SERF-195/src/outgoing_request.c
==============================================================================
--- serf/branches/SERF-195/src/outgoing_request.c       Sun Jun  7 10:45:06 
2026        (r1935099)
+++ serf/branches/SERF-195/src/outgoing_request.c       Sun Jun  7 11:38:48 
2026        (r1935100)
@@ -38,6 +38,85 @@
 
 #include "serf_private.h"
 
+
+/*** Request list handling ***/
+
+/* Push a request to the head of the lined list. */
+void serf__reqlist_push(serf_reqlist_t *list, serf_request_t *request)
+{
+    SERF__REQLIST_assert(request->list == NULL);
+    request->list = list;
+    if (list->head == NULL) {
+        list->head = request;
+        list->tail = request;
+    } else {
+        list->tail->next = request;
+        list->tail = request;
+    }
+    ++list->count;
+}
+
+/* Check if the linked list is not empty (contains a request). */
+void serf__reqlist_peek(serf_reqlist_t *list, serf_request_t **requestp)
+{
+    serf_request_t *request = list->head;
+    SERF__REQLIST_assert(request == NULL || request->list == list);
+    *requestp = request;
+}
+
+/* Pop a request from the head of the liked list. */
+void serf__reqlist_pop(serf_reqlist_t *list, serf_request_t *request)
+{
+    SERF__REQLIST_assert(list->head == request && request->list == list);
+    list->head = request->next;
+    if (list->head == NULL)
+        list->tail = NULL;
+    --list->count;
+    request->next = NULL;
+    request->list = NULL;
+}
+
+/* Remove a request from a linked list. */
+void serf__reqlist_delete(serf_reqlist_t *list, serf_request_t *request)
+{
+    SERF__REQLIST_assert(request->list == list);
+
+    if (list->head == request) {
+        list->head = request->next;
+    } else {
+        serf_request_t *scan = list->head;
+
+        while (scan->next && scan->next != request)
+            scan = scan->next;
+
+        SERF__REQLIST_assert(scan->next == request);
+
+        scan->next = request->next;
+    }
+
+    if (list->head == NULL)
+        list->tail = NULL;
+
+    --list->count;
+    request->next = NULL;
+    request->list = NULL;
+}
+
+/* Calculate the length of a linked list of requests. */
+void serf__reqlist_recalc(serf_reqlist_t *list)
+{
+    unsigned int length = 0;
+    serf_request_t *req = list->head;
+
+    while (req) {
+        ++length;
+        req = req->next;
+    }
+
+    list->count = length;
+}
+
+
 static apr_status_t clean_resp(void *data)
 {
     serf_request_t *request = data;
@@ -98,38 +177,6 @@ static apr_status_t clean_resp(void *dat
     return APR_SUCCESS;
 }
 
-void serf__push_request(serf_reqlist_t *list, serf_request_t *request)
-{
-    SERF__REQLIST_assert(request->list == NULL);
-    request->list = list;
-    if (list->head == NULL) {
-        list->head = request;
-        list->tail = request;
-    } else {
-        list->tail->next = request;
-        list->tail = request;
-    }
-    ++list->count;
-}
-
-void serf__peek_request(serf_reqlist_t *list, serf_request_t **requestp)
-{
-    serf_request_t *request = list->head;
-    SERF__REQLIST_assert(request == NULL || request->list == list);
-    *requestp = request;
-}
-
-void serf__take_request(serf_reqlist_t *list, serf_request_t *request)
-{
-    SERF__REQLIST_assert(list->head == request && request->list == list);
-    list->head = request->next;
-    if (list->head == NULL)
-        list->tail = NULL;
-    --list->count;
-    request->next = NULL;
-    request->list = NULL;
-}
-
 apr_status_t serf__destroy_request(serf_request_t *request)
 {
     serf_connection_t *conn = request->conn;
@@ -204,7 +251,7 @@ apr_status_t serf__destroy_request(serf_
     }
 
     if (request->list != NULL) {
-        serf__delete_from_reqlist(request->list, request);
+        serf__reqlist_delete(request->list, request);
     }
 
     if (request->writing >= SERF_WRITING_STARTED
@@ -215,7 +262,7 @@ apr_status_t serf__destroy_request(serf_
            Destroying now will destroy memory of buckets that we
            may still need.
         */
-        serf__push_request(&conn->done_reqs, request);
+        serf__reqlist_push(&conn->done_reqs, request);
     }
     else {
 
@@ -232,31 +279,6 @@ apr_status_t serf__destroy_request(serf_
     return APR_SUCCESS;
 }
 
-void serf__delete_from_reqlist(serf_reqlist_t *list, serf_request_t *request)
-{
-    SERF__REQLIST_assert(request->list == list);
-
-    if (list->head == request) {
-        list->head = request->next;
-    } else {
-        serf_request_t *scan = list->head;
-
-        while (scan->next && scan->next != request)
-            scan = scan->next;
-
-        SERF__REQLIST_assert(scan->next == request);
-
-        scan->next = request->next;
-    }
-
-    if (list->head == NULL)
-        list->tail = NULL;
-
-    --list->count;
-    request->next = NULL;
-    request->list = NULL;
-}
-
 apr_status_t serf__cancel_request(serf_request_t *request,
                                   serf_reqlist_t *list,
                                   int notify_request)
@@ -277,25 +299,11 @@ apr_status_t serf__cancel_request(serf_r
                                               SERF_ERROR_HTTP2_CANCEL);
     }
 
-    serf__delete_from_reqlist(list, request);
+    serf__reqlist_delete(list, request);
 
     return serf__destroy_request(request);
 }
 
-/* Calculate the length of a linked list of requests. */
-void serf__req_list_recalc_length(serf_reqlist_t *list)
-{
-    unsigned int length = 0;
-    serf_request_t *req = list->head;
-
-    while (req) {
-        length++;
-        req = req->next;
-    }
-
-    list->count = length;
-}
-
 apr_status_t serf__setup_request(serf_request_t *request)
 {
     serf_connection_t *conn = request->conn;
@@ -506,7 +514,7 @@ serf_request_t *serf_connection_request_
                              false /* ssl tunnel */);
 
     /* Link the request to the end of the request chain. */
-    serf__push_request(&conn->unwritten_reqs, request);
+    serf__reqlist_push(&conn->unwritten_reqs, request);
 
     /* Ensure our pollset becomes writable in context run */
     serf_io__set_pollset_dirty(&conn->io);

Reply via email to