X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=SimpleServer.xs;h=579ff91b3b71744c0673babf4f1ce475457790bf;hb=b88f2f7ab4c8c08d1a4552c05b52264b7b3e5ee4;hp=859af5ca31ed29cbcfb1d323b8c2ec9080056ae1;hpb=5fb0dad3f05f5110f22c8027824ae3562c5c522d;p=simpleserver-moved-to-github.git diff --git a/SimpleServer.xs b/SimpleServer.xs index 859af5c..579ff91 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -1,5 +1,5 @@ /* - * $Id: SimpleServer.xs,v 1.30 2004-06-05 23:09:04 adam Exp $ + * $Id: SimpleServer.xs,v 1.35 2005-11-09 09:35:47 adam Exp $ * ---------------------------------------------------------------------- * * Copyright (c) 2000-2004, Index Data. @@ -103,18 +103,20 @@ CV * simpleserver_sv2cv(SV *handler) { } /* debugging routine to check for destruction of Perl interpreters */ -#if 1 -int tst_clones(void) +#ifdef USE_ITHREADS +void tst_clones(void) { int i; PerlInterpreter *parent = PERL_GET_CONTEXT; - for (i = 0; i<500; i++) + for (i = 0; i<5000; i++) { PerlInterpreter *perl_interp; + PERL_SET_CONTEXT(parent); PL_perl_destruct_level = 2; - perl_interp = perl_clone(parent, 0); + perl_interp = perl_clone(parent, CLONEf_CLONE_HOST); PL_perl_destruct_level = 2; + PERL_SET_CONTEXT(perl_interp); perl_destruct(perl_interp); perl_free(perl_interp); } @@ -136,7 +138,7 @@ int simpleserver_clone(void) { if (!current) { PerlInterpreter *perl_interp; PERL_SET_CONTEXT( root_perl_context ); - perl_interp = perl_clone(root_perl_context, 0); + perl_interp = perl_clone(root_perl_context, CLONEf_CLONE_HOST); PERL_SET_CONTEXT( perl_interp ); } } @@ -356,7 +358,7 @@ void fatal(char *fmt, ...) { va_list ap; - fprintf(stderr, "FATAL (yazwrap): "); + fprintf(stderr, "FATAL (SimpleServer): "); va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); @@ -439,8 +441,21 @@ static SV *rpn2perl(Z_RPNStructure *s) case Z_RPNStructure_simple: { Z_Operand *o = s->u.simple; Z_AttributesPlusTerm *at; + if (o->which == Z_Operand_resultSetId) { + /* This code causes a SIGBUS on my machine, and I have no + idea why. It seems as clear as day to me */ + char *rsid = (char*) o->u.resultSetId; + printf("Encoding resultSetId '%s'\n", rsid); + sv = newObject("Net::Z3950::RPN::RSID", (SV*) (hv = newHV())); + printf("Made sv=0x%lx, hv=0x%lx\n", + (unsigned long) sv ,(unsigned long) hv); + SV *sv2 = newSVpv(rsid, strlen(rsid)); + setMember(hv, "id", sv2); + printf("Set hv{id} to 0x%lx\n", (unsigned long) sv2); + return sv; + } if (o->which != Z_Operand_APT) - fatal("can't handle RPN simples other than APT"); + fatal("can't handle RPN simples other than APT and RSID"); at = o->u.attributesPlusTerm; if (at->term->which != Z_Term_general) fatal("can't handle RPN terms other than general"); @@ -1299,7 +1314,8 @@ void bend_close(void *handle) sv_free((SV*) href); } - sv_free(zhandle->handle); + else + sv_free(zhandle->handle); PUTBACK; FREETMPS; LEAVE; @@ -1315,6 +1331,9 @@ void bend_close(void *handle) MODULE = Net::Z3950::SimpleServer PACKAGE = Net::Z3950::SimpleServer +PROTOTYPES: DISABLE + + void set_init_handler(arg) SV *arg @@ -1422,3 +1441,11 @@ ScanPartial() RETVAL +void +yazlog(arg) + SV *arg + CODE: + STRLEN len; + char *ptr; + ptr = SvPV(arg, len); + yaz_log(YLOG_LOG, "%.*s", len, ptr);