00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00038
00039
00040 if (url) {
00041
00042
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
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
00058 TSocket::fUrl = fConn->fUrl.GetUrl().c_str();
00059
00060
00061 fPid = gSystem->GetPid();
00062 }
00063 }
00064
00065
00066 Int_t TXUnixSocket::Reconnect()
00067 {
00068
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
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
00101 return ((fConn && fConn->IsValid()) ? 0 : -1);
00102 }