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/ricci/ricci RicciWorker.cpp
Date: 24 Jan 2008 06:14:38 -0000	[thread overview]
Message-ID: <20080124061438.15037.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2008-01-24 06:14:37

Modified files:
	ricci/ricci    : RicciWorker.cpp 

Log message:
	Fix stupid bug that caused reading batch jobs with XML longer than 4k to fail.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RicciWorker.cpp.diff?cvsroot=cluster&r1=1.16&r2=1.17

--- conga/ricci/ricci/RicciWorker.cpp	2008/01/02 20:47:38	1.16
+++ conga/ricci/ricci/RicciWorker.cpp	2008/01/24 06:14:37	1.17
@@ -258,6 +258,7 @@
 	_path(path)
 {
 	QueueLocker lock;
+	struct stat st;
 
 	_fd = open(_path.c_str(), O_RDONLY);
 	if (_fd == -1)
@@ -276,18 +277,24 @@
 			}
 		}
 
+		if (fstat(_fd, &st) != 0)
+			throw String("Unable to stat file: ") + String(strerror(errno));
+
 		// read file
 		String xml_str;
-		char buff[4096];
-		ssize_t res;
 
-		res = read_restart(_fd, buff, sizeof(buff));
-		if (res <= 0) {
-			throw String("error reading batch file: ")
+		while ((off_t) xml_str.size() < st.st_size) {
+			char buff[4096];
+			ssize_t res;
+
+			res = read_restart(_fd, buff, sizeof(buff));
+			if (res <= 0) {
+				throw String("error reading batch file: ")
 					+ String(strerror(-res));
+			}
+			xml_str.append(buff, res);
+			memset(buff, 0, sizeof(buff));
 		}
-		xml_str.append(buff, res);
-		memset(buff, 0, sizeof(buff));
 
 		// _xml
 		_xml = parseXML(xml_str);



                 reply	other threads:[~2008-01-24  6:14 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=20080124061438.15037.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.