libevhtp 1.2.18 made API changes, and unbundled oniguruma. To adapt seafile-server, some patches from Alexandre Rossi's debian packaging at http://sousmonlit.zincube.net/~niol/repositories.git/ were applied. Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>lilik-openwrt-22.03
@ -0,0 +1,40 @@ | |||
Author: David Barbion <davidb@230ruedubac.fr> | |||
Description: Use shared object for libevhtp | |||
Forwarded: https://github.com/haiwen/seafile-server/pull/12 | |||
Index: seafile-server/configure.ac | |||
=================================================================== | |||
--- seafile-server.orig/configure.ac | |||
+++ seafile-server/configure.ac | |||
@@ -218,6 +218,10 @@ PKG_CHECK_MODULES(LIBEVENT, [libevent >= | |||
AC_SUBST(LIBEVENT_CFLAGS) | |||
AC_SUBST(LIBEVENT_LIBS) | |||
+PKG_CHECK_MODULES(LIBEVHTP, [evhtp]) | |||
+AC_SUBST(LIBEVHTP_CFLAGS) | |||
+AC_SUBST(LIBEVHTP_LIBS) | |||
+ | |||
PKG_CHECK_MODULES(ZLIB, [zlib >= $ZLIB_REQUIRED]) | |||
AC_SUBST(ZLIB_CFLAGS) | |||
AC_SUBST(ZLIB_LIBS) | |||
Index: seafile-server/server/Makefile.am | |||
=================================================================== | |||
--- seafile-server.orig/server/Makefile.am | |||
+++ seafile-server/server/Makefile.am | |||
@@ -13,6 +13,7 @@ AM_CFLAGS = -DPKGDATADIR=\"$(pkgdatadir) | |||
@GLIB2_CFLAGS@ \ | |||
@MSVC_CFLAGS@ \ | |||
@LIBARCHIVE_CFLAGS@ \ | |||
+ @LIBEVHTP_CFLAGS@ \ | |||
-Wall | |||
bin_PROGRAMS = seaf-server | |||
@@ -114,7 +115,7 @@ seaf_server_SOURCES = \ | |||
seaf_server_LDADD = @CCNET_LIBS@ \ | |||
$(top_builddir)/lib/libseafile_common.la \ | |||
- @GLIB2_LIBS@ @GOBJECT_LIBS@ @SSL_LIBS@ @LIB_RT@ @LIB_UUID@ -lsqlite3 @LIBEVENT_LIBS@ -levhtp \ | |||
+ -lonig @GLIB2_LIBS@ @GOBJECT_LIBS@ @SSL_LIBS@ @LIB_RT@ @LIB_UUID@ -lsqlite3 @LIBEVENT_LIBS@ @LIBEVHTP_LIBS@ \ | |||
$(top_builddir)/common/cdc/libcdc.la \ | |||
$(top_builddir)/common/db-wrapper/libdbwrapper.la \ | |||
@SEARPC_LIBS@ @JANSSON_LIBS@ ${LIB_WS32} @ZLIB_LIBS@ \ |
@ -0,0 +1,69 @@ | |||
Author: Alexandre Rossi <alexandre.rossi@gmail.com> | |||
Description: Fix download stalling on recent libevhtp | |||
A while ago[1], evhtp_request_pause() behavior changed: it now disables | |||
both read and write events. seafile-server would then stall. | |||
. | |||
[1] https://github.com/criticalstack/libevhtp/commit/6cd89466fd6bd76c5b8624be65af5893afe3e40c | |||
[2] https://github.com/haiwen/seafile/issues/1119 | |||
Forwarded: no | |||
Index: seafile-server/server/access-file.c | |||
=================================================================== | |||
--- seafile-server.orig/server/access-file.c 2018-02-01 12:23:53.209308343 +0100 | |||
+++ seafile-server/server/access-file.c 2018-02-01 12:23:53.205308288 +0100 | |||
@@ -618,7 +618,7 @@ | |||
/* Block any new request from this connection before finish | |||
* handling this request. | |||
*/ | |||
- evhtp_request_pause (req); | |||
+ bufferevent_disable(bev, EV_READ); | |||
/* Kick start data transfer by sending out http headers. */ | |||
evhtp_send_reply_start(req, EVHTP_RES_OK); | |||
@@ -967,7 +967,7 @@ | |||
/* Block any new request from this connection before finish | |||
* handling this request. | |||
*/ | |||
- evhtp_request_pause (req); | |||
+ bufferevent_disable(bev, EV_READ); | |||
/* Kick start data transfer by sending out http headers. */ | |||
evhtp_send_reply_start(req, EVHTP_RES_PARTIAL); | |||
@@ -1032,7 +1032,7 @@ | |||
/* Block any new request from this connection before finish | |||
* handling this request. | |||
*/ | |||
- evhtp_request_pause (req); | |||
+ bufferevent_disable(bev, EV_READ); | |||
/* Kick start data transfer by sending out http headers. */ | |||
evhtp_send_reply_start(req, EVHTP_RES_OK); | |||
@@ -1365,7 +1365,7 @@ | |||
/* Block any new request from this connection before finish | |||
* handling this request. | |||
*/ | |||
- evhtp_request_pause (req); | |||
+ bufferevent_disable(bev, EV_READ); | |||
/* Kick start data transfer by sending out http headers. */ | |||
evhtp_send_reply_start(req, EVHTP_RES_OK); | |||
Index: seafile-server/server/upload-file.c | |||
=================================================================== | |||
--- seafile-server.orig/server/upload-file.c 2018-02-01 12:23:53.209308343 +0100 | |||
+++ seafile-server/server/upload-file.c 2018-02-01 12:25:14.542400155 +0100 | |||
@@ -2054,6 +2054,7 @@ | |||
if (res != EVHTP_RES_OK) { | |||
/* Don't receive any data before the connection is closed. */ | |||
//evhtp_request_pause (req); | |||
+ // or for later evhtp bufferevent_disable(evhtp_request_get_bev(req), EV_READ); | |||
/* Set keepalive to 0. This will cause evhtp to close the | |||
* connection after sending the reply. | |||
@@ -2271,6 +2272,7 @@ | |||
err: | |||
/* Don't receive any data before the connection is closed. */ | |||
//evhtp_request_pause (req); | |||
+ // or for later evhtp bufferevent_disable(evhtp_request_get_bev(req), EV_READ); | |||
/* Set keepalive to 0. This will cause evhtp to close the | |||
* connection after sending the reply. |
@ -0,0 +1,85 @@ | |||
Author: Alexandre Rossi <alexandre.rossi@gmail.com> | |||
Description: Take into account libevhtp API changes | |||
Forwarded: no | |||
Index: seafile-server/server/upload-file.c | |||
=================================================================== | |||
--- seafile-server.orig/server/upload-file.c 2018-02-01 12:25:52.666911934 +0100 | |||
+++ seafile-server/server/upload-file.c 2018-02-01 12:27:37.812323399 +0100 | |||
@@ -2059,7 +2059,7 @@ | |||
/* Set keepalive to 0. This will cause evhtp to close the | |||
* connection after sending the reply. | |||
*/ | |||
- req->keepalive = 0; | |||
+ req->flags &= ~EVHTP_REQ_FLAG_KEEPALIVE; | |||
fsm->state = RECV_ERROR; | |||
} | |||
@@ -2260,8 +2260,8 @@ | |||
} | |||
/* 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, upload_read_cb, fsm); | |||
+ evhtp_request_set_hook (req, evhtp_hook_on_request_fini, upload_finish_cb, fsm); | |||
/* Set arg for upload_cb or update_cb. */ | |||
req->cbarg = fsm; | |||
@@ -2277,7 +2277,7 @@ | |||
/* Set keepalive to 0. This will cause evhtp to close the | |||
* connection after sending the reply. | |||
*/ | |||
- req->keepalive = 0; | |||
+ req->flags &= ~EVHTP_REQ_FLAG_KEEPALIVE; | |||
send_error_reply (req, EVHTP_RES_BADREQ, err_msg); | |||
g_free (repo_id); | |||
@@ -2346,38 +2346,32 @@ | |||
cb = evhtp_set_regex_cb (htp, "^/upload/.*", upload_cb, NULL); | |||
/* upload_headers_cb() will be called after evhtp parsed all http headers. */ | |||
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); | |||
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, upload_headers_cb, NULL); | |||
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, 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, 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); | |||
- | |||
- /* 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); */ | |||
+ evhtp_callback_set_hook(cb, 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, upload_headers_cb, NULL); | |||
cb = evhtp_set_regex_cb (htp, "^/update/.*", update_cb, NULL); | |||
- evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, upload_headers_cb, NULL); | |||
+ evhtp_callback_set_hook(cb, evhtp_hook_on_headers, 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, 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); | |||
- | |||
- /* 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); */ | |||
+ evhtp_callback_set_hook(cb, 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, upload_headers_cb, NULL); | |||
evhtp_set_regex_cb (htp, "^/upload_progress.*", upload_progress_cb, NULL); | |||