From cbd545748436985150734279077eb81246e4556d Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 3 Dec 2025 11:04:01 +0000
Subject: [PATCH] Update deprecated libevhtp API calls for
 Yellow-Camper/libevhtp compatibility

- Replace evhtp_set_hook(&req->hooks, ...) with evhtp_request_set_hook(req, ...)
- Replace evhtp_set_hook(&cb->hooks, ...) with evhtp_callback_set_hook(cb, ...)
- Replace evhtp_use_threads(...) with evhtp_use_threads_wexit(...)

Co-authored-by: barracuda156 <92015510+barracuda156@users.noreply.github.com>

diff --git a/server/access-file.c b/server/access-file.c
index 14a3c3c4..aa66e6be 100644
--- server/access-file.c
+++ server/access-file.c
@@ -2345,7 +2345,7 @@ access_headers_cb (evhtp_request_t *req, evhtp_headers_t *hdr, void *arg)
     gettimeofday (&info->start, NULL);
 
     seaf_metric_manager_in_flight_request_inc (seaf->metric_mgr);
-    evhtp_set_hook (&req->hooks, evhtp_hook_on_request_fini, request_finish_cb, info);
+    evhtp_request_set_hook (req, evhtp_hook_on_request_fini, (evhtp_hook)request_finish_cb, info);
     req->cbarg = info;
 
     return EVHTP_RES_OK;
@@ -2357,19 +2357,19 @@ access_file_init (evhtp_t *htp)
     evhtp_callback_t *cb;
 
     cb = evhtp_set_regex_cb (htp, "^/files/.*", access_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, access_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)access_headers_cb, NULL);
 
     cb = evhtp_set_regex_cb (htp, "^/blks/.*", access_blks_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, access_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)access_headers_cb, NULL);
 
     cb = evhtp_set_regex_cb (htp, "^/zip/.*", access_zip_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, access_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)access_headers_cb, NULL);
 
     cb = evhtp_set_regex_cb (htp, "^/f/.*", access_link_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, access_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)access_headers_cb, NULL);
     //evhtp_set_regex_cb (htp, "^/d/.*", access_dir_link_cb, NULL);
     cb = evhtp_set_regex_cb (htp, "^/repos/[\\da-z]{8}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{12}/files/.*", access_v2_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, access_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)access_headers_cb, NULL);
 
     return 0;
 }
diff --git a/server/http-server.c b/server/http-server.c
index 5208f9a6..8dacde89 100644
--- server/http-server.c
+++ server/http-server.c
@@ -3056,7 +3056,7 @@ http_request_start_cb (evhtp_request_t *req, evhtp_headers_t *hdr, void *arg)
     gettimeofday (&info->start, NULL);
 
     seaf_metric_manager_in_flight_request_inc (seaf->metric_mgr);
-    evhtp_set_hook (&req->hooks, evhtp_hook_on_request_fini, http_request_finish_cb, info);
+    evhtp_request_set_hook (req, evhtp_hook_on_request_fini, (evhtp_hook)http_request_finish_cb, info);
     req->cbarg = info;
 
     return EVHTP_RES_OK;
