[pve-devel] r5442 - pve-common/trunk/data/PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jan 26 12:25:49 CET 2011


Author: dietmar
Date: 2011-01-26 12:25:49 +0100 (Wed, 26 Jan 2011)
New Revision: 5442

Modified:
   pve-common/trunk/data/PVE/RPCEnvironment.pm
Log:
correctly log errors


Modified: pve-common/trunk/data/PVE/RPCEnvironment.pm
===================================================================
--- pve-common/trunk/data/PVE/RPCEnvironment.pm	2011-01-26 09:34:14 UTC (rev 5441)
+++ pve-common/trunk/data/PVE/RPCEnvironment.pm	2011-01-26 11:25:49 UTC (rev 5442)
@@ -5,6 +5,7 @@
 use POSIX ":sys_wait_h";
 use IO::File;
 use Fcntl qw(:flock);
+use PVE::SafeSyslog;
 use PVE::INotify;
 use PVE::ProcFSTools;
 
@@ -276,8 +277,8 @@
 
 	if (!open (STDERR, ">&1")) {
 	    POSIX::_exit (1); 
-	      kill ('KILL', $$); 
-	  }
+	    kill ('KILL', $$); 
+	}
 	
 	STDERR->autoflush (1);
 
@@ -292,11 +293,15 @@
 	POSIX::write ($psync[1], $upid, length ($upid));
 	POSIX::close ($psync[1]);
 
-	&$function ($upid);
+	eval { &$function ($upid); };
+	my $err = $@ || "this code should not be reached";
+	my $msg = "worker function failed: $err";
+	syslog('err', $msg);
+	print STDERR "$msg\n";
+	POSIX::_exit (1); 
+	kill ('KILL', $$); 
+   }
 
-	die "should not be reached";
-    }
-
     POSIX::close ($psync[1]);
 
     # sync with child (wait until child starts)




More information about the pve-devel mailing list