From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 1 Jun 2007 23:09:57 -0000 Subject: [Cluster-devel] conga/luci/conga_ssl SSLClient.cpp conga_ssl_l ... Message-ID: <20070601230957.12129.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 or ...., 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 >::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 >::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) == ""), sizeof("/>") - 1) == "/>") || + ret.substr(start - sizeof(""), sizeof("") - 1) == "") + { + 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 *