Skip to content

Commit f02805c

Browse files
bbockelmmatyasselmeci
authored andcommitted
[#35] Make HTTP's maximum open delay configurable
By default, the bridge will retry operations internally until the maximum delay is hit and then return an error. By default, the maximum delay is 3600 seconds; this is well beyond the timeouts of a typical HTTP client. This makes the delay configurable for HTTP with the following: ``` http.maxdelay <seconds> ``` as in ``` http.maxdelay 10 ``` It also tunes down the default delay to 30s. Note: the response time can still be greater than 30s; this just limits how long the bridge will process "wait" responses for.
1 parent 2006eca commit f02805c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/XrdHttp/XrdHttpProtocol.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Xrd/XrdBuffer.hh"
2727
#include "Xrd/XrdLink.hh"
2828
#include "XProtocol/XProtocol.hh"
29+
#include "XrdOuc/XrdOuca2x.hh"
2930
#include "XrdOuc/XrdOucStream.hh"
3031
#include "XrdOuc/XrdOucEnv.hh"
3132
#include "XrdOuc/XrdOucGMap.hh"
@@ -45,6 +46,7 @@
4546
#include "XrdOuc/XrdOucUtils.hh"
4647
#include "XrdOuc/XrdOucPrivateUtils.hh"
4748

49+
#include <charconv>
4850
#include <openssl/err.h>
4951
#include <openssl/ssl.h>
5052
#include <vector>
@@ -84,6 +86,7 @@ char *XrdHttpProtocol::listredir = 0;
8486
bool XrdHttpProtocol::listdeny = false;
8587
bool XrdHttpProtocol::embeddedstatic = true;
8688
char *XrdHttpProtocol::staticredir = 0;
89+
int XrdHttpProtocol::m_maxdelay = -1;
8790
XrdOucHash<XrdHttpProtocol::StaticPreloadInfo> *XrdHttpProtocol::staticpreload = 0;
8891

8992
kXR_int32 XrdHttpProtocol::myRole = kXR_isManager;
@@ -903,6 +906,7 @@ int XrdHttpProtocol::Process(XrdLink *lp) // We ignore the argument here
903906
TRACEI(REQ, " Authorization failed.");
904907
return -1;
905908
}
909+
if (m_maxdelay > 0) Bridge->SetWait(m_maxdelay, false);
906910

907911
// Let the bridge process the login, and then reinvoke us
908912
DoingLogin = true;
@@ -1088,6 +1092,7 @@ int XrdHttpProtocol::Config(const char *ConfigFN, XrdOucEnv *myEnv) {
10881092
else if TS_Xeq("tlsreuse", xtlsreuse);
10891093
else if TS_Xeq("auth", xauth);
10901094
else if TS_Xeq("tlsclientauth", xtlsclientauth);
1095+
else if TS_Xeq("maxdelay", xmaxdelay);
10911096
else {
10921097
eDest.Say("Config warning: ignoring unknown directive '", var, "'.");
10931098
Config.Echo();
@@ -3012,6 +3017,19 @@ int XrdHttpProtocol::xauth(XrdOucStream &Config) {
30123017
return 0;
30133018
}
30143019

3020+
int XrdHttpProtocol::xmaxdelay(XrdOucStream &Config) {
3021+
char *val = Config.GetWord();
3022+
if(val) {
3023+
int maxdelay;
3024+
if (XrdOuca2x::a2tm(eDest, "http.maxdelay", val, &maxdelay, 1)) return 1;
3025+
m_maxdelay = maxdelay;
3026+
} else {
3027+
eDest.Emsg("Config", "http.maxdelay requires an argument in seconds (default is 30). Example: http.maxdelay 30");
3028+
return 1;
3029+
}
3030+
return 0;
3031+
}
3032+
30153033
/******************************************************************************/
30163034
/* x t r a c e */
30173035
/******************************************************************************/

src/XrdHttp/XrdHttpProtocol.hh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ private:
226226
static int xtlsreuse(XrdOucStream &Config);
227227
static int xauth(XrdOucStream &Config);
228228
static int xtlsclientauth(XrdOucStream &Config);
229-
229+
static int xmaxdelay(XrdOucStream &Config);
230+
230231
static bool isRequiredXtractor; // If true treat secxtractor errors as fatal
231232
static XrdHttpSecXtractor *secxtractor;
232233

@@ -427,6 +428,10 @@ protected:
427428
// Url to redirect to in the case a /static is requested
428429
static char *staticredir;
429430

431+
// Maximum amount of time an operation on the bridge can be
432+
// delayed
433+
static int m_maxdelay;
434+
430435
// Hash that keeps preloaded files
431436
struct StaticPreloadInfo {
432437
char *data;

0 commit comments

Comments
 (0)