From 19f0a27674405c2cb4d7e1bf248351bac855e929 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Tue, 16 Oct 2007 15:57:42 +0000 Subject: [PATCH] Prepare for merge LB common (can't compile). --- org.glite.lb.common/Makefile | 13 +++- org.glite.lb.common/interface/connpool.h | 16 +++-- org.glite.lb.common/interface/context-int.h | 33 ++++++++--- org.glite.lb.common/interface/lb_plain_io.h | 6 +- org.glite.lb.common/project/version.properties | 5 +- org.glite.lb.common/src/context.c | 24 +++++++- org.glite.lb.common/src/events.c.T | 34 +++++++++-- org.glite.lb.common/src/events_parse.c.T | 4 +- org.glite.lb.common/src/il_log.c | 2 +- org.glite.lb.common/src/mini_http.c | 2 +- org.glite.lb.common/src/xml_parse.c.T | 9 ++- org.glite.lb.common/test/parse.cpp.T | 82 +++++++++++++------------- 12 files changed, 158 insertions(+), 72 deletions(-) diff --git a/org.glite.lb.common/Makefile b/org.glite.lb.common/Makefile index d02ee1b..44b1b07 100644 --- a/org.glite.lb.common/Makefile +++ b/org.glite.lb.common/Makefile @@ -52,7 +52,13 @@ ifneq (${expat_prefix},/usr) endif EXPAT_LIBS:=${EXPAT_LIBS} -lexpat -LDFLAGS:=-L${stagedir}/lib \ +archlib:=lib +host_cpu:=${shell uname -m} +ifeq (${host_cpu},x86_64) + archlib:=lib64 +endif + +LDFLAGS:=-L${stagedir}/${archlib} -L${stagedir}/lib \ ${COVERAGE_FLAGS} EXT_LIBS:= ${EXPAT_LIBS} ${JOBID_LIB} ${TRIO_LIB} @@ -215,9 +221,14 @@ install: doc fi clean: +<<<<<<< Makefile rm -rvf *.o *.lo .libs lib* *.c *.h *.dox C/ CPP/ test_parse il_test parse.cpp events.tex status.tex rm -vf ${globalprefix} ${lbprefix} rm -rvf log.xml project/ rpmbuild/ RPMS/ tgz/ +======= + rm -rf *.o *.lo .libs lib* *.c test_parse il_test + +>>>>>>> 1.57.2.3 %.o: %.c ${COMPILE} ${CFLAGS} -c $< diff --git a/org.glite.lb.common/interface/connpool.h b/org.glite.lb.common/interface/connpool.h index 2545436..8b786a6 100644 --- a/org.glite.lb.common/interface/connpool.h +++ b/org.glite.lb.common/interface/connpool.h @@ -1,6 +1,7 @@ #ifndef GLITE_LB_CONNPOOL_H #define GLITE_LB_CONNPOOL_H +#include "glite/lb/padstruct.h" #include "glite/security/glite_gss.h" #include "glite/lb/context.h" #include "glite/lb/lb_plain_io.h" @@ -18,8 +19,7 @@ extern "C" { #define GLITE_LB_COMMON_CONNPOOL_SIZE 50 - -typedef struct _edg_wll_ConnPool { +glite_lb_padded_struct(_edg_wll_ConnPool,15, /* address and port where we are connected to */ char *peerName; unsigned int peerPort; @@ -28,11 +28,18 @@ typedef struct _edg_wll_ConnPool { edg_wll_GssCred gsiCred; edg_wll_GssConnection gss; char *buf; - int bufUse,bufSize; + int bufUse; + int bufSize; /* timestamp of usage of this entry in ctx.connPool */ struct timeval lastUsed; -} edg_wll_ConnPool; + +/* Proxy/Cert file identification */ + + struct stat *certfile; + +); +typedef struct _edg_wll_ConnPool edg_wll_ConnPool; #endif @@ -94,6 +101,7 @@ void edg_wll_poolFree(); in case memory has been already allocated, just return a pointer */ edg_wll_Connections* edg_wll_initConnections(); + #ifdef __cplusplus } #endif diff --git a/org.glite.lb.common/interface/context-int.h b/org.glite.lb.common/interface/context-int.h index bea1992..52bdd1e 100644 --- a/org.glite.lb.common/interface/context-int.h +++ b/org.glite.lb.common/interface/context-int.h @@ -14,13 +14,23 @@ #ifdef __cplusplus extern "C" { #endif - + +/* TODO: merge */ +<<<<<<< context-int.h #define EDG_WLL_SEQ_NULL "UI=000000:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000:LBS=000000" #define EDG_WLL_SEQ_PBS_NULL "TIMESTAMP=00000000000000:POS=0000000000:EV.CODE=000:SRC=?" #define EDG_WLL_SEQ_CONDOR_NULL EDG_WLL_SEQ_PBS_NULL #define EDG_WLL_SEQ_SIZE 103 /* strlen(EDG_WLL_SEQ_NULL)+1 */ #define EDG_WLL_SEQ_PBS_SIZE 57 /* strlen(EDG_WLL_SEQ_PBS_NULL)+1 */ #define EDG_WLL_SEQ_CONDOR_SIZE EDG_WLL_SEQ_PBS_SIZE +======= +#define EDG_WLL_SEQ_NULL "UI=000000:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000:LBS=000000" +#define EDG_WLL_SEQ_PBS_NULL "TIMESTAMP=00000000000000:POS=0000000000:EV.CODE=000:SRC=?" +#define EDG_WLL_SEQ_CONDOR_NULL EDG_WLL_SEQ_PBS_NULL +#define EDG_WLL_SEQ_SIZE (sizeof(EDG_WLL_SEQ_NULL)) +#define EDG_WLL_SEQ_PBS_SIZE (sizeof(EDG_WLL_SEQ_PBS_NULL)) +#define EDG_WLL_SEQ_CONDOR_SIZE EDG_WLL_SEQ_PBS_SIZE +>>>>>>> 1.26.2.4 typedef struct _edg_wll_SeqCode { unsigned int type; /* seq code type */ @@ -34,16 +44,16 @@ typedef struct _edg_wll_SeqCode { } edg_wll_SeqCode; /* non-gsi one-element analogy of connPool for L&B Proxy server */ -typedef struct _edg_wll_ConnProxy { +glite_lb_padded_struct(_edg_wll_ConnProxy,12, edg_wll_PlainConnection conn; char *buf; size_t bufSize; size_t bufUse; -} edg_wll_ConnProxy; - +) +typedef struct _edg_wll_ConnProxy edg_wll_ConnProxy; -struct _edg_wll_Context { +glite_lb_padded_struct(_edg_wll_Context,120, /* Error handling */ int errCode; /* recent error code */ char *errDesc; /* additional error description */ @@ -56,7 +66,8 @@ struct _edg_wll_Context { edg_wll_ConnPool *connPoolNotif; /* hold _one_ connection from notif-interlogger */ edg_wll_ConnProxy *connProxy; /* holds one plain connection */ - int semaphores,semset; + int semaphores; + int semset; edg_wll_QueryRec **job_index; void *job_index_cols; @@ -113,7 +124,11 @@ struct _edg_wll_Context { char *p_lbproxy_store_sock; char *p_lbproxy_serve_sock; char *p_user_lbproxy; - struct timeval p_log_timeout,p_sync_timeout,p_query_timeout, p_notif_timeout, p_tmp_timeout; + struct timeval p_log_timeout; + struct timeval p_sync_timeout; + struct timeval p_query_timeout; + struct timeval p_notif_timeout; + struct timeval p_tmp_timeout; char *p_query_server; int p_query_server_port; int p_query_server_override; @@ -132,7 +147,9 @@ struct _edg_wll_Context { int count_statistics; int greyjobs; -}; + + char **fqans; /* null-terminated list of peer's VOMS FQANs */ +) /* to be used internally: set, update and and clear the error information in * context, the desc string (if provided) is strdup()-ed diff --git a/org.glite.lb.common/interface/lb_plain_io.h b/org.glite.lb.common/interface/lb_plain_io.h index 1043d53..0723159 100644 --- a/org.glite.lb.common/interface/lb_plain_io.h +++ b/org.glite.lb.common/interface/lb_plain_io.h @@ -1,17 +1,19 @@ #ifndef GLITE_LB_PLAIN_IO_H #define GLITE_LB_PLAIN_IO_H +#include "glite/lb/padstruct.h" #ifdef __cplusplus extern "C" { #endif -typedef struct _edg_wll_PlainConnection { +glite_lb_padded_struct(_edg_wll_PlainConnection,6, int sock; char *buf; size_t bufSize; size_t bufUse; -} edg_wll_PlainConnection; +) +typedef struct _edg_wll_PlainConnection edg_wll_PlainConnection; int edg_wll_plain_accept( diff --git a/org.glite.lb.common/project/version.properties b/org.glite.lb.common/project/version.properties index 7042e91..b75f320 100644 --- a/org.glite.lb.common/project/version.properties +++ b/org.glite.lb.common/project/version.properties @@ -1,4 +1,3 @@ -# $Id$ -# $Name$ -module.version=5.0.3 +# $Header$ +module.version=6.1.0 module.age=1 diff --git a/org.glite.lb.common/src/context.c b/org.glite.lb.common/src/context.c index 799b0ba..f6ecf5d 100644 --- a/org.glite.lb.common/src/context.c +++ b/org.glite.lb.common/src/context.c @@ -133,6 +133,13 @@ void edg_wll_FreeContext(edg_wll_Context ctx) if (ctx->vomsGroups.len) free_voms_groups(&ctx->vomsGroups); if (ctx->dumpStorage) free(ctx->dumpStorage); if (ctx->purgeStorage) free(ctx->purgeStorage); + if (ctx->fqans) { + char **f; + for (f = ctx->fqans; f && *f; f++) + free(*f); + free(ctx->fqans); + ctx->fqans = NULL; + } edg_wll_FreeParams(ctx); @@ -151,7 +158,6 @@ static const char* const errTexts[] = { "Server response error", "Bad JobId format", "Database call failed", - "Bad URL format", "MD5 key clash", "GSSAPI Error", "DNS resolver error", @@ -161,7 +167,6 @@ static const char* const errTexts[] = { "Interlogger internal error", "Interlogger has events pending", "Compared events differ", - "SQL parse error", }; const char *edg_wll_GetErrorText(int code) { @@ -377,7 +382,10 @@ int edg_wll_SetSequenceCode(edg_wll_Context ctx, &c[EDG_WLL_SOURCE_LB_SERVER]); assert(EDG_WLL_SOURCE__LAST == 10); - if (res != EDG_WLL_SOURCE__LAST-1) + if (res == EDG_WLL_SOURCE_LB_SERVER-1) { + /* pre-collections compatibility */ + c[EDG_WLL_SOURCE_LB_SERVER] = 0; + } else if (res != EDG_WLL_SOURCE__LAST-1) return edg_wll_SetError(ctx, EINVAL, "edg_wll_SetSequenceCode(): syntax error in sequence code"); @@ -471,12 +479,22 @@ int edg_wll_GenerateSubjobIds( retjobs == NULL) return edg_wll_SetError(ctx, ENOMEM, NULL); +/* TODO: merge */ +<<<<<<< context.c if ( !seed || !strcmp(seed, "(nil)") ) { intseed = strdup("edg_wll_GenerateSubjobIds()"); } else intseed = strdup(seed); +======= + if ( !seed ) { + intseed = strdup("edg_wll_GenerateSubjobIds()"); + } + else + intseed = strdup(seed); + +>>>>>>> 1.23.2.10 for (subjob = 0; subjob < num_subjobs; subjob++) { asprintf(&unhashed, "%s,%s,%d", p_unique, intseed, subjob); diff --git a/org.glite.lb.common/src/events.c.T b/org.glite.lb.common/src/events.c.T index bd3beea..f69ecc3 100644 --- a/org.glite.lb.common/src/events.c.T +++ b/org.glite.lb.common/src/events.c.T @@ -21,9 +21,28 @@ static const struct timeval null_timeval = {0,0}; static const char *eventNames[] = { "Undefined", @@@{ +my $flesh = 'gLite'; #XXX +my $fleshno = 0; +my $eventno = $fleshno; + for my $e (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } $event->getTypes) { - gen "\t\"$e\",\n"; + + if ($flesh ne $event->{flesh}->{$e}) { + $flesh = $event->{flesh}->{$e}; + $fleshno += 100; + + gen "\t"; + while ($eventno < $fleshno) { + gen "NULL, "; + $eventno++; + if (($eventno % 10) == 0) { gen "\n\t"; } + } + gen "\n"; + } + + $eventno++; + gen "\t\"$e\", /* $eventno */\n"; } @@@} "SysCmpStat", @@ -43,7 +62,7 @@ edg_wll_EventCode edg_wll_StringToEvent(const char *name) unsigned int i; for (i=1; i= sizeof(eventNames)/sizeof(eventNames[0])) return NULL; - return strdup(eventNames[event]); + return eventNames[event] ? strdup(eventNames[event]) : NULL; } @@ -68,6 +87,7 @@ static const char *keyNames[] = { "Undefined", "DG.EVNT", @@@{ +my $keyno = 2; selectType $event '_common_'; for ($event->getFieldsOrdered) { my $f = selectField $event $_; @@ -75,10 +95,11 @@ for ($event->getFieldsOrdered) { my $fnu = uc $fn; my $c = $f->{comment}; if (hasAlias $f 'ULM') { - gen "\t\"$fnu\",\n"; + gen "\t\"$fnu\", /* $keyno */\n"; } else { - gen "\t\"DG.$fnu\",\n"; + gen "\t\"DG.$fnu\", /* $keyno */\n"; } + $keyno++; } for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } $event->getTypes) { @@ -87,7 +108,8 @@ for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } for ($event->getFieldsOrdered) { my $f = selectField $event $_; my $fnu = uc $f->{name}; - gen "\t\"DG.$tu.$fnu\",\n"; + gen "\t\"DG.$tu.$fnu\", /* $keyno */\n"; + $keyno++; } } @@@} diff --git a/org.glite.lb.common/src/events_parse.c.T b/org.glite.lb.common/src/events_parse.c.T index 79caa68..40f92b5 100644 --- a/org.glite.lb.common/src/events_parse.c.T +++ b/org.glite.lb.common/src/events_parse.c.T @@ -146,7 +146,7 @@ for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } my $c = "$t".ucfirst(${fn}); gen "\tthis->$tl.$fn = edg_wll_StringTo${c}(value);"; } else { - gen "\t"; + gen "\tif(strlen(value) > 0) "; gen $f->fromString('value',"this->$tl.$fn"); } gen "\n".$indent.$indent."break;\n"; @@ -339,7 +339,7 @@ clean: */ #define MISSING(m_key) { \ char *k = edg_wll_KeyNameToString(m_key); \ - sprintf(err_desc,"Message incomplete, missing key %s.", k); \ + sprintf(err_desc,"Message incomplete, missing or empty field %s.", k); \ free(k); \ ret=edg_wll_SetError(context,EDG_WLL_ERROR_PARSE_MSG_INCOMPLETE,err_desc); \ goto end; } diff --git a/org.glite.lb.common/src/il_log.c b/org.glite.lb.common/src/il_log.c index e3682a3..6e96007 100644 --- a/org.glite.lb.common/src/il_log.c +++ b/org.glite.lb.common/src/il_log.c @@ -24,7 +24,7 @@ il_log(int level, char *fmt, ...) } if(level <= LOG_ERR) { - openlog("edg-wl-interlogd", LOG_PID | LOG_CONS, LOG_DAEMON); + openlog(NULL, LOG_PID | LOG_CONS, LOG_DAEMON); syslog(level, "%s", err_text); closelog(); } diff --git a/org.glite.lb.common/src/mini_http.c b/org.glite.lb.common/src/mini_http.c index 6e803cf..c299ec9 100644 --- a/org.glite.lb.common/src/mini_http.c +++ b/org.glite.lb.common/src/mini_http.c @@ -50,7 +50,7 @@ edg_wll_ErrorCode edg_wll_http_recv(edg_wll_Context ctx,char **firstOut,char *** case EDG_WLL_GSS_OK: break; case EDG_WLL_GSS_ERROR_GSS: - edg_wll_SetErrorGss(ctx, "receving HTTP request", &gss_code); + edg_wll_SetErrorGss(ctx, "receving HTTP request/response", &gss_code); goto error; case EDG_WLL_GSS_ERROR_ERRNO: if (errno == ECONNRESET) errno = ENOTCONN; diff --git a/org.glite.lb.common/src/xml_parse.c.T b/org.glite.lb.common/src/xml_parse.c.T index c6211f8..1cde8fd 100644 --- a/org.glite.lb.common/src/xml_parse.c.T +++ b/org.glite.lb.common/src/xml_parse.c.T @@ -218,7 +218,7 @@ static void startQueryEvents(void *data, const char *el, const char **attr) if (!attr[0] || !attr[1]) { unexpError() break;} if (strcmp(attr[0],"name")) { unexpError() break;} if ( (XMLCtx->eventCode = edg_wll_StringToEvent((char *) attr[1])) - == EDG_WLL_EVENT_UNDEF ) { unexpError() break;} + == EDG_WLL_EVENT_UNDEF ) { unexpWarning() } XMLCtx->eventsOutGlobal = realloc(XMLCtx->eventsOutGlobal, (XMLCtx->position+1)*sizeof(*XMLCtx->eventsOutGlobal)); if (!XMLCtx->eventsOutGlobal) { edg_wll_SetError(XMLCtx->ctx, ENOMEM, NULL); unexpError() return; } @@ -845,6 +845,13 @@ static void endQueryEvents(void *data, const char *el UNUSED_VAR) edg_wll_freeBuf(XMLCtx); } break; + case 2: + /* skip events of unknown type */ + if (XMLCtx->eventCode == EDG_WLL_EVENT_UNDEF) { + edg_wll_FreeEvent(&(XMLCtx->eventsOutGlobal)[XMLCtx->position]); + XMLCtx->position--; + } + /* fallthough */ default: if (XMLCtx->char_buf) { unexpWarning() diff --git a/org.glite.lb.common/test/parse.cpp.T b/org.glite.lb.common/test/parse.cpp.T index df6c2aa..5211cb2 100644 --- a/org.glite.lb.common/test/parse.cpp.T +++ b/org.glite.lb.common/test/parse.cpp.T @@ -9,8 +9,6 @@ class EventParseTest: public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(EventParseTest); - CPPUNIT_TEST(regJob); -/* @@@{ for my $e ($event->getTypesOrdered) { my $u = lcfirst $e; @@ -20,12 +18,9 @@ class EventParseTest: public CppUnit::TestFixture gen "\tCPPUNIT_TEST($u);\n"; } @@@} -*/ CPPUNIT_TEST_SUITE_END(); public: - void regJob(); -/* @@@{ for my $e ($event->getTypesOrdered) { my $u = lcfirst $e; @@ -35,23 +30,25 @@ public: gen "\tvoid $u();\n"; } @@@} -*/ }; -void EventParseTest::regJob() -{ - edg_wll_Context ctx; - edg_wll_Event *e1,*e2; - char *line,*et,*ed; +@@@{ + for my $e ($event->getTypesOrdered) { + my $l = lcfirst $e; + if ($l =~ m/^pBS/) { $l = ucfirst $l; } + if ($l =~ m/^condor/) { $l = ucfirst $l; } + my $u = uc $e; + my $c = getTypeComment $event $e; + gen qq{ +void EventParseTest::$l() +\{ + edg_wll_Context ctx; + edg_wll_Event *e1,*e2; + char *line,*et,*ed; edg_wll_InitContext(&ctx); - e1 = edg_wll_InitEvent(EDG_WLL_EVENT_REGJOB); - - e1->regJob.jdl = strdup("very long job = \"blabla\" \\\\ \n hugh\t;"); - e1->regJob.ns = strdup("ns address"); - e1->regJob.jobtype = EDG_WLL_REGJOB_SIMPLE; - e1->regJob.seed = strdup(""); + e1 = edg_wll_InitEvent(EDG_WLL_EVENT_$u); gettimeofday(&e1->any.timestamp,NULL); @@ -64,19 +61,10 @@ void EventParseTest::regJob() e1->any.source = EDG_WLL_SOURCE_USER_INTERFACE; e1->any.src_instance = strdup(""); - line = edg_wll_UnparseEvent(ctx,e1); - std::cerr << line << std::endl; - - if (!line) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_UnparseEvent():") + et + " " + ed, line); - } - - if (edg_wll_ParseEvent(ctx,line,&e2)) { - edg_wll_Error(ctx,&et,&ed); - CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_ParseEvent():") + et + " " + ed, 0); - } +}; +/* TODO: merge */ +<<<<<<< parse.cpp.T if ((edg_wll_CompareEvents(ctx,e1,e2))) { edg_wll_Error(ctx,&et,&ed); CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_CompareEvents():") + et + " " + ed, 0); @@ -102,23 +90,39 @@ void EventParseTest::$l(){ "; selectType $event '_common_'; +======= + selectType $event "$e"; +>>>>>>> 1.8.2.4 for ($event->getFieldsOrdered) { my $f = selectField $event $_; my $fn = getName $f; - my $value = getDefaultTestValue $f; + if (!$f->{codes}) { - if (!$f->hasAlias('ULM')) { - my $fu = uc $fn; - gen "\te1->any.$fn = $value;\n"; -# gen "\tif (". $f->isNULL("e1->any.$fn") .") MISSING(EDG_WLL\_COMMON\_$fu)\n"; - } else { - my $fa = $f->getName('ULM'); - my $fu = uc $fa; -# gen "\tif (". $f->isNULL("e1->any.$fn") .") MISSING(ULM\_$fu)\n"; + my $value = ''; +# $value = "e1->$l.$fn = value;"; +# $value = $f->fromString('value',"e1->$l.$fn"); + if (($f->{type} eq "int") || ($f->{type} eq "port")) { + $value = "e1->$l.$fn = 654;"; + } elsif (($f->{type} eq "float") || ($f->{type} eq "double")) { + $value = "e1->$l.$fn = 3.1415;"; + } elsif ($f->{type} eq "string") { + $value = "e1->$l.$fn = strdup(\"teststring\");"; + } elsif ($f->{type} eq "logsrc") { + $value = "e1->$l.$fn = EDG_WLL_SOURCE_APPLICATION;"; + } elsif ($f->{type} eq "jobid") { + $value = "edg_wlc_JobIdParse(\"https://some.host:1234/x67qr549qc\",&e1->$l.$fn);"; + } elsif ($f->{type} eq "notifid") { + $value = "edg_wll_NotifIdParse(\"https://some.host:1234/NOTIF:x67qr549qc\",&e1->$l.$fn);"; + } else { + gen "% FIXME: unknown type $f->{type} for $fn \n"; } + gen "\t$value\n"; } } gen ' + line = edg_wll_UnparseEvent(ctx,e1); +// std::cerr << line << std::endl; + if (!line) { edg_wll_Error(ctx,&et,&ed); CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_UnparseEvent():") + et + " " + ed, line); @@ -134,12 +138,10 @@ void EventParseTest::$l(){ CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_CompareEvents():") + et + " " + ed, 0); } } - '; } @@@} -*/ CPPUNIT_TEST_SUITE_REGISTRATION( EventParseTest ); -- 1.8.2.3