[Cluster-devel] conga/luci/conga_ssl SSLClient.cpp conga_ssl_l ...
rmccabe at sourceware.org
rmccabe at sourceware.org
Fri Jun 1 23:09:57 UTC 2007
CVSROOT: /cvs/cluster
Module name: conga
Branch: EXPERIMENTAL
Changes by: rmccabe at sourceware.org 2007-06-01 23:09:57
Modified files:
luci/conga_ssl : SSLClient.cpp conga_ssl_lib.cpp
Log message:
performance fixes, pass 1:
- This code was using 1k buffers to read network data, and it would try to parse
the data received so far each time throgh the read loop as XML.
- Increase read buffers to 4k, and don't try to parse them as XML. Since we know
what the data coming in will look like (either <?xml ...><ricci ... /> or
<ricci>....</ricci>, scan the input for that instead.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/conga_ssl/SSLClient.cpp.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.3&r2=1.3.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/conga_ssl/conga_ssl_lib.cpp.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.3&r2=1.3.2.1
--- conga/luci/conga_ssl/SSLClient.cpp 2007/03/22 03:42:38 1.3
+++ conga/luci/conga_ssl/SSLClient.cpp 2007/06/01 23:09:57 1.3.2.1
@@ -1,5 +1,5 @@
/*
- Copyright Red Hat, Inc. 2005
+ Copyright Red Hat, Inc. 2005-2007
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -284,7 +284,7 @@
if (!_connected)
throw String("cannot receive, yet: SSL connection not connected");
- char buff[1024];
+ char buff[4096];
unsigned int beg = time_mil();
while (time_mil() < beg + timeout) {
--- conga/luci/conga_ssl/conga_ssl_lib.cpp 2007/03/21 20:12:57 1.3
+++ conga/luci/conga_ssl/conga_ssl_lib.cpp 2007/06/01 23:09:57 1.3.2.1
@@ -1,5 +1,5 @@
/*
- Copyright Red Hat, Inc. 2006
+ Copyright Red Hat, Inc. 2006-2007
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -215,46 +215,61 @@
PyObject *
conga_ssl_lib_recv(PyObject *self, PyObject *args)
{
- int id, timeout;
- if (!PyArg_ParseTuple(args, "ii", &id, &timeout))
- return NULL;
- if (timeout < 0) {
- PyErr_SetString(PyExc_ValueError, "negative timeout");
- return NULL;
- }
+ int id, timeout;
+
+ if (!PyArg_ParseTuple(args, "ii", &id, &timeout))
+ return NULL;
+
+ if (timeout < 0) {
+ PyErr_SetString(PyExc_ValueError, "negative timeout");
+ return NULL;
+ }
- try {
- map<int, counting_auto_ptr<SSLClient> >::const_iterator iter =
- ssls.find(id);
- if (iter == ssls.end())
- throw String("SSL connection closed");
-
- String resp;
- {
- PythonThreadsAllower all;
- int beg = int(time_sec());
- String xml_in;
- while (true) {
- if (int(time_sec()) > beg + timeout)
- throw String("timeout");
- else
- xml_in += iter->second->recv(400);
try {
- parseXML(xml_in);
- resp = xml_in;
- break;
- } catch ( ... ) {}
- }
- }
+ map<int, counting_auto_ptr<SSLClient> >::const_iterator iter =
+ ssls.find(id);
+
+ if (iter == ssls.end())
+ throw String("SSL connection closed");
- PyObject* resp_p = Py_BuildValue("s", resp.c_str());
- return resp_p;
- } catch (String e) {
- PyErr_SetString(PyExc_Exception, e.c_str());
- } catch ( ... ) {
- PyErr_SetString(PyExc_Exception, "unknown");
- }
- return NULL;
+ String resp;
+ {
+ PythonThreadsAllower all;
+
+ int beg = int(time_sec());
+ String xml_in;
+ while (true) {
+ String ret;
+ if (int(time_sec()) > beg + timeout)
+ throw String("timeout");
+ else {
+ ret = iter->second->recv(400);
+ if (ret == "")
+ continue;
+ xml_in += ret;
+ }
+ int start = ret.length() - 1;
+ while (start > 0 && ret[start] == '\n' || ret[start] == '\r')
+ start--;
+ start += 2;
+ if ((ret.substr(0, 6) == "<?xml " && ret.substr(start - sizeof("/>"), sizeof("/>") - 1) == "/>") ||
+ ret.substr(start - sizeof("</ricci>"), sizeof("</ricci>") - 1) == "</ricci>")
+ {
+ resp = xml_in;
+ break;
+ }
+ }
+ }
+
+ PyObject* resp_p = Py_BuildValue("s", resp.c_str());
+ return resp_p;
+ } catch (String e) {
+ PyErr_SetString(PyExc_Exception, e.c_str());
+ } catch ( ... ) {
+ PyErr_SetString(PyExc_Exception, "unknown");
+ }
+
+ return NULL;
}
PyObject *
More information about the Cluster-devel
mailing list