TXUnixSocket.cxx

Go to the documentation of this file.
00001 // @(#)root/proofx:$Id: TXUnixSocket.cxx 24719 2008-07-09 07:07:25Z ganis $
00002 // Author: Gerardo Ganis  12/12/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TXUnixSocket                                                         //
00015 //                                                                      //
00016 // Implementation of TXSocket using PF_UNIX sockets.                    //
00017 // Used for the internal connection between coordinator and proofserv.  //
00018 //                                                                      //
00019 //////////////////////////////////////////////////////////////////////////
00020 #ifdef OLDXRDOUC
00021 #  include "XrdSysToOuc.h"
00022 #  include "XrdOuc/XrdOucPthread.hh"
00023 #else
00024 #  include "XrdSys/XrdSysPthread.hh"
00025 #endif
00026 
00027 #include "TXUnixSocket.h"
00028 #include "XrdProofPhyConn.h"
00029 
00030 ClassImp(TXUnixSocket)
00031 
00032 //_____________________________________________________________________________
00033 TXUnixSocket::TXUnixSocket(const char *url,
00034                            Int_t psid, Char_t capver, TXHandler *handler)
00035              : TXSocket(0,'i',psid,capver,0,-1,handler)
00036 {
00037    // Constructor
00038 
00039    // Initialization
00040    if (url) {
00041 
00042       // Create connection
00043       fConn = new XrdProofPhyConn(url, psid, capver, this);
00044       if (!(fConn->IsValid())) {
00045          Error("TXUnixSocket", "severe error occurred while opening a connection"
00046                                " to server [%s]", fUrl.Data());
00047          return;
00048       }
00049 
00050       // Fill some info
00051       fUser = fConn->fUser.c_str();
00052       fHost = fConn->fHost.c_str();
00053       fPort = fConn->fPort;
00054       fXrdProofdVersion = fConn->fRemoteProtocol;
00055       fRemoteProtocol = fConn->fRemoteProtocol;
00056 
00057       // Save also updated url
00058       TSocket::fUrl = fConn->fUrl.GetUrl().c_str();
00059 
00060       // This is needed for the reader thread to signal an interrupt
00061       fPid = gSystem->GetPid();
00062    }
00063 }
00064 
00065 //______________________________________________________________________________
00066 Int_t TXUnixSocket::Reconnect()
00067 {
00068    // Try reconnection after failure
00069 
00070    if (gDebug > 0) {
00071       Info("Reconnect", "%p: %p: %d: trying to reconnect on %s", this,
00072                         fConn, (fConn ? fConn->IsValid() : 0), fUrl.Data());
00073    }
00074 
00075    if (fXrdProofdVersion < 1005) {
00076       Info("Reconnect","%p: server does not support reconnections (protocol: %d < 1005)",
00077                        this, fXrdProofdVersion);
00078       return -1;
00079    }
00080 
00081 
00082    if (fConn && !fConn->IsValid()) {
00083 
00084       // Block any other attempt to use this connection
00085       XrdSysMutexHelper l(fConn->fMutex);
00086 
00087       fConn->Close();
00088       int maxtry, timewait;
00089       XrdProofConn::GetRetryParam(maxtry, timewait);
00090       XrdProofConn::SetRetryParam(300, 1);
00091       fConn->Connect();
00092       XrdProofConn::SetRetryParam();
00093    }
00094 
00095    if (gDebug > 0) {
00096       Info("Reconnect", "%p: %p: attempt %s", this, fConn,
00097                         ((fConn && fConn->IsValid()) ? "succeeded!" : "failed"));
00098    }
00099 
00100    // Done
00101    return ((fConn && fConn->IsValid()) ? 0 : -1);
00102 }

Generated on Tue Jul 5 14:52:28 2011 for ROOT_528-00b_version by  doxygen 1.5.1