[complement-svn] SF.net SVN: complement:[1952] trunk/complement/explore/lib/mt
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2008-07-30 17:26:26
|
Revision: 1952 http://complement.svn.sourceforge.net/complement/?rev=1952&view=rev Author: complement Date: 2008-07-30 17:26:23 +0000 (Wed, 30 Jul 2008) Log Message: ----------- in uid implementation use system_error for detailed report about problem libxmt: revision 2.0.9. save errno instead of just fail flag; throw system error with errno---details about problem Revision Links: -------------- http://complement.svn.sourceforge.net/complement/?rev=2&view=rev Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/uid.cc Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2008-07-25 06:35:15 UTC (rev 1951) +++ trunk/complement/explore/lib/mt/ChangeLog 2008-07-30 17:26:23 UTC (rev 1952) @@ -1,3 +1,9 @@ +2008-07-30 Petr Ovtchenkov <pt...@is...> + + * uid.cc: use system_error for detailed report about problem; + + * libxmt: bump revision to 2.0.9. + 2008-07-25 Petr Ovtchenkov <pt...@is...> * system_error, system_error.cc: basic functionality Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2008-07-25 06:35:15 UTC (rev 1951) +++ trunk/complement/explore/lib/mt/Makefile.inc 2008-07-30 17:26:23 UTC (rev 1952) @@ -1,9 +1,9 @@ -# -*- Makefile -*- Time-stamp: <08/07/25 10:25:30 ptr> +# -*- Makefile -*- Time-stamp: <08/07/30 19:12:30 ptr> LIBNAME = xmt MAJOR = 2 MINOR = 0 -PATCH = 8 +PATCH = 9 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc callstack.cc system_error.cc thread.cc \ date_time.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/uid.cc =================================================================== --- trunk/complement/explore/lib/mt/uid.cc 2008-07-25 06:35:15 UTC (rev 1951) +++ trunk/complement/explore/lib/mt/uid.cc 2008-07-30 17:26:23 UTC (rev 1952) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/07 14:19:23 yeti> +// -*- C++ -*- Time-stamp: <08/07/30 19:12:12 ptr> /* * Copyright (c) 2006, 2008 @@ -16,6 +16,7 @@ #include <unistd.h> #include <fcntl.h> #include <stdexcept> +#include <mt/system_error> #include <iostream> @@ -62,21 +63,24 @@ static uuid_type _host_id; char _host_id_str[48]; // 37 really - bool fail; + int err; }; uuid_type __uid_init::_host_id; +static const char boot_id[] = "/proc/sys/kernel/random/boot_id"; +static const char uu_id[] = "/proc/sys/kernel/random/uuid"; + __uid_init::__uid_init() : - fail( false ) + err( 0 ) { - int fd = ::open( "/proc/sys/kernel/random/boot_id", O_RDONLY ); + int fd = ::open( boot_id, O_RDONLY ); if ( (fd < 0) || (::read( fd, _host_id_str, 36 ) != 36 )) { + err = errno; if ( fd >= 0 ) { ::close( fd ); } - fail = true; } else { _host_id_str[36] = '\0'; ::close( fd ); @@ -142,8 +146,8 @@ const char *hostid_str() throw (runtime_error) { static detail::__uid_init _uid; - if ( _uid.fail ) { - throw runtime_error( "can't read hostid" ); + if ( _uid.err != 0 ) { + throw system_error( _uid.err, get_posix_category(), detail::boot_id ); } return _uid._host_id_str; } @@ -158,12 +162,13 @@ { char buf[37]; - int fd = ::open( "/proc/sys/kernel/random/uuid", O_RDONLY ); + int fd = ::open( detail::uu_id, O_RDONLY ); if ( (fd < 0) || (::read( fd, buf, 37 ) != 37) ) { + system_error se( errno, get_posix_category(), string( "Can't generate UID; " ) + detail::uu_id ); if ( fd >= 0 ) { ::close( fd ); } - throw runtime_error( "Can't generate UID" ); + throw se; // return std::string(); } ::close( fd ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |