From 55f683e5fecabe80d0d2478cd54422fda7eb0341 Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Sat, 2 Dec 2000 15:48:59 +0000
Subject: [PATCH] correction in TFile::Open() in case of TNetFile and PROOF.

git-svn-id: http://root.cern.ch/svn/root/trunk@1103 27541ba8-7e3a-0410-8455-c3a389f83636
---
 base/src/TFile.cxx | 15 ++++++++++++---
 io/src/TFile.cxx   | 15 ++++++++++++---
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/base/src/TFile.cxx b/base/src/TFile.cxx
index a0f0622998b..040fea6c684 100644
--- a/base/src/TFile.cxx
+++ b/base/src/TFile.cxx
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TFile.cxx,v 1.12 2000/11/27 10:44:46 rdm Exp $
+// @(#)root/base:$Name:  $:$Id: TFile.cxx,v 1.13 2000/11/30 08:34:12 brun Exp $
 // Author: Rene Brun   28/11/94
 
 /*************************************************************************
@@ -1437,18 +1437,27 @@ TFile *TFile::Open(const char *name, Option_t *option, const char *ftitle, Int_t
    // TRFIOFile and with "file:" or the default a local TFile. However,
    // before opening a file via TNetFile a check is made to see if the URL
    // specifies a local file. If that is the case the file will be opened
-   // via a normal TFile. To force the opening of a local file via a
+   // via a normal TFile (+). To force the opening of a local file via a
    // TNetFile use either TNetFile directly or specify as host "localhost".
    // For the meaning of the options and other arguments see the constructors
    // of the individual file classes.
 
+   // (+) Unless PROOF is active and this is not a PROOF master server, i.e.
+   // this is a PROOF client, in that case open as a TNetFile so the TNetFile
+   // gets propagated to PROOF to be opened there too (a TFile open does
+   // get propagated to PROOF since it makes not much sense trying to open
+   // a local file on a remote machine).
+
    TFile *f = 0;
 
    if (!strncmp(name, "root:", 5) || !strncmp(name, "roots:", 6)) {
       TUrl url(name);
       TInetAddress a(gSystem->GetHostByName(url.GetHost()));
       TInetAddress b(gSystem->GetHostByName(gSystem->HostName()));
-      if (strcmp(a.GetHostName(), b.GetHostName()))
+      if (strcmp(a.GetHostName(), b.GetHostName()) ||
+          (TClassTable::GetDict("TProof") &&
+           gROOT->ProcessLineFast("TProof::IsActive()") &&
+           !gROOT->ProcessLineFast("TProof::This()->IsMaster()")))
          f = new TNetFile(name, option, ftitle, compress);
       else {
          const char *fname = url.GetFile();
diff --git a/io/src/TFile.cxx b/io/src/TFile.cxx
index a0f0622998b..040fea6c684 100644
--- a/io/src/TFile.cxx
+++ b/io/src/TFile.cxx
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TFile.cxx,v 1.12 2000/11/27 10:44:46 rdm Exp $
+// @(#)root/base:$Name:  $:$Id: TFile.cxx,v 1.13 2000/11/30 08:34:12 brun Exp $
 // Author: Rene Brun   28/11/94
 
 /*************************************************************************
@@ -1437,18 +1437,27 @@ TFile *TFile::Open(const char *name, Option_t *option, const char *ftitle, Int_t
    // TRFIOFile and with "file:" or the default a local TFile. However,
    // before opening a file via TNetFile a check is made to see if the URL
    // specifies a local file. If that is the case the file will be opened
-   // via a normal TFile. To force the opening of a local file via a
+   // via a normal TFile (+). To force the opening of a local file via a
    // TNetFile use either TNetFile directly or specify as host "localhost".
    // For the meaning of the options and other arguments see the constructors
    // of the individual file classes.
 
+   // (+) Unless PROOF is active and this is not a PROOF master server, i.e.
+   // this is a PROOF client, in that case open as a TNetFile so the TNetFile
+   // gets propagated to PROOF to be opened there too (a TFile open does
+   // get propagated to PROOF since it makes not much sense trying to open
+   // a local file on a remote machine).
+
    TFile *f = 0;
 
    if (!strncmp(name, "root:", 5) || !strncmp(name, "roots:", 6)) {
       TUrl url(name);
       TInetAddress a(gSystem->GetHostByName(url.GetHost()));
       TInetAddress b(gSystem->GetHostByName(gSystem->HostName()));
-      if (strcmp(a.GetHostName(), b.GetHostName()))
+      if (strcmp(a.GetHostName(), b.GetHostName()) ||
+          (TClassTable::GetDict("TProof") &&
+           gROOT->ProcessLineFast("TProof::IsActive()") &&
+           !gROOT->ProcessLineFast("TProof::This()->IsMaster()")))
          f = new TNetFile(name, option, ftitle, compress);
       else {
          const char *fname = url.GetFile();
-- 
GitLab