Skip to content

Commit

Permalink
Merge branch 'master' into xrdssi
Browse files Browse the repository at this point in the history
Conflicts:
	docs/PreReleaseNotes.txt
  • Loading branch information
abh3 committed Sep 20, 2015
2 parents 5ae5805 + 5c14410 commit f875af9
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 14 deletions.
5 changes: 1 addition & 4 deletions docs/PreReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ Prerelease Notes
* [Server] Allow declaring extra large I/O buffers (mostly for Ceph).

+ **Major bug fixes**
* [Server] Avoid SEGV when an excessively long readv vector is presented.
* [XrdCl] Process waitresp synchronously via Ignore return to avoid SEGV.
* [XrdCl] Avoid memory leak when a handler returns Ignore for a taken
message. This becomes more severe with above patch.
* [XrdCl] Avoid SEGV when server fails after it responds waitresp.

+ **Minor bug fixes**

Expand Down
1 change: 1 addition & 0 deletions packaging/rhel/xrootd.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ fi
%{_libdir}/libXrdPss-4.so
%{_libdir}/libXrdXrootd-4.so
%{_libdir}/libXrdFileCache-4.so
%{_libdir}/libXrdBlacklistDecision-4.so
%{_libdir}/libXrdHttp-4.so
%{_libdir}/libXrdOssSIgpfsT-4.so
%{_libdir}/libXrdServer.so.*
Expand Down
1 change: 1 addition & 0 deletions src/XrdCl/XrdClXRootDMsgHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ namespace XrdCl
return Take | RemoveHandler;

case kXR_waitresp:
pResponse = 0;
return Take | Ignore; // This must be handled synchronously!

//------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/XrdCms/XrdCmsProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ int XrdCmsProtocol::Process(XrdLink *lp)
// rejected until we finish removing this node. We get the node lock afterwards.
//
lp->Serialize();
if (!myNode) return -1;
myNode->Lock();

// Immediately terminate redirectors (they have an Rslot).
Expand Down
23 changes: 23 additions & 0 deletions src/XrdFileCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include( XRootDCommon )
# Modules
#-------------------------------------------------------------------------------
set( LIB_XRD_FILECACHE XrdFileCache-${PLUGIN_VERSION} )
set( LIB_XRD_BLACKLIST XrdBlacklistDecision-${PLUGIN_VERSION} )

#-------------------------------------------------------------------------------
# Shared library version
Expand Down Expand Up @@ -38,6 +39,24 @@ set_target_properties(
INTERFACE_LINK_LIBRARIES ""
LINK_INTERFACE_LIBRARIES "" )

#-------------------------------------------------------------------------------
# The XrdBlacklistDecision library
#-------------------------------------------------------------------------------
add_library(
${LIB_XRD_BLACKLIST}
MODULE
XrdFileCache/XrdFileCacheBlacklistDecision.cc)

target_link_libraries(
${LIB_XRD_BLACKLIST}
)

set_target_properties(
${LIB_XRD_BLACKLIST}
PROPERTIES
INTERFACE_LINK_LIBRARIES ""
LINK_INTERFACE_LIBRARIES "" )

#-------------------------------------------------------------------------------
# xrdpfc_print
#-------------------------------------------------------------------------------
Expand All @@ -59,6 +78,10 @@ install(
TARGETS ${LIB_XRD_FILECACHE}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )

install(
TARGETS ${LIB_XRD_BLACKLIST}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )

