]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ssl/helper.cc
7 #include "ssl/Config.h"
8 #include "ssl/helper.h"
12 Ssl::Helper
* Ssl::Helper::GetInstance()
14 static Ssl::Helper sslHelper
;
22 Ssl::Helper::~Helper()
27 void Ssl::Helper::Init()
29 assert(ssl_crtd
== NULL
);
31 bool useSslBump
= false;
32 for (http_port_list
*s
= ::Config
.Sockaddr
.http
; s
; s
= s
->next
) {
42 ssl_crtd
= new helper("ssl_crtd");
43 ssl_crtd
->childs
.updateLimits(Ssl::TheConfig
.ssl_crtdChildren
);
44 ssl_crtd
->ipc_type
= IPC_STREAM
;
45 // The crtd messages may contain the eol ('\n') character. We are
46 // going to use the '\1' char as the end-of-message mark.
48 assert(ssl_crtd
->cmdline
== NULL
);
50 char *tmp
= xstrdup(Ssl::TheConfig
.ssl_crtd
);
51 char *tmp_begin
= tmp
;
53 bool db_path_was_found
= false;
54 bool block_size_was_found
= false;
55 char buffer
[20] = "2048";
56 while ((token
= strwordtok(NULL
, &tmp
))) {
57 wordlistAdd(&ssl_crtd
->cmdline
, token
);
58 if (!strcmp(token
, "-b"))
59 block_size_was_found
= true;
60 if (!strcmp(token
, "-s")) {
61 db_path_was_found
= true;
62 } else if (db_path_was_found
) {
63 db_path_was_found
= false;
64 int fs_block_size
= 0;
65 storeDirGetBlkSize(token
, &fs_block_size
);
66 snprintf(buffer
, sizeof(buffer
), "%i", fs_block_size
);
69 if (!block_size_was_found
) {
70 wordlistAdd(&ssl_crtd
->cmdline
, "-b");
71 wordlistAdd(&ssl_crtd
->cmdline
, buffer
);
75 helperOpenServers(ssl_crtd
);
78 void Ssl::Helper::Shutdown()
82 helperShutdown(ssl_crtd
);
83 wordlistDestroy(&ssl_crtd
->cmdline
);
88 void Ssl::Helper::sslSubmit(CrtdMessage
const & message
, HLPCB
* callback
, void * data
)
90 static time_t first_warn
= 0;
93 if (ssl_crtd
->stats
.queue_size
>= (int)(ssl_crtd
->childs
.n_running
* 2)) {
95 first_warn
= squid_curtime
;
96 if (squid_curtime
- first_warn
> 3 * 60)
97 fatal("SSL servers not responding for 3 minutes");
98 debugs(34, 1, HERE
<< "Queue overload, rejecting");
99 callback(data
, (char *)"error 45 Temporary network problem, please retry later");
104 std::string msg
= message
.compose();
106 helperSubmit(ssl_crtd
, msg
.c_str(), callback
, data
);