From: Jan Kupec Date: Fri, 23 Feb 2007 16:42:21 +0000 (+0000) Subject: Merged revisions 5092 via svnmerge from X-Git-Tag: 6.6.0~2579 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74a6b0899cae9c613d493c13cbfe771fbbb519a9;p=platform%2Fupstream%2Flibzypp.git Merged revisions 5092 via svnmerge from http://svn.suse.de/svn/zypp/branches/SuSE-Linux-10_2-Branch/libzypp ........ r5092 | jkupec | 2007-02-23 17:20:47 +0100 (Fri, 23 Feb 2007) | 2 lines adding soft,timeo=X nfs mount options by default (#235211) ........ --- diff --git a/package/libzypp.changes b/package/libzypp.changes index 5ca889b4d..0ffca30ca 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Feb 23 17:40:23 CET 2007 - jkupec@suse.cz + +- adding sotf,timeo=X nfs mount options by default (#235211) +- r5093 + ------------------------------------------------------------------- Fri Feb 23 14:16:19 CET 2007 - jkupec@suse.cz diff --git a/zypp/media/MediaNFS.cc b/zypp/media/MediaNFS.cc index 1a6c98fc8..b09559d92 100644 --- a/zypp/media/MediaNFS.cc +++ b/zypp/media/MediaNFS.cc @@ -11,6 +11,7 @@ */ #include +#include #include "zypp/base/Logger.h" #include "zypp/base/String.h" @@ -102,19 +103,41 @@ namespace zypp { { options="ro"; } - - // Add option "nolock", unless option "lock" or "unlock" is already set. - // This should prevent the mount command hanging when the portmapper isn't - // running. + vector optionList; str::split( options, std::back_inserter(optionList), "," ); vector::const_iterator it; + bool contains_lock = false, contains_soft = false, + contains_timeo = false, contains_hard = false; + for( it = optionList.begin(); it != optionList.end(); ++it ) { - if ( *it == "lock" || *it == "nolock" ) break; + if ( *it == "lock" || *it == "nolock" ) contains_lock = true; + else if ( *it == "soft") contains_soft = true; + else if ( *it == "hard") contains_hard = true; + else if ( it->find("timeo") != string::npos ) contains_timeo = true; } - if ( it == optionList.end() ) { - optionList.push_back( "nolock" ); - options = str::join( optionList, "," ); + + if ( !(contains_lock && contains_soft) ) { + // Add option "nolock", unless option "lock" or "unlock" is already set. + // This should prevent the mount command hanging when the portmapper isn't + // running. + if ( !contains_lock ) { + optionList.push_back( "nolock" ); + } + // Add options "soft,timeo=NFS_MOUNT_TIMEOUT", unless they are set + // already or "hard" option is explicitly specified. This prevent + // the mount command from hanging when the nfs server is not responding + // and file transactions from an unresponsive to throw an error after + // a short time instead of hanging forever + if ( !(contains_soft || contains_hard) ) { + optionList.push_back( "soft" ); + if ( !contains_timeo ) { + ostringstream s; + s << "timeo=" << NFS_MOUNT_TIMEOUT; + optionList.push_back( s.str() ); + } + } + options = str::join( optionList, "," ); } mount.mount(path,mountpoint,filesystem,options); diff --git a/zypp/media/MediaNFS.h b/zypp/media/MediaNFS.h index 09704138e..0893b6e7c 100644 --- a/zypp/media/MediaNFS.h +++ b/zypp/media/MediaNFS.h @@ -14,6 +14,11 @@ #include "zypp/media/MediaHandler.h" +/** + * Value of nfs mount minor timeout in tenths of a second. + */ +#define NFS_MOUNT_TIMEOUT 10 + namespace zypp { namespace media {