install(
TARGETS xrdpfc_print
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
Expand Down
130 changes: 130 additions & 0 deletions src/XrdFileCache/XrdFileCacheBlacklistDecision.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
//----------------------------------------------------------------------------------
// Copyright (c) 2015 by Board of Trustees of the Leland Stanford, Jr., University
// Author: Alja Mrak-Tadel, Matevz Tadel, Brian Bockelman
//----------------------------------------------------------------------------------
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------

#include "XrdFileCacheDecision.hh"
#include "XrdSys/XrdSysError.hh"

#include <vector>
#include <fcntl.h>
#include <stdio.h>
#include <fnmatch.h>

class BlacklistDecision : public XrdFileCache::Decision
{
//----------------------------------------------------------------------------
//! A decision library that allows all files to be cached except for a blacklist
//----------------------------------------------------------------------------

public:
virtual bool Decide(const std::string & url, XrdOss &) const
{
size_t slashslash = url.find("//");
const char *fname = url.c_str();
if (slashslash != std::string::npos)
{
fname += slashslash+2;
fname = strchr(fname, '/');
if (!fname) {return true;}
}
std::string url_path = fname;
size_t question = url_path.find("?");
if (question != std::string::npos)
{
url_path[question] = '\0';
fname = url_path.c_str();
}
if ((strlen(fname) > 1) && (fname[0] == '/') && (fname[1] == '/'))
{
fname++;
}
//m_log.Emsg("BlacklistDecide", "Deciding whether to cache file", fname);
for (std::vector<std::string>::const_iterator it = m_blacklist.begin(); it != m_blacklist.end(); it++)
{
if (!fnmatch(it->c_str(), fname, FNM_PATHNAME))
{
//m_log.Emsg("BlacklistDecide", "Not caching file as it matches blacklist entry", it->c_str());
return false;
}
}
//m_log.Emsg("BlacklistDecide", "Caching file", fname);
return true;
}

BlacklistDecision(XrdSysError &log)
: m_log(log)
{
}

virtual bool ConfigDecision(const char * parms)
{
if (!parms || !parms[0] || (strlen(parms) == 0))
{
m_log.Emsg("ConfigDecision", "Blacklist file not specified.");
return false;
}
m_log.Emsg("ConfigDecision", "Using blacklist", parms);
FILE * fp = fopen(parms, "r");
if (fp == 0)
{
m_log.Emsg("ConfigDecision", errno, "Failed to open blacklist:", parms);
return false;
}

ssize_t read;
size_t len =0;
char *line = NULL;
while (-1 != (read=getline(&line, &len, fp)))
{
char *trimmed = line;
while (trimmed[0] && isspace(trimmed[0])) {trimmed++;}
if (trimmed[0] == 0) {continue;}
size_t filelen = strlen(trimmed);
if (trimmed[filelen-1] == '\n') {trimmed[filelen-1] = '\0';}
m_blacklist.push_back(trimmed);
}
free(line);
fclose(fp);
if (!feof(fp))
{
m_log.Emsg("ConfigDecision", errno, "Failed to parse blacklist");
}
for (std::vector<std::string>::const_iterator it=m_blacklist.begin(); it!=m_blacklist.end(); it++)
{
m_log.Emsg("ConfigDecision", "Cache is blacklisting paths matching", it->c_str());
}
return true;
}

private:
std::vector<std::string> m_blacklist;
XrdSysError &m_log;
};

/******************************************************************************/
/* XrdFileCacheGetDecision */
/******************************************************************************/

// Return a decision object to use.
extern "C"
{
XrdFileCache::Decision *XrdFileCacheGetDecision(XrdSysError &err)
{
return new BlacklistDecision(err);
}
}

2 changes: 1 addition & 1 deletion src/XrdFileCache/XrdFileCacheDecision.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace XrdFileCache
//!
//! @return decision
//---------------------------------------------------------------------
virtual bool Decide(std::string &, XrdOss &) const = 0;
virtual bool Decide(const std::string &, XrdOss &) const = 0;

//------------------------------------------------------------------------------
//! Parse configuration arguments.
Expand Down
3 changes: 2 additions & 1 deletion src/XrdFileCache/XrdFileCacheFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool Factory::xdlib(XrdOucStream &Config)
std::string libp;
if (!(val = Config.GetWord()) || !val[0])
{
clLog()->Info(XrdCl::AppMsg, " Factory:;Config() decisionlib not specified; always caching files");
clLog()->Info(XrdCl::AppMsg, " Factory::Config() decisionlib not specified; always caching files");
return true;
}
else
Expand Down Expand Up @@ -150,6 +150,7 @@ bool Factory::xdlib(XrdOucStream &Config)
d->ConfigDecision(params);

m_decisionpoints.push_back(d);
clLog()->Info(XrdCl::AppMsg, "Factory::Config() successfully created decision lib from %s", libp.c_str());
return true;
}
//______________________________________________________________________________
Expand Down
16 changes: 15 additions & 1 deletion src/XrdOuc/XrdOucFileInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ XrdOucFileInfo::~XrdOucFileInfo()
// Destroy the url list
//
while((udP = uP)) {uP = uP->next; delete udP;}

// Free the memory allocated for fTargetName
//
if( fTargetName ) free(fTargetName);
}

/******************************************************************************/
Expand Down Expand Up @@ -150,7 +154,17 @@ void XrdOucFileInfo::AddUrl(const char *url, const char *cntry,
else fUrl = urlP;
if (fUrl != fUrlNext) fUrlNext = fUrl;
}


/******************************************************************************/
/* A d d F i l e N a m e */
/******************************************************************************/

void XrdOucFileInfo::AddFileName(const char * filename)
{
if(filename)
fTargetName = strdup(filename);
}

