diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-02-16 17:42:46 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-02-16 17:42:46 +0000 |
commit | 880f421fc30003d1626429e8796d43b91d71cab9 (patch) | |
tree | dd3aff8b9397dd9177ed24a32d4e6fd2f841ebdd /sunrpc/rpc_svcout.c | |
parent | f565518e7e393419f99457792971ce71215d02cc (diff) | |
download | glibc-880f421fc30003d1626429e8796d43b91d71cab9.zip glibc-880f421fc30003d1626429e8796d43b91d71cab9.tar.gz glibc-880f421fc30003d1626429e8796d43b91d71cab9.tar.bz2 |
Update.
1998-02-16 17:33 Ulrich Drepper <drepper@cygnus.com>
* elf/rtld.c (dl_main): Recognize --library-path parameter and
pass value (or NULL) to _dl_init_paths.
* elf/dl-load.c (_dl_init_paths): Change to take one parameter,
replacing local variable llp. If llp is NULL examine LD_LIBRARY_PATH
environment variable.
* elf/link.h: Change prototype for _dl_init_paths.
* elf/dl-support.c: Pass NULL in _dl_init_paths call.
* localedata/Makefile (distribute): Add test files.
1998-02-17 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* localedata/tests/{test1.cm, test2.cm, test3.cm, test4.cm,
test1.def, test2.def, test3.def, test4.def}: Simple input files
for localedef. Contributed by Yung-Ching Hsiao
<yhsiao@cae.wisc.edu>.
* localedata/Makefile (tests): Call tst-locale.sh.
* localedata/tst-locale.sh: New file, regression tests for some
localedef problems.
1998-02-15 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/nss_nisplus/nisplus-alias.c: Use __stpncpy.
* nis/nss_nisplus/nisplus-hosts.c: Make sure buffer is always NUL
terminated.
* nis/nss_nisplus/nisplus-network.c: Likewise.
* nis/nss_nisplus/nisplus-proto.c: Likewise.
* nis/nss_nisplus/nisplus-rpc.c: Likewise.
* nis/nss_nisplus/nisplus-service.c: Likewise.
Add more changes from TI-RPC 2.3 for rpcgen to fix include/C++ bug
and support generating thread safe RPC code.
* sunrpc/rpc_main.c: Add changes.
* sunrpc/rpc_clntout.c: Likewise.
* sunrpc/rpc_cout.c: Likewise.
* sunrpc/rpc_hout.c: Likewise.
* sunrpc/rpc_parse.c: Likewise.
* sunrpc/rpc_sample.c: Likewise.
* sunrpc/rpc_scan.c: Likewise.
* sunrpc/rpc_svcout.c: Likewise.
* sunrpc/rpc_util.c: Likewise.
* sunrpc/rpc_util.h: Add new structs and prototypes.
* sunrpc/proto.h: Remove prototypes for static functions.
1998-02-15 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* locale/programs/ld-messages.c (messages_finish): Don't skip
error checking when being quiet.
* locale/programs/ld-ctype.c (ctype_finish): Likewise.
(set_class_defaults): Likewise.
* locale/programs/charmap.c (parse_charmap): Likewise.
* locale/programs/ld-collate.c (collate_finish): Likewise.
* locale/programs/ld-monetary.c (monetary_finish): Likewise.
* locale/programs/ld-time.c (time_finish): Likewise.
* locale/programs/locfile.c (write_locale_data): Likewise.
* locale/programs/ld-ctype.c (ctype_class_to): Silently ignore
unknown characters and empty ranges.
* locale/programs/ld-collate.c (collate_order_elem): When
processing an ellipsis properly form a linked list in the result
table, fix typo when allocating ordering array.
[PR libc/419]
1998-02-13 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* elf/Makefile (ld-map): Define.
(rtld-ldscript): Define. Change all `$(objpfx)rtld-ldscript' to
`$(rtld-ldscript)'.
($(objpfx)ld.so): Combine the two versions of this rule. Depend
on $(ld-map).
(rtld-link): Combine the two versions of this definition. Fixed
to make it work when no symbol versioning is used.
1998-02-16 Ulrich Drepper <drepper@cygnus.com>
* Makeconfig (build-program-cmd): Use --library-path parameter to
ld.so instead of environment variable.
* sunrpc/Makefile (rpcgen-cmd): Don't use -$ parameter.
* sunrpc/rpc_main.c: Remove support for -$$ option again.
1998-02-16 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* Make-dist: Respect with-cvs setting.
* MakeTAGS (all-pot): Likewise.
* sysdeps/sparc/sparc32/Makefile: Likewise.
* sysdeps/mach/hurd/Makefile: Likewise.
* stdlib/Makefile: Likewise.
* posix/Makefile: Likewise.
* intl/Makefile: Likewise.
* po/Makefile (linguas): Likewise
Diffstat (limited to 'sunrpc/rpc_svcout.c')
-rw-r--r-- | sunrpc/rpc_svcout.c | 303 |
1 files changed, 211 insertions, 92 deletions
diff --git a/sunrpc/rpc_svcout.c b/sunrpc/rpc_svcout.c index 75eb695..9b5f1dd 100644 --- a/sunrpc/rpc_svcout.c +++ b/sunrpc/rpc_svcout.c @@ -48,6 +48,7 @@ static const char TRANSP[] = "transp"; static const char ARG[] = "argument"; static const char RESULT[] = "result"; static const char ROUTINE[] = "local"; +static char RETVAL[] = "retval"; char _errbuf[256]; /* For all messages */ @@ -103,12 +104,31 @@ write_most (const char *infile /* our name */ , int netflag, int nomain) #endif f_print (fout, "%s int _rpcpmstart;", var_type); f_print (fout, "\t\t/* Started by a port monitor ? */\n"); - f_print (fout, "%s int _rpcfdtype;", var_type); - f_print (fout, "\t\t/* Whether Stream or Datagram ? */\n"); + if (!tirpcflag) + { + f_print (fout, "%s int _rpcfdtype;", var_type); + f_print (fout, "\t\t/* Whether Stream or Datagram ? */\n"); + } if (timerflag) { +#if 0 f_print (fout, "%s int _rpcsvcdirty;", var_type); f_print (fout, "\t/* Still serving ? */\n"); +#else + f_print(fout, " /* States a server can be in wrt request */\n\n"); + f_print(fout, "#define\t_IDLE 0\n"); + f_print(fout, "#define\t_SERVED 1\n"); + f_print(fout, "#define\t_SERVING 2\n\n"); + f_print(fout, "static int _rpcsvcstate = _IDLE;"); + f_print(fout, "\t /* Set when a request is serviced */\n"); + + if (mtflag) + { + f_print (fout, "mutex_t _svcstate_lock;"); + f_print (fout, + "\t\t\t/* Mutex lock for variable_rpcsvcstate */\n"); + } +#endif } write_svc_aux (nomain); } @@ -120,10 +140,10 @@ write_most (const char *infile /* our name */ , int netflag, int nomain) #ifdef __GNU_LIBRARY__ if (Cflag) - f_print (fout, "\nint\nmain(int argc, char **argv)\n"); + f_print (fout, "\nint\nmain (int argc, char **argv)\n"); else { - f_print (fout, "\nint\nmain(argc, argv)\n"); + f_print (fout, "\nint\nmain (argc, argv)\n"); f_print (fout, "\tint argc;\n"); f_print (fout, "\tchar **argv;\n"); } @@ -147,7 +167,12 @@ write_most (const char *infile /* our name */ , int netflag, int nomain) f_print (fout, "\tpid_t pid;\n"); f_print (fout, "\tint i;\n"); f_print (fout, "\tchar mname[FMNAMESZ + 1];\n\n"); - write_pm_most (infile, netflag); + + if (mtflag & timerflag) + f_print (fout, + "\tmutex_init (&_svcstate_lock, USYNC_THREAD, NULL);\n"); + + write_pm_most (infile, netflag); f_print (fout, "\telse {\n"); write_rpc_svc_fg (infile, "\t\t"); f_print (fout, "\t}\n"); @@ -180,19 +205,19 @@ write_netid_register (const char *transp) sp = ""; f_print (fout, "\n"); - f_print (fout, "%s\tnconf = getnetconfigent(\"%s\");\n", sp, transp); + f_print (fout, "%s\tnconf = getnetconfigent (\"%s\");\n", sp, transp); f_print (fout, "%s\tif (nconf == NULL) {\n", sp); (void) sprintf (_errbuf, "cannot find %s netid.", transp); sprintf (tmpbuf, "%s\t\t", sp); print_err_message (tmpbuf); - f_print (fout, "%s\t\texit(1);\n", sp); + f_print (fout, "%s\t\texit (1);\n", sp); f_print (fout, "%s\t}\n", sp); - f_print (fout, "%s\t%s = svc_tli_create(RPC_ANYFD, nconf, 0, 0, 0);\n", + f_print (fout, "%s\t%s = svc_tli_create (RPC_ANYFD, nconf, 0, 0, 0);\n", sp, TRANSP /*, transp *//* ?!?... */ ); f_print (fout, "%s\tif (%s == NULL) {\n", sp, TRANSP); - (void) sprintf (_errbuf, "cannot create %s service.", transp); + sprintf (_errbuf, "cannot create %s service.", transp); print_err_message (tmpbuf); - f_print (fout, "%s\t\texit(1);\n", sp); + f_print (fout, "%s\t\texit (1);\n", sp); f_print (fout, "%s\t}\n", sp); for (l = defined; l != NULL; l = l->next) @@ -204,22 +229,20 @@ write_netid_register (const char *transp) } for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print (fout, - "%s\t(void) rpcb_unset(%s, %s, nconf);\n", + f_print (fout, "%s\t(void) rpcb_unset (%s, %s, nconf);\n", sp, def->def_name, vp->vers_name); - f_print (fout, - "%s\tif (!svc_reg(%s, %s, %s, ", + f_print (fout, "%s\tif (!svc_reg (%s, %s, %s, ", sp, TRANSP, def->def_name, vp->vers_name); pvname (def->def_name, vp->vers_num); f_print (fout, ", nconf)) {\n"); (void) sprintf (_errbuf, "unable to register (%s, %s, %s).", def->def_name, vp->vers_name, transp); print_err_message (tmpbuf); - f_print (fout, "%s\t\texit(1);\n", sp); + f_print (fout, "%s\t\texit (1);\n", sp); f_print (fout, "%s\t}\n", sp); } } - f_print (fout, "%s\tfreenetconfigent(nconf);\n", sp); + f_print (fout, "%s\tfreenetconfigent (nconf);\n", sp); } /* @@ -241,7 +264,7 @@ write_nettype_register (const char *transp) } for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print (fout, "\tif (!svc_create("); + f_print (fout, "\tif (!svc_create ("); pvname (def->def_name, vp->vers_num); f_print (fout, ", %s, %s, \"%s\")) {\n ", def->def_name, vp->vers_name, transp); @@ -249,7 +272,7 @@ write_nettype_register (const char *transp) "unable to create (%s, %s) for %s.", def->def_name, vp->vers_name, transp); print_err_message ("\t\t"); - f_print (fout, "\t\texit(1);\n"); + f_print (fout, "\t\texit (1);\n"); f_print (fout, "\t}\n"); } } @@ -267,22 +290,22 @@ write_rest (void) f_print (fout, "\tif (%s == (SVCXPRT *)NULL) {\n", TRANSP); (void) sprintf (_errbuf, "could not create a handle"); print_err_message ("\t\t"); - f_print (fout, "\t\texit(1);\n"); + f_print (fout, "\t\texit (1);\n"); f_print (fout, "\t}\n"); if (timerflag) { f_print (fout, "\tif (_rpcpmstart) {\n"); f_print (fout, - "\t\t(void) signal(SIGALRM, %s closedown);\n", + "\t\t(void) signal (SIGALRM, %s closedown);\n", Cflag ? "(SIG_PF)" : "(void(*)())"); - f_print (fout, "\t\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); + f_print (fout, "\t\t(void) alarm (_RPCSVC_CLOSEDOWN);\n"); f_print (fout, "\t}\n"); } } - f_print (fout, "\tsvc_run();\n"); + f_print (fout, "\tsvc_run ();\n"); (void) sprintf (_errbuf, "svc_run returned"); print_err_message ("\t"); - f_print (fout, "\texit(1);\n"); + f_print (fout, "\texit (1);\n"); f_print (fout, "\t/* NOTREACHED */\n"); f_print (fout, "}\n"); } @@ -312,8 +335,6 @@ write_programs (const char *storage) write_program (def, storage); } } - - } /* write out definition of internal function (e.g. _printmsg_1(...)) @@ -333,25 +354,37 @@ write_real_program (const definition * def) { for (proc = vp->procs; proc != NULL; proc = proc->next) { - f_print (fout, "\n"); - internal_proctype (proc); + fprintf (fout, "\n"); + if (!mtflag) + internal_proctype (proc); + else + f_print (fout, "int"); f_print (fout, "\n_"); pvname (proc->proc_name, vp->vers_num); if (Cflag) { - f_print (fout, "("); + f_print (fout, " ("); /* arg name */ if (proc->arg_num > 1) f_print (fout, proc->args.argname); else ptype (proc->args.decls->decl.prefix, proc->args.decls->decl.type, 0); - f_print (fout, " *argp, struct svc_req *%s)\n", - RQSTP); + if (mtflag) + { + f_print(fout, " *argp, void *%s, struct svc_req *%s)\n", + RESULT, RQSTP); + } + else + f_print (fout, " *argp, struct svc_req *%s)\n", + RQSTP); } else { - f_print (fout, "(argp, %s)\n", RQSTP); + if (mtflag) + f_print(fout, " (argp, %s, %s)\n", RESULT, RQSTP); + else + f_print (fout, " (argp, %s)\n", RQSTP); /* arg name */ if (proc->arg_num > 1) f_print (fout, "\t%s *argp;\n", proc->args.argname); @@ -366,8 +399,8 @@ write_real_program (const definition * def) } f_print (fout, "{\n"); - f_print (fout, "\treturn("); - if (Cflag) + f_print (fout, "\treturn ("); + if (Cflag || mtflag) pvname_svc (proc->proc_name, vp->vers_num); else pvname (proc->proc_name, vp->vers_num); @@ -451,33 +484,65 @@ write_program (const definition * def, const char *storage) f_print (fout, "\t\tint fill;\n"); } f_print (fout, "\t} %s;\n", ARG); - f_print (fout, "\tchar *%s;\n", RESULT); + if (mtflag) + { + f_print(fout, "\tunion {\n"); + for (proc = vp->procs; proc != NULL; proc = proc->next) + if (!streq (proc->res_type, "void")) + { + f_print(fout, "\t\t"); + ptype(proc->res_prefix, proc->res_type, 0); + pvname(proc->proc_name, vp->vers_num); + f_print(fout, "_res;\n"); + } + f_print(fout, "\t} %s;\n", RESULT); + f_print(fout, "\tbool_t %s;\n", RETVAL); + + } else + f_print (fout, "\tchar *%s;\n", RESULT); if (Cflag) { f_print (fout, "\txdrproc_t xdr_%s, xdr_%s;\n", ARG, RESULT); - f_print (fout, - "\tchar *(*%s)(char *, struct svc_req *);\n", - ROUTINE); + if (mtflag) + f_print(fout, + "\tbool_t (*%s)(char *, void *, struct svc_req *);\n", + ROUTINE); + else + f_print (fout, "\tchar *(*%s)(char *, struct svc_req *);\n", + ROUTINE); } else { f_print (fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT); - f_print (fout, "\tchar *(*%s)();\n", ROUTINE); + if (mtflag) + f_print(fout, "\tbool_t (*%s)();\n", ROUTINE); + else + f_print (fout, "\tchar *(*%s)();\n", ROUTINE); } - f_print (fout, "\n"); if (timerflag) +#if 0 f_print (fout, "\t_rpcsvcdirty = 1;\n"); +#else + { + if (mtflag) + f_print(fout, "\tmutex_lock(&_svcstate_lock);\n"); + f_print(fout, "\t_rpcsvcstate = _SERVING;\n"); + if (mtflag) + f_print(fout, "\tmutex_unlock(&_svcstate_lock);\n"); + } +#endif + f_print (fout, "\tswitch (%s->rq_proc) {\n", RQSTP); if (!nullproc (vp->procs)) { f_print (fout, "\tcase NULLPROC:\n"); f_print (fout, Cflag - ? "\t\t(void) svc_sendreply(%s, (xdrproc_t) xdr_void, (char *)NULL);\n" - : "\t\t(void) svc_sendreply(%s, xdr_void, (char *)NULL);\n", + ? "\t\t(void) svc_sendreply (%s, (xdrproc_t) xdr_void, (char *)NULL);\n" + : "\t\t(void) svc_sendreply (%s, xdr_void, (char *)NULL);\n", TRANSP); print_return ("\t\t"); f_print (fout, "\n"); @@ -495,17 +560,27 @@ write_program (const definition * def, const char *storage) } p_xdrfunc (RESULT, proc->res_type); if (Cflag) - f_print (fout, - "\t\t%s = (char *(*)(char *, struct svc_req *)) ", - ROUTINE); + { + if (mtflag) + f_print(fout, + "\t\t%s = (bool_t (*) (char *, void *, struct svc_req *))", + ROUTINE); + else + f_print (fout, + "\t\t%s = (char *(*)(char *, struct svc_req *)) ", + ROUTINE); + } else - f_print (fout, "\t\t%s = (char *(*)()) ", ROUTINE); + if (mtflag) + f_print(fout, "\t\t%s = (bool_t (*)()) ", ROUTINE); + else + f_print (fout, "\t\t%s = (char *(*)()) ", ROUTINE); if (newstyle) { /* new style: calls internal routine */ f_print (fout, "_"); } - if (Cflag && !newstyle) + if ((Cflag || mtflag) && !newstyle) pvname_svc (proc->proc_name, vp->vers_num); else pvname (proc->proc_name, vp->vers_num); @@ -517,7 +592,7 @@ write_program (const definition * def, const char *storage) print_return ("\t\t"); f_print (fout, "\t}\n"); - f_print (fout, "\t(void) memset((char *)&%s, 0, sizeof (%s));\n", ARG, ARG); + f_print (fout, "\tmemset ((char *)&%s, 0, sizeof (%s));\n", ARG, ARG); if (Cflag) printif ("getargs", TRANSP, "(caddr_t) &", ARG); else @@ -526,15 +601,29 @@ write_program (const definition * def, const char *storage) print_return ("\t\t"); f_print (fout, "\t}\n"); - if (Cflag) - f_print (fout, "\t%s = (*%s)((char *)&%s, %s);\n", - RESULT, ROUTINE, ARG, RQSTP); + if (!mtflag) + if (Cflag) + f_print (fout, "\t%s = (*%s)((char *)&%s, %s);\n", + RESULT, ROUTINE, ARG, RQSTP); + else + f_print (fout, "\t%s = (*%s)(&%s, %s);\n", + RESULT, ROUTINE, ARG, RQSTP); else - f_print (fout, "\t%s = (*%s)(&%s, %s);\n", - RESULT, ROUTINE, ARG, RQSTP); - f_print (fout, - "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n", - RESULT, TRANSP, RESULT, RESULT); + if (Cflag) + f_print(fout, "\t%s = (bool_t) (*%s)((char *)&%s, (void *)&%s, %s);\n", + RETVAL, ROUTINE, ARG, RESULT, RQSTP); + else + f_print(fout, "\t%s = (bool_t) (*%s)(&%s, &%s, %s);\n", + RETVAL, ROUTINE, ARG, RESULT, RQSTP); + if (mtflag) + f_print(fout, + "\tif (%s > 0 && !svc_sendreply(%s, xdr_%s, (char *)&%s)) {\n", + RETVAL, TRANSP, RESULT, RESULT); + else + f_print(fout, + "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n", + RESULT, TRANSP, RESULT, RESULT); + printerr ("systemerr", TRANSP); f_print (fout, "\t}\n"); @@ -542,10 +631,22 @@ write_program (const definition * def, const char *storage) printif ("freeargs", TRANSP, "(caddr_t) &", ARG); else printif ("freeargs", TRANSP, "&", ARG); - (void) sprintf (_errbuf, "unable to free arguments"); + + sprintf (_errbuf, "unable to free arguments"); print_err_message ("\t\t"); - f_print (fout, "\t\texit(1);\n"); + f_print (fout, "\t\texit (1);\n"); f_print (fout, "\t}\n"); + /* print out free routine */ + if (mtflag) + { + f_print(fout,"\tif (!"); + pvname(def->def_name, vp->vers_num); + f_print(fout,"_freeresult (%s, xdr_%s, (caddr_t) &%s))\n", + TRANSP, RESULT, RESULT); + (void) sprintf(_errbuf, "unable to free results"); + print_err_message("\t\t"); + f_print(fout, "\n"); + } print_return ("\t"); f_print (fout, "}\n"); } @@ -554,14 +655,14 @@ write_program (const definition * def, const char *storage) static void printerr (const char *err, const char *transp) { - f_print (fout, "\t\tsvcerr_%s(%s);\n", err, transp); + f_print (fout, "\t\tsvcerr_%s (%s);\n", err, transp); } static void printif (const char *proc, const char *transp, const char *prefix, const char *arg) { - f_print (fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", + f_print (fout, "\tif (!svc_%s (%s, xdr_%s, %s%s)) {\n", proc, transp, arg, prefix, arg); } @@ -572,10 +673,10 @@ nullproc (const proc_list * proc) { if (streq (proc->proc_num, "0")) { - return (1); + return 1; } } - return (0); + return 0; } static void @@ -588,13 +689,13 @@ write_inetmost (const char *infile) f_print (fout, "\tint asize = sizeof (saddr);\n"); f_print (fout, "\n"); f_print (fout, - "\tif (getsockname(0, (struct sockaddr *)&saddr, &asize) == 0) {\n"); + "\tif (getsockname (0, (struct sockaddr *)&saddr, &asize) == 0) {\n"); f_print (fout, "\t\tint ssize = sizeof (int);\n\n"); f_print (fout, "\t\tif (saddr.sin_family != AF_INET)\n"); - f_print (fout, "\t\t\texit(1);\n"); - f_print (fout, "\t\tif (getsockopt(0, SOL_SOCKET, SO_TYPE,\n"); + f_print (fout, "\t\t\texit (1);\n"); + f_print (fout, "\t\tif (getsockopt (0, SOL_SOCKET, SO_TYPE,\n"); f_print (fout, "\t\t\t\t(char *)&_rpcfdtype, &ssize) == -1)\n"); - f_print (fout, "\t\t\texit(1);\n"); + f_print (fout, "\t\t\texit (1);\n"); f_print (fout, "\t\tsock = 0;\n"); f_print (fout, "\t\t_rpcpmstart = 1;\n"); f_print (fout, "\t\tproto = 0;\n"); @@ -610,11 +711,21 @@ static void print_return (const char *space) { if (exitnow) - f_print (fout, "%sexit(0);\n", space); + f_print (fout, "%sexit (0);\n", space); else { if (timerflag) - f_print (fout, "%s_rpcsvcdirty = 0;\n", space); + { +#if 0 + f_print (fout, "%s_rpcsvcdirty = 0;\n", space); +#else + if (mtflag) + f_print(fout, "%smutex_lock(&_svcstate_lock);\n", space); + f_print(fout, "%s_rpcsvcstate = _SERVED;\n", space); + if (mtflag) + f_print(fout, "%smutex_unlock(&_svcstate_lock);\n", space); +#endif + } f_print (fout, "%sreturn;\n", space); } } @@ -634,7 +745,7 @@ print_pmapunset (const char *space) for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { - f_print (fout, "%s(void) pmap_unset(%s, %s);\n", + f_print (fout, "%spmap_unset (%s, %s);\n", space, def->def_name, vp->vers_name); } } @@ -645,11 +756,11 @@ static void print_err_message (const char *space) { if (logflag) - f_print (fout, "%ssyslog(LOG_ERR, \"%s\");\n", space, _errbuf); + f_print (fout, "%ssyslog (LOG_ERR, \"%s\");\n", space, _errbuf); else if (inetdflag || pmflag) - f_print (fout, "%s_msgout(\"%s\");\n", space, _errbuf); + f_print (fout, "%s_msgout (\"%s\");\n", space, _errbuf); else - f_print (fout, "%sfprintf(stderr, \"%s\");\n", space, _errbuf); + f_print (fout, "%sfprintf (stderr, \"%s\");\n", space, _errbuf); } /* @@ -675,22 +786,22 @@ write_msg_out (void) f_print (fout, "static\n"); if (!Cflag) { - f_print (fout, "void _msgout(msg)\n"); + f_print (fout, "void _msgout (msg)\n"); f_print (fout, "\tchar *msg;\n"); } else { - f_print (fout, "void _msgout(char* msg)\n"); + f_print (fout, "void _msgout (char* msg)\n"); } f_print (fout, "{\n"); f_print (fout, "#ifdef RPC_SVC_FG\n"); if (inetdflag || pmflag) f_print (fout, "\tif (_rpcpmstart)\n"); - f_print (fout, "\t\tsyslog(LOG_ERR, msg);\n"); + f_print (fout, "\t\tsyslog (LOG_ERR, msg);\n"); f_print (fout, "\telse\n"); - f_print (fout, "\t\t(void) fprintf(stderr, \"%%s\\n\", msg);\n"); + f_print (fout, "\t\tfprintf (stderr, \"%%s\\n\", msg);\n"); f_print (fout, "#else\n"); - f_print (fout, "\tsyslog(LOG_ERR, msg);\n"); + f_print (fout, "\tsyslog (LOG_ERR, msg);\n"); f_print (fout, "#endif\n"); f_print (fout, "}\n"); } @@ -705,20 +816,23 @@ write_timeout_func (void) return; f_print (fout, "\n"); f_print (fout, "static void\n"); -#ifdef __GNU_LIBRARY__ if (Cflag) - f_print (fout, "closedown(int sig)\n"); + f_print (fout, "closedown (int sig)\n"); else - f_print (fout, "closedown(sig)\n\tint sig;\n"); -#else - f_print (fout, "closedown()\n"); -#endif + f_print (fout, "closedown (sig)\n\tint sig;\n"); f_print (fout, "{\n"); -#ifdef __GNU_LIBRARY__ - f_print (fout, "\t(void) signal(sig, %s closedown);\n", + +#if defined (__GNU_LIBRARY__) && 0 + f_print (fout, "\t(void) signal (sig, %s closedown);\n", Cflag ? "(SIG_PF)" : "(void(*)())"); #endif + if (mtflag) + f_print(fout, "\tmutex_lock(&_svcstate_lock);\n"); +#if 0 f_print (fout, "\tif (_rpcsvcdirty == 0) {\n"); +#else + f_print(fout, "\tif (_rpcsvcstate == _IDLE) {\n"); +#endif f_print (fout, "\t\textern fd_set svc_fdset;\n"); f_print (fout, "\t\tstatic int size;\n"); f_print (fout, "\t\tint i, openfd;\n"); @@ -731,15 +845,17 @@ write_timeout_func (void) { f_print (fout, "\n\t\tif (_rpcfdtype == SOCK_DGRAM)\n"); } - f_print (fout, "\t\t\texit(0);\n"); + f_print (fout, "\t\t\texit (0);\n"); f_print (fout, "\t\tif (size == 0) {\n"); if (tirpcflag) { f_print (fout, "\t\t\tstruct rlimit rl;\n\n"); f_print (fout, "\t\t\trl.rlim_max = 0;\n"); f_print (fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n"); - f_print (fout, "\t\t\tif ((size = rl.rlim_max) == 0)\n"); - f_print (fout, "\t\t\t\treturn;\n"); + f_print (fout, "\t\t\tif ((size = rl.rlim_max) == 0) {\n"); + if (mtflag) + f_print(fout, "\t\t\t\tmutex_unlock(&_svcstate_lock);\n"); + f_print (fout, "\t\t\t\treturn;\n\t\t\t}\n"); } else { @@ -750,9 +866,15 @@ write_timeout_func (void) f_print (fout, "\t\t\tif (FD_ISSET(i, &svc_fdset))\n"); f_print (fout, "\t\t\t\topenfd++;\n"); f_print (fout, "\t\tif (openfd <= 1)\n"); - f_print (fout, "\t\t\texit(0);\n"); + f_print (fout, "\t\t\texit (0);\n"); f_print (fout, "\t}\n"); - f_print (fout, "\t(void) alarm(_RPCSVC_CLOSEDOWN);\n"); + f_print(fout, "\tif (_rpcsvcstate == _SERVED)\n"); + f_print(fout, "\t\t_rpcsvcstate = _IDLE;\n\n"); + if (mtflag) + f_print(fout, "\tmutex_unlock(&_svcstate_lock);\n"); + f_print(fout, "\t(void) signal(SIGALRM, %s closedown);\n", + Cflag? "(SIG_PF)" : "(void(*)())"); + f_print (fout, "\talarm (_RPCSVC_CLOSEDOWN);\n"); f_print (fout, "}\n"); } @@ -915,9 +1037,6 @@ open_log_file (const char *infile, const char *sp) *s = '.'; } - - - /* * write a registration for the given transport for Inetd */ |