Skip to content
Snippets Groups Projects
Commit 83b9e4a9 authored by Johannes Elmsheuser's avatar Johannes Elmsheuser Committed by Walter Lampl
Browse files

JiveXML: update build dependency for RPC for CentOS7 and CentOS9

Fix for ATEAM-841. Handle Sun RPC remote address information transparently for IPv4 and IPv6 by using the generic getnameinfo() function. This includes Attila's suggested patch for CMake and the FindRPC.cmake and compiles on both CentOS 7 and 9. Adding the recommended constants to use for the size of result buffers of getnameinfo().  Patch orginally provided by Reiner Hauser.
parent 69543413
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Declare the package name:
atlas_subdir( JiveXML )
# External package(s).
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
if ( ATLAS_OS_ID STREQUAL "centos9" )
find_package( RPC )
endif()
# Component(s) in the package:
atlas_add_library( JiveXMLLib
src/*.cxx
PUBLIC_HEADERS JiveXML
LINK_LIBRARIES AthenaBaseComps GaudiKernel
PRIVATE_LINK_LIBRARIES EventInfo xAODEventInfo )
if ( RPC_FOUND )
atlas_add_library( JiveXMLLib
JiveXML/*.h src/*.cxx
PUBLIC_HEADERS JiveXML
INCLUDE_DIRS ${RPC_INCLUDE_DIRS}
LINK_LIBRARIES ${RPC_LIBRARIES} AthenaBaseComps GaudiKernel
PRIVATE_LINK_LIBRARIES EventInfo xAODEventInfo )
else()
atlas_add_library( JiveXMLLib
JiveXML/*.h src/*.cxx
PUBLIC_HEADERS JiveXML
INCLUDE_DIRS ${RPC_INCLUDE_DIRS}
LINK_LIBRARIES AthenaBaseComps GaudiKernel
PRIVATE_LINK_LIBRARIES EventInfo xAODEventInfo )
endif()
atlas_add_component( JiveXML
src/components/*.cxx
......@@ -17,4 +33,3 @@ atlas_add_component( JiveXML
# Install files from the package:
atlas_install_joboptions( share/*.py )
atlas_install_runtime( test/*.xml test/*.xsl )
......@@ -11,8 +11,7 @@
#include "JiveXML/EventStream.h"
#include "JiveXML/IServerSvc.h"
//Forward declaration
extern "C" struct CLIENT;
#include <rpc/clnt.h>
namespace JiveXML {
......
......@@ -5,6 +5,7 @@
#ifndef JIVEXML__ONCRPCSERVERPROCS_H
#define JIVEXML__ONCRPCSERVERPROCS_H
#include <rpc/rpc.h>
#include <string>
/**
......@@ -13,12 +14,6 @@
* return them to the caller.
*/
//forward declaration
#ifndef __APPLE__
struct SVCXPRT;
#else
#include <rpc/rpc.h>
#endif
struct EventRequest;
struct Event;
......
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
#
# Helper module for finding the location of the <rpc/*.h> headers and the
# corresponding library.
#
# Since this is the only package that depends on this system library, this
# module is defined here, instead of in AtlasCMake.
#
# Defines:
# RPC_INCLUDE_DIRS
# RPC_LIBRARIES
# RPC_FOUND
#
# Can be steered using RPC_ATROOT.
#
# Load the AtlasLCG helper code. Unfortunately AtlasCMake is not good
# at picking up stuff from /usr. Something to be improved at one point.
include( LCGFunctions )
# Declare the module:
lcg_external_module( NAME RPC
INCLUDE_SUFFIXES include include/tirpc
INCLUDE_NAMES rpc/rpc.h
LIBRARY_SUFFIXES lib lib32 lib64
DEFAULT_COMPONENTS tirpc )
# Handle the standard find_package arguments:
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( RPC DEFAULT_MSG RPC_INCLUDE_DIR
RPC_INCLUDE_DIRS RPC_LIBRARIES )
mark_as_advanced( RPC_FOUND RPC_INCLUDE_DIR )
......@@ -10,6 +10,7 @@
#include "JiveXML/IServer.h"
//Decoding of caller IP address
#include <climits>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
......@@ -124,23 +125,29 @@ namespace JiveXML {
if ( ServerSvc->LogLevel() <= MSG::DEBUG ){
//Get information about the requester
struct sockaddr_in* caller = svc_getcaller(rqstp->rq_xprt);
//Get port number
int port = caller->sin_port;
//Get IP-address
std::string IPAddr = inet_ntoa(caller->sin_addr);
//Try to get the hosts name
struct hostent *he = gethostbyaddr(&caller->sin_addr, sizeof ( struct in_addr), AF_INET);
auto caller = (struct sockaddr* )svc_getcaller(rqstp->rq_xprt);
char port[NI_MAXSERV];
char host[NI_MAXHOST];
char IPAddr[INET6_ADDRSTRLEN];
//assemble a message
msg << "Request from host ";
//Add host name if we have one
if (he) msg << he->h_name << " ";
if(getnameinfo(caller, rqstp->rq_xprt->xp_addrlen,
host, sizeof host,
nullptr, 0,
0) == 0)
msg << host << " ";
//Add ip-address and port
msg << "(" << IPAddr << ") on port " << port;
if(getnameinfo(caller, rqstp->rq_xprt->xp_addrlen,
IPAddr, sizeof IPAddr,
port, sizeof port,
NI_NUMERICSERV | NI_NUMERICHOST) == 0)
msg << "(" << IPAddr << ") on port " << port;
//Deliver the message
ServerSvc->Message(MSG::DEBUG,msg.str()); msg.str("");
}
//Prepare the dispatch thread argument structure making a copy of the
//request, so it sticks around if this thread is gone
DispatchThreadArguments DpThreadArgs(ServerSvc, new svc_req(*rqstp), NULL, NULL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment