Commit 04e74ecb authored by Steven Murray's avatar Steven Murray
Browse files

I have lost losts of time due to undecipherable compilation errors caused by

the following MACRO magic in h/log.h:

  #ifdef log
  #undef log
  #endif
  #define log (*logfunc)          /* logging function name                */

With this commit I remove the above MARCHO magic and simply replace "log" with
its expanded form of (*logfunc).
parent 348193bc
......@@ -54,14 +54,14 @@ char *getifnam_r(int s,
addrlen = (socklen_t) sizeof(struct sockaddr_in);
if (getsockname(s, (struct sockaddr *)&addr, &addrlen) == -1 ) {
TRACE(2,"getifnam_r", "getsockname returned %d", errno);
log(LOG_ERR, "getsockname: %s\n",strerror(errno));
(*logfunc)(LOG_ERR, "getsockname: %s\n",strerror(errno));
END_TRACE();
return(NULL);
} else {
binaddr = addr.sin_addr.s_addr;
}
if ((s_s = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ) {
log(LOG_ERR, "socket: %s\n",strerror(errno));
(*logfunc)(LOG_ERR, "socket: %s\n",strerror(errno));
return(NULL);
}
......@@ -70,7 +70,7 @@ char *getifnam_r(int s,
ifr = ifc.ifc_req;
if ((n = ioctl(s_s, SIOCGIFCONF, (char *)&ifc)) < 0) {
TRACE(2,"getifnam_r", "ioctl returned %d", errno);
log(LOG_ERR, "ioctl(SIOCGIFCONF): %s\n",strerror(errno));
(*logfunc)(LOG_ERR, "ioctl(SIOCGIFCONF): %s\n",strerror(errno));
(void) close(s_s);
END_TRACE();
return(NULL);
......
......@@ -45,7 +45,7 @@ int get_user(char *from_node,
char *last = NULL;
if ( (fsin=fopen(infile,"r"))==NULL ) {
log(LOG_ERR, "Could not open file %s, errno %d\n", infile, errno);
(*logfunc)(LOG_ERR, "Could not open file %s, errno %d\n", infile, errno);
serrno = ENOENT;
return -ENOENT ;
}
......@@ -54,7 +54,7 @@ int get_user(char *from_node,
if ( buf[0] == '#') continue ;
if ( ( p = strrchr( buf,'\n') ) != NULL ) *p='\0' ;
log(LOG_DEBUG,"Entry >%s< in %s\n",buf,infile) ;
(*logfunc)(LOG_DEBUG,"Entry >%s< in %s\n",buf,infile) ;
p = strtok_r( buf, " \t",&last);
if ( p != NULL ) strcpy (maphostnam, p) ;
......@@ -90,10 +90,10 @@ int get_user(char *from_node,
if ( strcmp( mapgid, "*" ) && ( (gid=atoi(mapgid)) <= 0 || gid != from_gid ) )
continue ;
log( LOG_DEBUG,"Found a possible entry: %s\n",to_user);
(*logfunc)( LOG_DEBUG,"Found a possible entry: %s\n",to_user);
if ( (pw = Cgetpwnam(to_user))==NULL) {
log(LOG_INFO,"Cgetpwnam(): %s\n",sstrerror(serrno));
(*logfunc)(LOG_INFO,"Cgetpwnam(): %s\n",sstrerror(serrno));
continue ;
} else {
*to_uid = pw->pw_uid;
......
......@@ -55,12 +55,12 @@ int isremote(struct in_addr from_host,
if ( (p=getconfent("SIMULATION","REMOTE",1))!=NULL &&
(p=(char *)strtok_r(p," \t",&last))!=NULL && !strcmp(p,"YES")) {
log(LOG_DEBUG,"isremote(): Client simulates remote behaviour\n");
(*logfunc)(LOG_DEBUG,"isremote(): Client simulates remote behaviour\n");
return 1 ;
}
if ( (p=getconfent("ISREMOTE","CALLS",1))!=NULL &&
(p=(char *)strtok_r(p," \t",&last) )!=NULL && !strcmp(p,"NO") ) {
log(LOG_DEBUG,"isremote(): Any connection assumed from local site\n");
(*logfunc)(LOG_DEBUG,"isremote(): Any connection assumed from local site\n");
return 0 ;
}
......@@ -70,12 +70,12 @@ int isremote(struct in_addr from_host,
gethostname(local, CA_MAXHOSTNAMELEN+1);
if ( (h=(struct hostent *)Cgethostbyname(local))==NULL) {
log(LOG_ERR,"isremote(): gethostbyname() error\n");
(*logfunc)(LOG_ERR,"isremote(): gethostbyname() error\n");
return -1 ;
}
ladd=(union adr *)h->h_addr_list[0];
in.s_addr=ladd->adr_i ;
log(LOG_DEBUG, "isremote(): Local host is %s\n",inet_ntoa( in ));
(*logfunc)(LOG_DEBUG, "isremote(): Local host is %s\n",inet_ntoa( in ));
if ( host_name != NULL ) {
FILE *fs;
......@@ -84,12 +84,12 @@ int isremote(struct in_addr from_host,
/*
* Is the hostname declared as a "remote" site host ?
*/
log(LOG_DEBUG,"isremote(): searching <%s> in %s\n",host_name, rthfile);
(*logfunc)(LOG_DEBUG,"isremote(): searching <%s> in %s\n",host_name, rthfile);
if ( (fs = fopen( rthfile, "r")) != NULL ) {
while ( fgets(s,CA_MAXHOSTNAMELEN+1,fs) != NULL ) {
if ( (cp= strtok_r(s," \n\t",&last))!=NULL ) {
if ( !isdigit(cp[0]) && (cp[0]!='#') && !strcmp(cp,host_name) ) {
log(LOG_DEBUG,"isremote(): %s is in list of external hosts\n",cp);
(*logfunc)(LOG_DEBUG,"isremote(): %s is in list of external hosts\n",cp);
fclose(fs);
return 1;
}
......@@ -97,11 +97,11 @@ int isremote(struct in_addr from_host,
strcpy(ent,cp) ;
if ( strtok_r(cp,".",&last) == NULL ||
strtok_r(NULL,".",&last) == NULL )
log(LOG_DEBUG,"%s ignored: IP specification too short\n", ent);
(*logfunc)(LOG_DEBUG,"%s ignored: IP specification too short\n", ent);
else {
if ( !strncmp( ent, inet_ntoa( from_host ), strlen(ent))) {
log(LOG_DEBUG,"Entry %s matches to %s\n",ent,inet_ntoa(from_host));
log(LOG_INFO,"isremote(): %s is classified as remote\n",host_name);
(*logfunc)(LOG_DEBUG,"Entry %s matches to %s\n",ent,inet_ntoa(from_host));
(*logfunc)(LOG_INFO,"isremote(): %s is classified as remote\n",host_name);
fclose(fs) ;
return 1 ;
}
......@@ -116,12 +116,12 @@ int isremote(struct in_addr from_host,
/*
* Is the hostname declared local ?
*/
log(LOG_DEBUG,"isremote(): searching <%s> in %s\n",host_name, lhfile);
(*logfunc)(LOG_DEBUG,"isremote(): searching <%s> in %s\n",host_name, lhfile);
if ( (fs = fopen( lhfile, "r")) != NULL ) {
while ( fgets(s,CA_MAXHOSTNAMELEN+1,fs) != NULL ) {
if ( (cp= strtok_r(s," \n\t",&last)) != NULL ) {
if ( !isdigit(cp[0]) && (cp[0]!='#') && !strcmp(cp,host_name) ) {
log(LOG_DEBUG,"isremote(): %s is in list of local hosts\n",cp);
(*logfunc)(LOG_DEBUG,"isremote(): %s is in list of local hosts\n",cp);
fclose(fs);
return 0;
}
......@@ -129,11 +129,11 @@ int isremote(struct in_addr from_host,
strcpy(ent,cp) ;
if ( strtok_r(cp,".",&last) == NULL ||
strtok_r(NULL,".",&last) == NULL )
log(LOG_DEBUG,"%s ignored: IP specification too short \n", ent);
(*logfunc)(LOG_DEBUG,"%s ignored: IP specification too short \n", ent);
else {
if ( !strncmp( ent, inet_ntoa( from_host ), strlen(ent) )) {
log(LOG_DEBUG,"Entry %s matches to %s\n",ent,inet_ntoa(from_host));
log(LOG_DEBUG,"isremote(): %s is classified as local\n",host_name);
(*logfunc)(LOG_DEBUG,"Entry %s matches to %s\n",ent,inet_ntoa(from_host));
(*logfunc)(LOG_DEBUG,"isremote(): %s is classified as local\n",host_name);
fclose (fs);
return 0 ;
}
......@@ -145,10 +145,10 @@ int isremote(struct in_addr from_host,
}
} /* if ( host_name != NULL ) */
log(LOG_DEBUG, "isremote(): Client host is %s\n",inet_ntoa( from_host )) ;
(*logfunc)(LOG_DEBUG, "isremote(): Client host is %s\n",inet_ntoa( from_host )) ;
if( (s_s = socket(AF_INET, SOCK_DGRAM, 0)) == -1 ) {
log(LOG_ERR, "socket: %s\n",strerror(errno));
(*logfunc)(LOG_ERR, "socket: %s\n",strerror(errno));
return -1;
}
......@@ -157,7 +157,7 @@ int isremote(struct in_addr from_host,
ifr = ifc.ifc_req;
if ((n = ioctl(s_s, SIOCGIFCONF, (char *)&ifc)) < 0) {
log(LOG_ERR, "ioctl(SIOCGIFCONF): %s\n",strerror(errno));
(*logfunc)(LOG_ERR, "ioctl(SIOCGIFCONF): %s\n",strerror(errno));
close(s_s);
return -1;
}
......@@ -165,16 +165,16 @@ int isremote(struct in_addr from_host,
{
for (n = ifc.ifc_len/sizeof(struct ifreq); --n >= 0; ifr++) {
memcpy (&addr, &ifr->ifr_addr, sizeof(struct sockaddr_in));
log(LOG_DEBUG , "Comparing %d and %d \n", inet_netof(addr.sin_addr), inet_netof(from_host));
(*logfunc)(LOG_DEBUG , "Comparing %d and %d \n", inet_netof(addr.sin_addr), inet_netof(from_host));
if ( inet_netof(addr.sin_addr) == inet_netof(from_host) ) {
close(s_s);
log(LOG_DEBUG ,"isremote(): client is in same site\n");
(*logfunc)(LOG_DEBUG ,"isremote(): client is in same site\n");
return 0;
}
}
}
close(s_s);
log(LOG_INFO ,"isremote(): client is in another site\n");
(*logfunc)(LOG_INFO ,"isremote(): client is in another site\n");
return 1;
}
......@@ -191,14 +191,14 @@ int CDoubleDnsLookup(int s, char *host) {
}
if ( getpeername(s,(struct sockaddr *)&from,&fromlen) == -1 ) {
save_errno = errno;
log(LOG_ERR, "CDoubleDnsLookup() getpeername(): %s\n",neterror());
(*logfunc)(LOG_ERR, "CDoubleDnsLookup() getpeername(): %s\n",neterror());
errno = save_errno;
return(-1);
}
if ( (hp = Cgethostbyaddr((void *)&from.sin_addr,sizeof(struct in_addr),from.sin_family)) == NULL ) {
save_errno = (serrno > 0 ? serrno : errno);
log(LOG_ERR,"CDoubleDnsLookup() Cgethostbyaddr(): h_errno=%d, %s\n",
(*logfunc)(LOG_ERR,"CDoubleDnsLookup() Cgethostbyaddr(): h_errno=%d, %s\n",
h_errno,neterror());
serrno = save_errno;
return(-1);
......@@ -210,7 +210,7 @@ int CDoubleDnsLookup(int s, char *host) {
*/
if ( (i = isremote(from.sin_addr,tmphost)) == -1 ) {
save_errno = errno;
log(LOG_ERR,"CDoubleDnsLookup() isremote(): %s\n",neterror());
(*logfunc)(LOG_ERR,"CDoubleDnsLookup() isremote(): %s\n",neterror());
errno = save_errno;
return(-1);
}
......@@ -220,7 +220,7 @@ int CDoubleDnsLookup(int s, char *host) {
if ( (hp = Cgethostbyname(tmphost)) == NULL ) {
save_errno = (serrno > 0 ? serrno : errno);
log(LOG_ERR,"CDoubleDnsLookup() Cgethostbyname(): h_errno=%d, %s\n",
(*logfunc)(LOG_ERR,"CDoubleDnsLookup() Cgethostbyname(): h_errno=%d, %s\n",
h_errno,neterror());
if ( h_errno == HOST_NOT_FOUND ) serrno = SENOSHOST;
else serrno = save_errno;
......@@ -228,7 +228,7 @@ int CDoubleDnsLookup(int s, char *host) {
}
i = 0;
while (hp->h_addr_list[i] != NULL) {
log(LOG_DEBUG,"CDoubleDnsLookup() comparing %s with %s\n",
(*logfunc)(LOG_DEBUG,"CDoubleDnsLookup() comparing %s with %s\n",
inet_ntoa(*(struct in_addr *)(hp->h_addr_list[i])),inet_ntoa(from.sin_addr));
if ( ((struct in_addr *)(hp->h_addr_list[i++]))->s_addr == from.sin_addr.s_addr ) return(0);
}
......
......@@ -23,11 +23,6 @@ EXTERN_C void logit (int, char *, ...);
EXTERN_C void setlogbits (int);
EXTERN_C int getloglv (void);
#ifdef log
#undef log
#endif
#define log (*logfunc) /* logging function name */
#ifndef _SYSLOG_WIN32_H
#include <syslog.h> /* system logger definitions */
#endif
......
......@@ -325,7 +325,7 @@ int qryFile(char *svcClass, char *path)
rc = stage_filequery(qrequests,1,&qresponses,&nbqresps,&opts);
UPDATE_TIMING(svcClass,stager_qry_end);
if ( rc != 0 ) {
log(LOG_ERR,"stage_filequery(%s), svcClass=%s: %s\n",
(*logfunc)(LOG_ERR,"stage_filequery(%s), svcClass=%s: %s\n",
path,svcClass,sstrerror(serrno));
UPDATE_ERROR(svcClass,stager_qry_error);
}
......@@ -371,7 +371,7 @@ int rmFile(char *svcClass, char *path)
UPDATE_TIMING(svcClass,stager_rm_end);
if (rc < 0) {
log(LOG_ERR, "stage_rm(%s,%s): %s, errbuf=%s\n",
(*logfunc)(LOG_ERR, "stage_rm(%s,%s): %s, errbuf=%s\n",
svcClass,path,sstrerror(serrno),errbuf);
UPDATE_ERROR(svcClass,stager_rm_error);
free_filereq(reqs,nbreqs);
......@@ -379,7 +379,7 @@ int rmFile(char *svcClass, char *path)
}
if (response == NULL) {
log(LOG_ERR, "stage_rm(%s,%s): Response object is NULL\n",
(*logfunc)(LOG_ERR, "stage_rm(%s,%s): Response object is NULL\n",
svcClass,path);
return(-1);
}
......@@ -401,7 +401,7 @@ void dumpStat()
fd = open(statFileName,oflags,0766);
if ( fd == -1 ) {
log(LOG_ERR,"dumpStat() open(%s): %s\n",statFileName,sstrerror(errno));
(*logfunc)(LOG_ERR,"dumpStat() open(%s): %s\n",statFileName,sstrerror(errno));
return;
}
now = time(NULL);
......@@ -480,7 +480,7 @@ void *svcClassProbe(
char *myWriteBuffer, *myReadBuffer;
if ( arg == NULL ) {
log(LOG_ERR,"svcClassProbe() thread started without service class???\n");
(*logfunc)(LOG_ERR,"svcClassProbe() thread started without service class???\n");
return(NULL);
}
mySvcClass = strdup((char *)arg);
......@@ -493,7 +493,7 @@ void *svcClassProbe(
strlen(stageHost)+strlen("/") +
strlen(mySvcClass)+1);
if ( myRootPath == NULL ) {
log(LOG_ERR,"malloc(): %s\n",sstrerror(errno));
(*logfunc)(LOG_ERR,"malloc(): %s\n",sstrerror(errno));
free(mySvcClass);
return(NULL);
}
......@@ -501,7 +501,7 @@ void *svcClassProbe(
stageHost,mySvcClass,directoryName);
rc = rfio_mkdir(myRootPath,0755);
if ( rc == -1 ) {
log(LOG_ERR,"rfio_mkdir(%s): %s\n",myRootPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_mkdir(%s): %s\n",myRootPath,rfio_serror());
if ( rfio_serrno() != EEXIST ) {
free(mySvcClass);
return(NULL);
......@@ -511,7 +511,7 @@ void *svcClassProbe(
stageHost,mySvcClass,directoryName,stageHost);
rc = rfio_mkdir(myRootPath,0755);
if ( rc == -1 ) {
log(LOG_ERR,"rfio_mkdir(%s): %s\n",myRootPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_mkdir(%s): %s\n",myRootPath,rfio_serror());
if ( rfio_serrno() != EEXIST ) {
free(mySvcClass);
return(NULL);
......@@ -521,28 +521,28 @@ void *svcClassProbe(
stageHost,mySvcClass,directoryName,stageHost,mySvcClass);
rc = rfio_mkdir(myRootPath,0755);
if ( rc == -1 ) {
log(LOG_ERR,"rfio_mkdir(%s): %s\n",myRootPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_mkdir(%s): %s\n",myRootPath,rfio_serror());
if ( rfio_serrno() != EEXIST ) {
free(mySvcClass);
return(NULL);
}
}
log(LOG_INFO,"svcClassProbe(%s) starting with root path %s\n",
(*logfunc)(LOG_INFO,"svcClassProbe(%s) starting with root path %s\n",
mySvcClass,myRootPath);
if ( (baseName = (char *)malloc(256)) == NULL ) {
log(LOG_ERR,"svcClassProbe(%s) malloc(): %s\n",mySvcClass,sstrerror(errno));
(*logfunc)(LOG_ERR,"svcClassProbe(%s) malloc(): %s\n",mySvcClass,sstrerror(errno));
free(mySvcClass);
return(NULL);
}
if ( (myWriteBuffer = (char *)malloc(bufferSize)) == NULL ) {
log(LOG_ERR,"svcClassProbe(%s) malloc(%d): %s\n",mySvcClass,
(*logfunc)(LOG_ERR,"svcClassProbe(%s) malloc(%d): %s\n",mySvcClass,
bufferSize,sstrerror(errno));
free(baseName);
free(mySvcClass);
return(NULL);
}
if ( (myReadBuffer = (char *)malloc(bufferSize)) == NULL ) {
log(LOG_ERR,"svcClassProbe(%s) malloc(%d): %s\n",mySvcClass,
(*logfunc)(LOG_ERR,"svcClassProbe(%s) malloc(%d): %s\n",mySvcClass,
bufferSize,sstrerror(errno));
free(myWriteBuffer);
free(baseName);
......@@ -566,7 +566,7 @@ void *svcClassProbe(
if ( fullPath != NULL ) free(fullPath);
fullPath = NULL;
if ( (fullPath = (char *)malloc(strlen(myRootPath)+strlen(baseName)+2)) == NULL ) {
log(LOG_ERR,"svcClassProbe(%s) malloc(): %s\n",mySvcClass,sstrerror(errno));
(*logfunc)(LOG_ERR,"svcClassProbe(%s) malloc(): %s\n",mySvcClass,sstrerror(errno));
return(NULL);
}
sprintf(fullPath,"%s/%s",myRootPath,baseName);
......@@ -579,7 +579,7 @@ void *svcClassProbe(
fd = rfio_open(fullPath,O_CREAT|O_TRUNC|O_WRONLY,0766);
UPDATE_TIMING(mySvcClass,rfio_open_write_end);
if ( fd == -1 ) {
log(LOG_ERR,"rfio_open(%s): %s\n",fullPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_open(%s): %s\n",fullPath,rfio_serror());
UPDATE_ERROR(mySvcClass,rfio_open_write_error);
continue;
}
......@@ -590,7 +590,7 @@ void *svcClassProbe(
rc = rfio_write(fd,myWriteBuffer,size);
if ( rc > 0 ) nbBytesWritten += rc;
else {
log(LOG_ERR,"rfio_write(%s,O_WRONLY): %s\n",fullPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_write(%s,O_WRONLY): %s\n",fullPath,rfio_serror());
UPDATE_ERROR(mySvcClass,rfio_write_error);
break;
}
......@@ -600,7 +600,7 @@ void *svcClassProbe(
rc = rfio_close(fd);
UPDATE_TIMING(mySvcClass,rfio_close_write_end);
if ( rc == -1 ) {
log(LOG_ERR,"rfio_close(%s): %s\n",fullPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_close(%s): %s\n",fullPath,rfio_serror());
UPDATE_ERROR(mySvcClass,rfio_close_write_error);
continue;
}
......@@ -613,7 +613,7 @@ void *svcClassProbe(
fd = rfio_open(fullPath,O_RDONLY,0766);
UPDATE_TIMING(mySvcClass,rfio_open_read_end);
if ( fd == -1 ) {
log(LOG_ERR,"rfio_open(%s,O_RDONLY): %s\n",fullPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_open(%s,O_RDONLY): %s\n",fullPath,rfio_serror());
UPDATE_ERROR(mySvcClass,rfio_open_read_error);
continue;
}
......@@ -624,13 +624,13 @@ void *svcClassProbe(
rc = rfio_read(fd,myReadBuffer,size);
if ( rc > 0 ) nbBytesRead += rc;
else {
log(LOG_ERR,"rfio_read(%s): %s\n",fullPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_read(%s): %s\n",fullPath,rfio_serror());
UPDATE_ERROR(mySvcClass,rfio_read_error);
break;
}
if ( rc == size ) {
if ( memcmp(myReadBuffer,myWriteBuffer,rc) != 0 ) {
log(LOG_ERR,"svcClassProbe(%s): data corruption after %d bytes?",
(*logfunc)(LOG_ERR,"svcClassProbe(%s): data corruption after %d bytes?",
mySvcClass,nbBytesRead);
UPDATE_ERROR(mySvcClass,corruption_error);
}
......@@ -641,7 +641,7 @@ void *svcClassProbe(
rc = rfio_close(fd);
UPDATE_TIMING(mySvcClass,rfio_close_read_end);
if ( rc == -1 ) {
log(LOG_ERR,"rfio_close(%s): %s\n",fullPath,rfio_serror());
(*logfunc)(LOG_ERR,"rfio_close(%s): %s\n",fullPath,rfio_serror());
UPDATE_ERROR(mySvcClass,rfio_close_read_error);
continue;
}
......@@ -764,7 +764,7 @@ int main(int argc, char *argv[])
thrPool = Cpool_create(nbSvcClasses,&nbThreads);
if ( (thrPool == -1) || (nbSvcClasses > nbThreads) ) {
log(LOG_ERR,"Cpool_init(): failed to get required number of threads (%d, got %d)\n",
(*logfunc)(LOG_ERR,"Cpool_init(): failed to get required number of threads (%d, got %d)\n",
nbSvcClasses,nbThreads);
exit(1);
}
......@@ -772,14 +772,14 @@ int main(int argc, char *argv[])
for (i=0; i<nbSvcClasses; i++) {
item = (TimingItem_t *)calloc(1,sizeof(TimingItem_t));
if ( item == NULL ) {
log(LOG_ERR,"calloc(1,%d): %s\n",sizeof(TimingItem_t),sstrerror(errno));
(*logfunc)(LOG_ERR,"calloc(1,%d): %s\n",sizeof(TimingItem_t),sstrerror(errno));
exit(1);
}
item->svcClass = strdup(svcClasses[i]);
CLIST_INSERT(timingList,item);
rc = Cpool_assign(thrPool,svcClassProbe,(void *)svcClasses[i],-1);
if ( rc == -1 ) {
log(LOG_ERR,"Cpool_assign(): %s\n",sstrerror(serrno));
(*logfunc)(LOG_ERR,"Cpool_assign(): %s\n",sstrerror(serrno));
exit(1);
}
}
......
......@@ -47,12 +47,12 @@ int rfio_alrm(int rcode,
struct stat statb ;
if ( (p= (char *)getconfent("RFIOD","ALRM",0)) == NULL ) {
log(LOG_DEBUG,"rfio_alrm() entered: no alarm in getconfent() \n");
(*logfunc)(LOG_DEBUG,"rfio_alrm() entered: no alarm in getconfent() \n");
return 1 ;
}
if ( ( (n=atoi(p)) > 0 && n==rcode ) || n==0 ) {
time(&clock) ;
log(LOG_DEBUG,"rfio_alrm(): alarm %s\n",buf) ;
(*logfunc)(LOG_DEBUG,"rfio_alrm(): alarm %s\n",buf) ;
if ( stat(RFIO_ALRM,&statb) < 0 ) {
wrtbanner ++ ;
}
......
......@@ -41,18 +41,18 @@ int connecttpread(char * host,
extern char * getenv() ; /* Getting env variables */
char * env ; /* To store env variables */
log(LOG_DEBUG,"Connecting tpread@%s to check key on port %d\n",host,aport);
(*logfunc)(LOG_DEBUG,"Connecting tpread@%s to check key on port %d\n",host,aport);
/*
* Creating socket.
*/
if (( sock= socket(AF_INET,SOCK_STREAM,0)) == -1 ) {
log(LOG_ERR,"socket(): %s\n",strerror(errno)) ;
(*logfunc)(LOG_ERR,"socket(): %s\n",strerror(errno)) ;
return -1 ;
}
if ((hp= Cgethostbyname(host)) == NULL ) {
serrno = SENOSHOST;
log(LOG_ERR,"Cgethostbyname(): %s\n",sstrerror(serrno)) ;
(*logfunc)(LOG_ERR,"Cgethostbyname(): %s\n",sstrerror(serrno)) ;
close(sock);
return -1 ;
}
......@@ -72,14 +72,14 @@ int connecttpread(char * host,
* Connecting the socket.
*/
if ( connect(sock, (struct sockaddr *) &sin, sizeof(sin)) == -1 ) {
log(LOG_ERR,"connect(): %s\n",strerror(errno)) ;
(*logfunc)(LOG_ERR,"connect(): %s\n",strerror(errno)) ;
close(sock);
return -1 ;
}
log(LOG_DEBUG,"Checking that key replier is in site\n");
(*logfunc)(LOG_DEBUG,"Checking that key replier is in site\n");
if ( isremote(sin.sin_addr, host) ) {
log(LOG_INFO,"Attempt to give key from outside site rejected\n");
(*logfunc)(LOG_INFO,"Attempt to give key from outside site rejected\n");
close(sock);
return -1 ;
}
......@@ -107,31 +107,31 @@ int checkkey(int sock,
* Sending key.
*/
if ( netwrite_timeout(sock,marsh_buf,3*LONGSIZE,RFIO_CTRL_TIMEOUT) != (3*LONGSIZE) ) {
log(LOG_ERR,"netwrite(): %s\n", strerror(errno)) ;
(*logfunc)(LOG_ERR,"netwrite(): %s\n", strerror(errno)) ;
return -1 ;
}
/*
* Waiting for ok akn.
*/
if ( (rcode= netread_timeout(sock,marsh_buf,LONGSIZE*3,RFIO_CTRL_TIMEOUT)) != (LONGSIZE*3) ) {
log(LOG_ERR,"netread(): %s\n",strerror(errno)) ;
(*logfunc)(LOG_ERR,"netread(): %s\n",strerror(errno)) ;
(void) close(sock) ;
return -1 ;
}
ptr = marsh_buf ;
if ( rcode == 0 ) {
log(LOG_ERR,"connection closed by remote end\n") ;
(*logfunc)(LOG_ERR,"connection closed by remote end\n") ;
(void) close(sock) ;
return -1 ;
}
unmarshall_LONG(ptr,magic);
if ( magic != RFIO2TPREAD_MAGIC ) {
log(LOG_ERR,"Magic inconsistency. \n");
(*logfunc)(LOG_ERR,"Magic inconsistency. \n");
return -1 ;
}
unmarshall_LONG(ptr,answer);
if ( answer==OK ) {
log(LOG_DEBUG,"Key is correct.\n");
(*logfunc)(LOG_DEBUG,"Key is correct.\n");
return 1 ;
}
else
......
......@@ -55,22 +55,22 @@ static void
p->aligned = a;
p->next = NULL;
log(ALIGNEDBUF_LOG_LEVEL,"%s: u=%p a=%p\n", __func__, u, a);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL,"%s: u=%p a=%p\n", __func__, u, a);
if (a_map_find_unaligned(a)) {
log(LOG_ERR,"%s: mapping already exists!\n", __func__);
(*logfunc)(LOG_ERR,"%s: mapping already exists!\n", __func__);
free(p);
return a;
}
if ((q = _a_map_get_tail())) {
q->next = p;
log(ALIGNEDBUF_LOG_LEVEL, "tail q=%p\n", q);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL, "tail q=%p\n", q);
} else {
aligned_mapping = p;
log(ALIGNEDBUF_LOG_LEVEL, "head p=%p\n", p);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL, "head p=%p\n", p);
}
return a;
} else {
log(LOG_ERR,"%s: malloc() failed\n", __func__);
(*logfunc)(LOG_ERR,"%s: malloc() failed\n", __func__);
return NULL;
}
}
......@@ -99,9 +99,9 @@ static void
}
u = q->unaligned;
free(q);
log(ALIGNEDBUF_LOG_LEVEL,"%s: u=%p a=%p\n", __func__, u, a);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL,"%s: u=%p a=%p\n", __func__, u, a);
} else {
log(LOG_ERR,"%s: a=%p mapping not found!\n", __func__, a);
(*logfunc)(LOG_ERR,"%s: a=%p mapping not found!\n", __func__, a);
}
return u;
}
......@@ -113,7 +113,7 @@ void
int padding;
void *unaligned, *aligned;
log(ALIGNEDBUF_LOG_LEVEL,"%s(%ld)\n", __func__, size);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL,"%s(%ld)\n", __func__, size);
page_size = getpagesize();
mask = page_size-1;
padding = (size + mask) / page_size;
......@@ -122,13 +122,13 @@ void
if (unaligned) {
aligned = (void*)((intptr_t) (unaligned + mask) & ~mask);
if ( a_map_add(unaligned, aligned) ) {
log(ALIGNEDBUF_LOG_LEVEL, "%s: success\n", __func__);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL, "%s: success\n", __func__);
return (void*)aligned;
} else {
return NULL;
}
} else {
log(ALIGNEDBUF_LOG_LEVEL, "%s: failure\n", __func__);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL, "%s: failure\n", __func__);
return NULL;
}
}
......@@ -138,13 +138,13 @@ free_page_aligned(void *buf)
{
void *unaligned;
log(ALIGNEDBUF_LOG_LEVEL,"%s: buf=%p\n", __func__, buf);
(*logfunc)(ALIGNEDBUF_LOG_LEVEL,"%s: buf=%p\n", __func__, buf);
unaligned = a_map_del(buf);