XrdCmsSupervisor.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                   X r d C m s S u p e r v i s o r . c c                    */
00004 /*                                                                            */
00005 /*                                                                            */
00006 /* (c) 2007 by the Board of Trustees of the Leland Stanford, Jr., University  */
00007 /*                            All Rights Reserved                             */
00008 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00009 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00010 /******************************************************************************/
00011 
00012 //       $Id: XrdCmsSupervisor.cc 30949 2009-11-02 16:37:58Z ganis $
00013 
00014 const char *XrdCmsSupervisorCVSID = "$Id: XrdCmsSupervisor.cc 30949 2009-11-02 16:37:58Z ganis $";
00015 
00016 #include "Xrd/XrdInet.hh"
00017 #include "Xrd/XrdLink.hh"
00018 
00019 #include "XrdCms/XrdCmsConfig.hh"
00020 #include "XrdCms/XrdCmsProtocol.hh"
00021 #include "XrdCms/XrdCmsSupervisor.hh"
00022 #include "XrdCms/XrdCmsTrace.hh"
00023 
00024 #include "XrdNet/XrdNetSocket.hh"
00025 
00026 #include "XrdSys/XrdSysError.hh"
00027 
00028 using namespace XrdCms;
00029 
00030 /******************************************************************************/
00031 /*                               G l o b a l s                                */
00032 /******************************************************************************/
00033 
00034 int      XrdCmsSupervisor::superOK = 0;
00035 
00036 XrdInet *XrdCmsSupervisor::NetTCPr = 0;
00037 
00038 /******************************************************************************/
00039 /*                                  I n i t                                   */
00040 /******************************************************************************/
00041 
00042 int XrdCmsSupervisor::Init(const char *AdminPath, int AdminMode)
00043 {
00044    char spbuff[1024];
00045 
00046 // Create the supervisor unix domain socket. We use this for the redirector
00047 // assigned to this supervisor node (one one redirector allowed)
00048 //
00049    if (!XrdNetSocket::socketPath(&Say, spbuff, AdminPath,
00050       "olbd.super", AdminMode | S_IFSOCK)) return 1;
00051 
00052 // Create a new network suitable for use with XrdLink objects
00053 //
00054    if (!(NetTCPr = new XrdInet(&Say)))
00055       {Say.Emsg("Supervisor","Unable to create supervisor interface.");
00056        return 0;
00057       }
00058 
00059 // Set out domain name for this network
00060 //
00061    if (Config.myDomain) NetTCPr->setDomain(Config.myDomain);
00062 
00063 // Bind the unix domain path to the network
00064 //
00065    if (NetTCPr->Bind(spbuff, "tcp")) return 0;
00066 
00067 // All done
00068 //
00069    superOK = 1;
00070    return 1;
00071 }
00072   
00073 /******************************************************************************/
00074 /*                                 S t a r t                                  */
00075 /******************************************************************************/
00076 
00077 void XrdCmsSupervisor::Start()
00078 {
00079    XrdCmsProtocol *pP;
00080    XrdLink        *lP;
00081 
00082 // Accept single connections and dispatch the supervisor data interface
00083 //
00084    while(1) 
00085         if ((lP = NetTCPr->Accept(XRDNET_NODNTRIM)))
00086            {if ((pP = XrdCmsProtocol::Alloc("redirector")))
00087                {lP->setProtocol((XrdProtocol *)pP);
00088                 pP->Process(lP);
00089                 lP->Close();
00090                }
00091            }
00092 }

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