srv->rbuf[0] = '\0';
}
- if (hlp->return_full_reply) {
- debugs(84, 3, HERE << "Return entire buffer");
- helperReturnBuffer(0, srv, hlp, srv->rbuf, srv->rbuf + srv->roffset);
- } else {
- while ((t = strchr(srv->rbuf, '\n'))) {
- /* end of reply found */
- char *msg = srv->rbuf;
- int i = 0;
- debugs(84, 3, "helperHandleRead: end of reply found");
-
- if (t > srv->rbuf && t[-1] == '\r')
- t[-1] = '\0';
-
- *t++ = '\0';
-
- if (hlp->childs.concurrency) {
- i = strtol(msg, &msg, 10);
-
- while (*msg && xisspace(*msg))
- msg++;
- }
-
- helperReturnBuffer(i, srv, hlp, msg, t);
+ while ((t = strchr(srv->rbuf, hlp->eom))) {
+ /* end of reply found */
+ char *msg = srv->rbuf;
+ int i = 0;
+ debugs(84, 3, "helperHandleRead: end of reply found");
+
+ if (t > srv->rbuf && t[-1] == '\r' && hlp->eom == '\n')
+ t[-1] = '\0';
+
+ *t++ = '\0';
+
+ if (hlp->childs.concurrency) {
+ i = strtol(msg, &msg, 10);
+
+ while (*msg && xisspace(*msg))
+ msg++;
}
+
+ helperReturnBuffer(i, srv, hlp, msg, t);
}
if (srv->rfd != -1)
srv->roffset = 0;
}
- if ((t = strchr(srv->rbuf, '\n'))) {
+ if ((t = strchr(srv->rbuf, hlp->eom))) {
/* end of reply found */
int called = 1;
debugs(84, 3, "helperStatefulHandleRead: end of reply found");
- if (t > srv->rbuf && t[-1] == '\r')
+ if (t > srv->rbuf && t[-1] == '\r' && hlp->eom == '\n')
t[-1] = '\0';
*t = '\0';
class helper
{
public:
- inline helper(const char *name) : cmdline(NULL), id_name(name) {};
+ inline helper(const char *name) : cmdline(NULL), id_name(name), eom('\n') {}
~helper();
public:
Ip::Address addr;
time_t last_queue_warn;
time_t last_restart;
+ char eom; ///< The char which marks the end of (response) message, normally '\n'
struct _stats {
int requests;
int queue_size;
int avg_svc_time;
} stats;
- /// True if callback expects the whole helper output, as a c-string.
- bool return_full_reply;
private:
CBDATA_CLASS2(helper);
ssl_crtd = new helper("ssl_crtd");
ssl_crtd->childs = Ssl::TheConfig.ssl_crtdChildren;
ssl_crtd->ipc_type = IPC_STREAM;
+ // The crtd messages may contain the eol ('\n') character. We are
+ // going to use the '\1' char as the end-of-message mark.
+ ssl_crtd->eom = '\1';
assert(ssl_crtd->cmdline == NULL);
{
char *tmp = xstrdup(Ssl::TheConfig.ssl_crtd);
}
safe_free(tmp_begin);
}
- ssl_crtd->return_full_reply = true;
helperOpenServers(ssl_crtd);
}
}
first_warn = 0;
- helperSubmit(ssl_crtd, message.compose().c_str(), callback, data);
+ std::string msg = message.compose();
+ msg += '\n';
+ helperSubmit(ssl_crtd, msg.c_str(), callback, data);
}