/******************************************************************************/
/* G e t D i g e s t */
/******************************************************************************/
Expand Down
17 changes: 16 additions & 1 deletion src/XrdOuc/XrdOucFileInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ void AddDigest(const char *hname, const char *hval);

void AddUrl(const char *url, const char *cntry=0,
int prty=0, bool fifo=true);
//-----------------------------------------------------------------------------
//! Add a filename to the file descriptions.
//!
//! @param filename Poiner to file name.
//-----------------------------------------------------------------------------
void AddFileName(const char * filename);

//-----------------------------------------------------------------------------
//! Obtain the next digest that can be used to validate the file.
Expand All @@ -93,6 +99,14 @@ const char *GetDigest(const char *&hval, bool xrdname=true);

const char *GetLfn() {return fLfn;}

//-----------------------------------------------------------------------------
//! Obtain the target file name.
//!
//! @return Pointer to the target file name. The target filename is valid until this object is deleted.
//-----------------------------------------------------------------------------

const char *GetTargetName() {return fTargetName;}

//-----------------------------------------------------------------------------
//! Get file size.
//!
Expand Down Expand Up @@ -133,7 +147,7 @@ void SetSize(long long fsz) {fSize = fsz;}

XrdOucFileInfo(const char *lfn=0)
: nextFile(0), fHash(0), fHashNext(0),
fUrl(0), fUrlNext(0), fSize(-1)
fUrl(0), fUrlNext(0), fTargetName(0), fSize(-1)
{if (lfn) fLfn = strdup(lfn);
else fLfn = 0;
}
Expand All @@ -157,6 +171,7 @@ XrdOucFIHash *fHashNext;
XrdOucFIUrl *fUrl;
XrdOucFIUrl *fUrlNext;
char *fLfn;
char *fTargetName;
long long fSize;
};
#endif
23 changes: 20 additions & 3 deletions src/XrdPss/XrdPss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,26 @@ const char *XrdPssSys::P2CGI(int &cgilen, char *cbuff, int cblen,
if (!Cgi1) {cgilen = strlen(Cgi2); return Cgi2;}
if (!Cgi2) return Cgi1;

// Compose the two cgi elements together
//
cgilen = snprintf(cbuff, cblen, "%s&%s", Cgi1, Cgi2);
// Strip out any 'tried='
// Then, Compose the two cgi elements together
const char * tried_loc = strstr(Cgi1, "tried=");
if (tried_loc != NULL) {
const char *next_amp = strchr(tried_loc, '&');
size_t bytes_to_copy = tried_loc-Cgi1;
if (bytes_to_copy >= static_cast<size_t>(cblen)) {return NULL;}
memcpy(cbuff, Cgi1, bytes_to_copy);
cgilen = bytes_to_copy;
if (next_amp)
{
cgilen += snprintf(cbuff+bytes_to_copy, cblen-bytes_to_copy, "%s&%s", next_amp, Cgi2);
}
else
{
cgilen += snprintf(cbuff+bytes_to_copy, cblen-bytes_to_copy, "&%s", Cgi2);
}
} else {
cgilen = snprintf(cbuff, cblen, "%s&%s", Cgi1, Cgi2);
}
return (cgilen >= cblen ? 0 : cbuff);
}

Expand Down
17 changes: 17 additions & 0 deletions src/XrdXml/XrdXmlMetaLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,14 @@ bool XrdXmlMetaLink::GetFile(const char *scope)

bool XrdXmlMetaLink::GetFileInfo(const char *scope)
{
static const char *fileScope = "file";
const char *fsubElem[] = {scope, "url", "hash", "size",
"verification", "resources", 0};
int ePos;

if(strncmp(scope, fileScope, 4) == 0)
GetName();

// Process the elements in he file section. Both formats have the same tags,
// though not the same attributes. We will take care of the differences later.
//
Expand Down Expand Up @@ -425,6 +429,19 @@ bool XrdXmlMetaLink::GetUrl()
return true;
}

/******************************************************************************/
/* Private: G e t N a m e */
/******************************************************************************/

void XrdXmlMetaLink::GetName()
{
static const char *mAtr[] = {"name", 0};
char *mVal[] = {0};
reader->GetAttributes(mAtr, mVal);
currFile->AddFileName(mVal[0]);
free(mVal[0]);
}

/******************************************************************************/
/* Private: P u t F i l e */
/******************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/XrdXml/XrdXmlMetaLink.hh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ bool GetHash();
void GetRdrError(const char *why);
bool GetSize();
bool GetUrl();
void GetName();
bool PutFile(const char *buff, int blen);
bool UrlOK(char *url);

Expand Down
Loading

0 comments on commit f875af9

Please sign in to comment.