[Cluster-devel] conga/ricci/ricci RicciWorker.cpp

[email protected] <[email protected]>
Newsgroups com.redhat.cluster-devel
Message-ID <[email protected]>
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);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.