All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/conga_ssl SSLClient.cpp conga_ssl_l ...
Date: 1 Jun 2007 23:09:57 -0000	[thread overview]
Message-ID: <20070601230957.12129.qmail@sourceware.org> (raw)

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 *



                 reply	other threads:[~2007-06-01 23:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070601230957.12129.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.