[Cluster-devel] conga/ricci common/File.cpp common/Socket.cpp ...

rmccabe at sourceware.org rmccabe at sourceware.org
Fri Aug 24 22:05:15 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2007-08-24 22:05:14

Modified files:
	ricci/common   : File.cpp Socket.cpp utils.cpp 
	ricci/modules/storage: SwapFS.cpp System.cpp 

Log message:
	- Better error messages
	- Minor cleanups

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/File.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Socket.cpp.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/utils.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/SwapFS.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/System.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5

--- conga/ricci/common/File.cpp	2006/12/12 13:11:50	1.3
+++ conga/ricci/common/File.cpp	2007/08/24 22:05:13	1.4
@@ -144,7 +144,7 @@
   MutexLocker l(*_mutex);
   
   long len = size();
-  auto_ptr<char> buff(new char[len]);
+  const auto_ptr<char> buff(new char[len]);
   try {
     ((fstream*) _pimpl->fs)->seekg(0, ios::beg);
     check_failed();
@@ -206,7 +206,7 @@
 {
   MutexLocker l(*_mutex);
   if (::unlink(_path.c_str()))
-    throw String("unlink failed");
+    throw String("unlink failed: " + String(strerror(errno)));
 }
 
 File::operator const String () const
--- conga/ricci/common/Socket.cpp	2007/03/23 17:25:12	1.6
+++ conga/ricci/common/Socket.cpp	2007/08/24 22:05:14	1.7
@@ -115,7 +115,7 @@
     throw String("socket not valid");
   int flags = fcntl(_sock, F_GETFL);
   if (flags == -1)
-    throw String("fcntl() failed");
+    throw String("fcntl(F_GETFL): " + String(strerror(errno)));
   return flags & O_NONBLOCK;
 }
 
@@ -126,28 +126,26 @@
     throw String("socket not valid");
   int old_flags = fcntl(_sock, F_GETFL);
   if (old_flags == -1)
-    throw String("fcntl() failed");
+    throw String("fcntl(F_GETFL): " + String(strerror(errno)));
   int new_flags;
   if (mode)
     new_flags = old_flags | O_NONBLOCK;
   else
     new_flags = old_flags & ~O_NONBLOCK;
   if (fcntl(_sock, F_SETFL, new_flags))
-    throw String("fcntl() failed");
+    throw String("fcntl(F_SETFL): " + String(strerror(errno)));
   return old_flags & O_NONBLOCK;
 }
 
 void
-Socket::poll(bool& read, 
-	     bool& write, 
-	     int timeout)
+Socket::poll(bool& read, bool& write, int timeout)
 {
   if (!valid())
     throw String("socket not valid");
   
   poll_fd poll_data;
   poll_data.fd = _sock;
-  poll_data.events = (read?POLLIN:0) | (write?POLLOUT:0);
+  poll_data.events = (read ? POLLIN : 0) | (write ? POLLOUT : 0);
   
   read = write = false;
   int beg = time_mil();
@@ -169,7 +167,7 @@
       if (errno == EINTR)
 	continue;
       else
-	throw String("poll() error");
+	throw String("poll() error: " + String(strerror(errno)));
     } else {
       if (poll_data.revents & POLLIN)
 	read = true;
--- conga/ricci/common/utils.cpp	2006/10/25 18:47:16	1.8
+++ conga/ricci/common/utils.cpp	2007/08/24 22:05:14	1.9
@@ -241,7 +241,7 @@
 utils::to_string(long long value)
 {
   char tmp[100];
-  sprintf(tmp, "%Ld", value);
+  sprintf(tmp, "%lld", value);
   return tmp;
 }
 String 
@@ -289,6 +289,7 @@
     return c.exec_ret;
   }
 }
+
 void
 utils::clear_cache()
 {
--- conga/ricci/modules/storage/SwapFS.cpp	2006/10/06 03:10:13	1.8
+++ conga/ricci/modules/storage/SwapFS.cpp	2007/08/24 22:05:14	1.9
@@ -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
@@ -154,7 +154,7 @@
   if (utils::execute("/sbin/mkswap", args, out, err, status))
     throw command_not_found_error_msg("mkswap");
   if (status != 0)
-    throw String("mkswap failed");
+    throw String("mkswap failed: ") + err;
   
   if (swapon) {
     args.clear();
@@ -162,7 +162,7 @@
     if (utils::execute("/sbin/swapon", args, out, err, status))
       throw command_not_found_error_msg("swapon");
     if (status != 0)
-      throw String("swapon failed");
+      throw String("swapon failed: ") + err;
   }
   
   if (fstab) {
--- conga/ricci/modules/storage/System.cpp	2006/10/06 03:10:13	1.4
+++ conga/ricci/modules/storage/System.cpp	2007/08/24 22:05:14	1.5
@@ -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
@@ -47,7 +47,7 @@
   Mapper(MAPPER_SYS_TYPE, id)
 {
   if (_mapper_id != SYS_PREFIX)
-    throw String("invalid mapper_id");
+    throw String("invalid mapper_id: " + _mapper_id);
   
   // parse blockdev
   vector<String> args;
@@ -58,7 +58,7 @@
   if (utils::execute("/sbin/blockdev", args, out, err, status))
     throw command_not_found_error_msg("blockdev");
   if (status)
-    throw String("blockdev failed");
+    throw String("blockdev failed: ") + err;
   
   vector<String> lines = utils::split(out, "\n");
   for (vector<String>::iterator iter = lines.begin();




More information about the Cluster-devel mailing list