@@ -3071,37 +3071,37 @@ http_request_init (HttpServerStruct *server)
     cb = evhtp_set_cb (priv->evhtp,
                   GET_PROTO_PATH, get_protocol_cb,
                   NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         GET_CHECK_QUOTA_REGEX, get_check_quota_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         OP_PERM_CHECK_REGEX, get_check_permission_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         HEAD_COMMIT_OPER_REGEX, head_commit_oper_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         GET_HEAD_COMMITS_MULTI_REGEX, head_commits_multi_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         COMMIT_OPER_REGEX, commit_oper_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         GET_FS_OBJ_ID_REGEX, get_fs_obj_id_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     // evhtp_set_regex_cb (priv->evhtp,
     //                     START_FS_OBJ_ID_REGEX, start_fs_obj_id_cb,
@@ -3118,42 +3118,42 @@ http_request_init (HttpServerStruct *server)
     cb = evhtp_set_regex_cb (priv->evhtp,
                         BLOCK_OPER_REGEX, block_oper_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         POST_CHECK_FS_REGEX, post_check_fs_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         POST_CHECK_BLOCK_REGEX, post_check_block_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         POST_RECV_FS_REGEX, post_recv_fs_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         POST_PACK_FS_REGEX, post_pack_fs_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         GET_BLOCK_MAP_REGEX, get_block_map_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         GET_JWT_TOKEN_REGEX, get_jwt_token_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     cb = evhtp_set_regex_cb (priv->evhtp,
                         GET_ACCESSIBLE_REPO_LIST_REGEX, get_accessible_repo_list_cb,
                         NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, http_request_start_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)http_request_start_cb, NULL);
 
     /* Web access file */
     access_file_init (priv->evhtp);
@@ -3268,7 +3268,7 @@ http_server_run (void *arg)
 
     http_request_init (server);
 
-    evhtp_use_threads (priv->evhtp, NULL, server->worker_threads, NULL);
+    evhtp_use_threads_wexit (priv->evhtp, NULL, NULL, server->worker_threads, NULL);
 
     struct timeval tv;
     tv.tv_sec = CLEANING_INTERVAL_SEC;


https://github.com/freebsd/freebsd-ports/blob/main/net-mgmt/seafile-server/files/patch-server_upload-file.c
--- server/upload-file.c	2021-12-09 05:24:45 UTC
+++ server/upload-file.c
@@ -2234,7 +2234,7 @@ out:
         /* Set keepalive to 0. This will cause evhtp to close the
          * connection after sending the reply.
          */
-        req->keepalive = 0;
+	evhtp_request_set_keepalive(req, 0);
 
         fsm->state = RECV_ERROR;
     }
@@ -2545,8 +2545,8 @@ upload_headers_cb (evhtp_request_t *req, evhtp_headers
     }
 
     /* Set up per-request hooks, so that we can read file data piece by piece. */
-    evhtp_set_hook (&req->hooks, evhtp_hook_on_read, upload_read_cb, fsm);
-    evhtp_set_hook (&req->hooks, evhtp_hook_on_request_fini, upload_finish_cb, fsm);
+    evhtp_request_set_hook (req, evhtp_hook_on_read, (evhtp_hook)upload_read_cb, fsm);
+    evhtp_request_set_hook (req, evhtp_hook_on_request_fini, (evhtp_hook)upload_finish_cb, fsm);
     /* Set arg for upload_cb or update_cb. */
     req->cbarg = fsm;
 
@@ -2561,7 +2561,7 @@ err:
     /* Set keepalive to 0. This will cause evhtp to close the
      * connection after sending the reply.
      */
-    req->keepalive = 0;
+	 evhtp_request_set_keepalive(req, 0);
     send_error_reply (req, error_code, err_msg);
 
     g_free (repo_id);
@@ -2662,32 +2662,32 @@ upload_file_init (evhtp_t *htp, const char *http_temp_
     g_free (cluster_shared_dir);
 
     cb = evhtp_set_regex_cb (htp, "^/upload-api/.*", upload_api_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)upload_headers_cb, NULL);
 
     cb = evhtp_set_regex_cb (htp, "^/upload-raw-blks-api/.*",
                              upload_raw_blks_api_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)upload_headers_cb, NULL);
 
     cb = evhtp_set_regex_cb (htp, "^/upload-blks-api/.*", upload_blks_api_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)upload_headers_cb, NULL);
 
     /* cb = evhtp_set_regex_cb (htp, "^/upload-blks-aj/.*", upload_blks_ajax_cb, NULL); */
     /* evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); */
 
     cb = evhtp_set_regex_cb (htp, "^/upload-aj/.*", upload_ajax_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)upload_headers_cb, NULL);
 
     cb = evhtp_set_regex_cb (htp, "^/update-api/.*", update_api_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)upload_headers_cb, NULL);
 
     cb = evhtp_set_regex_cb (htp, "^/update-blks-api/.*", update_blks_api_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)upload_headers_cb, NULL);
 
     /* cb = evhtp_set_regex_cb (htp, "^/update-blks-aj/.*", update_blks_ajax_cb, NULL); */
     /* evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); */
 
     cb = evhtp_set_regex_cb (htp, "^/update-aj/.*", update_ajax_cb, NULL);
-    evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL);
+    evhtp_callback_set_hook(cb, evhtp_hook_on_headers, (evhtp_hook)upload_headers_cb, NULL);
 
     evhtp_set_regex_cb (htp, "^/upload_progress.*", upload_progress_cb, NULL);
 
