home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / WAIS / ir / server.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-02  |  17.5 KB  |  642 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE    
  2.    No guarantees or restrictions.  See the readme file for the full standard 
  3.    disclaimer.
  4.    5.29.90    Harry Morris, morris@think.com
  5. */
  6.  
  7. /* this file is a server process for a unix machine that takes input from 
  8.    standard in or from a socket and searches the local search engine on the 
  9.    unix box.
  10.    originally written by harry morris.
  11.    modified by brewster kahle. 7/90
  12.    6.xx.90    Brewster - initial implementation of stdio interface
  13.    7.xx.90    Patrick Bray - support for headers and forking processes
  14.    90.07.31    Ephraim - support for logging 
  15.  
  16.    91.03.03     Jonathan - set searchLog to log_out.
  17.    91.05.23    Jonathan - added fork process for indexer.
  18.                            Fixed version display so it exits.
  19.    91.05.25     Jonathan - added setuid.
  20.    
  21.    Tue Jul  9 12:11:02 1991 -- Michael Haberler mah@wu-wien.ac.at
  22.  
  23.                 Added semi-intelligent INFO database indexing (only done if
  24.         any of the .src files is newer than INFO.dct)
  25.         
  26.         Locking against multiple concurrent INFO rebuilds if 
  27.         running under inetd
  28.  
  29.         Use scandir() for directory operations
  30.  
  31.         Works under inetd as well as standalone. Here are my inetd.conf
  32.            entries (not the missing userid in the Ultrix inetd.conf!):
  33.  
  34.    hpux 7.0/800, Interactive/386 2.2.1:
  35.     z3950 stream tcp nowait root /usr/local/etc/waisserver waisserver -s \
  36.         -d /usr/logins/mah/wais-sources
  37.  
  38.    Ultrix 4.1:
  39.     z3950 stream tcp nowait /usr/local/etc/waisserver waisserver -s \
  40.         -d /usr/logins/mah/wais-sources
  41.  
  42.    Also, add the next line to /etc/services, and tickle your YP server:
  43.     z3950           210/tcp         # wide area information server (wais)
  44.  
  45.  to do:
  46.    - limit all requests to that directory is switch is set?
  47.    - make it so it can be a deamon in rc.local and inetd and a login process
  48.  */
  49.  
  50. #define SERVER_DATE "Fri Sep 13 1991"
  51.  
  52. #ifndef lint
  53. static char *RCSid = "$Header: /proj/wais/wais-8-b3/ir/RCS/server.c,v 1.22 91/09/13 15:55:14 brewster Exp $";
  54. #endif
  55.  
  56. #define INFO_DICT    "INFO.dct"
  57. #define LOCKFILE    "/tmp/INFO.lock" /* while re-indexing INFO */
  58. #define NAPTIME     1             /* seconds */
  59. #define MAXNAPTIME  60        /* wait up to a minute for indexer to finish */
  60.  
  61. #include "sockets.h"
  62. #include <sys/types.h>
  63. #include <sys/stat.h>
  64. #ifdef ultrix
  65. #include <sys/file.h>
  66. #else
  67. #ifdef USG
  68. #include <sys/fcntl.h>
  69. #else
  70. #include <sys/file.h>
  71. #endif
  72. #endif /* else ultrix */
  73. #ifdef SYSV            
  74. #define SIGCHLD SIGCLD
  75. #endif
  76. #include <signal.h>
  77. #include <string.h>
  78. #include "irdirent.h"
  79. #include "panic.h"
  80. #include "ustubs.h"
  81. #include "transprt.h"
  82. #include "wmessage.h"
  83. #include "ir.h"
  84. #include "wprot.h"
  85. #include "cutil.h"
  86. #include "futil.h"
  87. #include "irext.h"
  88.  
  89. /* to create the INFO index */
  90. #include "irtfiles.h"
  91. #include "irfiles.h"
  92. #include "irhash.h"
  93. #include "version.h"
  94.  
  95. #define BUFSZ 30000     /* size of our buffer */
  96. static long bufferSize = BUFSZ; /* how much we are using
  97.                                    (we get one of these per process) */
  98.  
  99. char *log_file_name = NULL;
  100.  
  101. FILE *logfile; /* the logfile */
  102.  
  103. /*---------------------------------------------------------------------------*/
  104.  
  105. #define TIMEOUT_LENGTH 36000 /* ten hour timeout. */
  106. #define IDLE_TIME "10 hours"
  107.  
  108. void
  109. serve_client(in,out, index_directory)
  110. FILE* in;
  111. FILE* out;
  112. char *index_directory;
  113.   char buf[BUFSZ];        /* contains the message and header */
  114.   char *bufPtr ;        /* points at the begining of the z3950 */
  115.   long size;            /* bytes in the z3950 message */
  116.   WAISMessage header;        /* for storing the header */
  117.   long i;
  118.   long bytesLeft;
  119.   struct itimerval new, old;
  120.   long nextChar;
  121.  
  122.   new.it_interval.tv_sec = 0;
  123.   new.it_interval.tv_usec = 0;
  124.   new.it_value.tv_sec = TIMEOUT_LENGTH;
  125.   new.it_value.tv_usec = 0;
  126.  
  127.   getitimer(ITIMER_REAL, &old);
  128.   while (TRUE)
  129.     {
  130.       /* try to read the header */
  131.       for (i = 0; i < HEADER_LENGTH; i++)
  132.     { 
  133.       setitimer(ITIMER_REAL, &new, NULL);
  134.       nextChar = fgetc(in);
  135.       if (nextChar == EOF)    /* my connection exited, so will I */
  136.         { 
  137.           return;
  138.         }
  139.       else
  140.         buf[i] = (char)nextChar;
  141.     }
  142.  
  143.       setitimer(ITIMER_REAL, &old, NULL);
  144.       /* parse the header */
  145.       readWAISPacketHeader(buf,&header);
  146.  
  147.       /* make sure we have the right version.  
  148.      If we dont, we dont know what to do. */
  149.       if (header.hdr_vers > HEADER_VERSION)
  150.     panic("Incompatable header versions (Current version: %d, supplied version: %d.", 
  151.           HEADER_VERSION, header.hdr_vers) ;
  152.  
  153.       /* determine the size of the z3950 message */
  154.       {
  155.     char length_array[11];
  156.     strncpy(length_array, header.msg_len, 10);
  157.     length_array[10] = '\0';
  158.     size = atol(length_array);
  159.       }
  160.  
  161.       /* set bufPtr to start the z3950 message */
  162.       bufPtr = buf + HEADER_LENGTH ;
  163.  
  164.       /* read the z3950 message */
  165.       for (i = 0; i < size ; i++) {
  166.     setitimer(ITIMER_REAL, &new, NULL);
  167.     buf[i + HEADER_LENGTH] = (char)fgetc(in) ;
  168.       }
  169.  
  170.       rewind(in);
  171.  
  172.       /* decode the z3950 if necessary */
  173.       transportDecode((long)header.encoding,bufPtr,&size);
  174.      
  175.       /* XXX handle compression options */
  176.  
  177.       /* process it the z3950 */
  178.       bytesLeft = bufferSize;
  179.  
  180.       size = interpret_buffer(bufPtr,size,bufPtr,bytesLeft,
  181.                   &bufferSize,(long)header.hdr_vers,
  182.                   index_directory); 
  183.  
  184.       /* re-encode the message if necessary */
  185.       transportCode((long)header.encoding,bufPtr,&size); 
  186.  
  187.       /* XXX handle compression options */
  188.  
  189.       /* write the new header */
  190.       writeWAISPacketHeader(buf,size,
  191.                 (long)header.msg_type,header.server,
  192.                 (long)header.compression,(long)header.encoding,
  193.                 (long)header.hdr_vers);
  194.  
  195.       /* write the whole response to the output file */
  196.       for (i = 0; i < size + HEADER_LENGTH; i++)
  197.     fputc(buf[i],out) ;
  198.  
  199.       fflush(out);        /* flush any file buffers */
  200.       rewind(out);        /* reset the file for read */
  201.  
  202.     }
  203. }
  204.  
  205. /*---------------------------------------------------------------------------*/
  206.  
  207. #ifndef ISC
  208. static void breakKey _AP((long s1,long s2,struct sigcontext* s3,char* s4));
  209. #endif
  210.  
  211. static void
  212. breakKey (s1,s2,s3,s4)
  213. long s1;
  214. long s2;
  215. struct sigcontext *s3;
  216. char *s4;
  217. {
  218.   panic ("got a ^c");
  219. }
  220.  
  221. /*---------------------------------------------------------------------------*/
  222.  
  223. void
  224. childhandler(sig, code, scp, addr)
  225. long sig, code;
  226. struct sigcontext *scp;
  227. char *addr;
  228. {
  229.   wait(NULL);            /* give the kid a decent burial */
  230. }
  231.  
  232. /*---------------------------------------------------------------------------*/
  233.  
  234. void
  235. alarmhandler(sig, code, scp, addr)
  236. long sig, code;
  237. struct sigcontext *scp;
  238. char *addr;
  239. {
  240.   waislog(WLOG_HIGH, WLOG_CLOSE,
  241.       "Server idle longer %s. Closing server and exiting.", IDLE_TIME);
  242.   exit(0);
  243. }
  244.  
  245. /*---------------------------------------------------------------------------*/
  246.  
  247. void
  248. seghandler(sig, code, scp, addr)
  249. long sig, code;
  250. struct sigcontext *scp;
  251. char *addr;
  252. {
  253.   waislog(WLOG_HIGH, WLOG_CLOSE,
  254.       "Segmentation violation.  Bummer. Closing server and exiting.");
  255.   exit(0);
  256. }
  257.  
  258. /*---------------------------------------------------------------------------*/
  259.  
  260. void
  261. bushandler(sig, code, scp, addr)
  262. long sig, code;
  263. struct sigcontext *scp;
  264. char *addr;
  265. {
  266.   waislog(WLOG_HIGH, WLOG_CLOSE,
  267.       "Bus error.  Bummer. Closing server and exiting.");
  268.   exit(0);
  269. }
  270.  
  271. /*---------------------------------------------------------------------------*/
  272.  
  273. #include <pwd.h>
  274.  
  275. int finduid(name)
  276. char *name;
  277. {
  278.   struct passwd *pwent;
  279.  
  280.   if ((pwent = getpwnam(name)) == NULL) {
  281.     return -1;
  282.   }
  283.  
  284.   return(pwent->pw_uid);
  285. }
  286.  
  287. static  char *index_dir = NULL;
  288. static  time_t info_change_time;
  289. static  int indexing_needed = 0;
  290. static  char *info_dict = INFO_DICT;
  291.  
  292. extern int alphasort();
  293.  
  294. /* selecttion function for scandir()
  295.  * trigger on ".src" extension, regular file, and != "INFO.src"
  296.  * Indexing is needed if any of the .src files is younger than 
  297.  * INFO.dct
  298.  */
  299. static int
  300. srcfiles(e)
  301.     struct dirent *e;
  302. {
  303.     struct stat sb;
  304.     char *lastdot = strrchr(e->d_name,'.');
  305.     int candidate;
  306.  
  307.     candidate =    lastdot && 
  308.           (stat(merge_pathnames(e->d_name,index_dir), &sb) >= 0) && 
  309.           ((sb.st_mode & S_IFMT) == S_IFREG) &&
  310.           !strcmp(lastdot,source_ext) && 
  311.           strcmp(e->d_name,info_dict); /* whew */
  312.  
  313.         if (candidate) {
  314.         indexing_needed |= (sb.st_mtime > info_change_time);
  315.         return 1;
  316.     }
  317.     return 0;
  318. }
  319.  
  320.  
  321. /*---------------------------------------------------------------------------*/
  322.  
  323. extern char *inet_ntoa _AP((struct in_addr));
  324.  
  325. void
  326. main(argc,argv)
  327. int argc;
  328. char* argv[];
  329. { FILE *file;
  330.   long socket;
  331.   char *next_argument = next_arg(&argc, &argv), *command_name;
  332.   boolean use_stdio = TRUE;        /* default is true */
  333.   long tcp_port = 210;            /* tcp_port to use */
  334.   /* char *log_file_name = NULL; */    /* name of file for error output */
  335.   int child_proc;        /* for the child process id */
  336.   char *uid_name = "root";    /* user id so setuid if root */
  337.   int uid = 0;        /* if not specified, leave as root. */
  338.   int child,lockfd;
  339.   struct stat statbuf;
  340.   struct dirent **list;
  341.   int n_files,fd;    
  342.   int naptime = 0;
  343.   extern int errno;
  344.   extern char *sys_errlist[];
  345.   char host_name[255];
  346.  
  347.   command_name = next_argument;
  348.   host_name[0] = 0;
  349.  
  350.   if (!strcmp(command_name, "waisserver.d")) {
  351.     struct sockaddr_in source;
  352.     int sourcelen;
  353. #ifdef BSD
  354.   struct in_addr {
  355.     union {
  356.       struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
  357.       u_long S_addr;
  358.     } S_un;
  359.   } addr_p;
  360. #endif /* BSD */
  361.  
  362.   sourcelen = sizeof(struct sockaddr_in);
  363.  
  364.     if (!getpeername(fileno(stdout),&source,&sourcelen)) {
  365. #ifdef BSD
  366.       addr_p.S_un.S_addr = source.sin_addr.s_addr;
  367. #endif                /* BSD */
  368.   
  369.       if(source.sin_family == AF_INET) {
  370. #ifdef NOINETNTOA
  371.     sprintf(host_name, "%d.%d.%d.%d",
  372. #ifdef BSD
  373.         addr_p.S_un.S_un_b.s_b1,
  374.         addr_p.S_un.S_un_b.s_b2,
  375.         addr_p.S_un.S_un_b.s_b3,
  376.         addr_p.S_un.S_un_b.s_b4
  377. #else
  378.         source.sin_addr.S_un.S_un_b.s_b1,
  379.         source.sin_addr.S_un.S_un_b.s_b2,
  380.         source.sin_addr.S_un.S_un_b.s_b3,
  381.         source.sin_addr.S_un.S_un_b.s_b4
  382.  
  383. #endif /* BSD */
  384.         );
  385. #else
  386.      sprintf(host_name, "%s", inet_ntoa(source.sin_addr));
  387. #endif /* NOINETNTOA */
  388.       }
  389.     }
  390.     else sprintf(host_name, "Error getting socket: %d, %s.", errno, sys_errlist[errno]);
  391.  
  392.     use_stdio = TRUE;
  393.   }
  394.  
  395.   if (argc == 0){
  396.     printf("Usage: %s [-p [port_number]] [-s] [-d directory] [-u user] [-v]\n",
  397.        command_name);
  398.     printf(" -p [port] listen to the port.  If the port is supplied, then\n");
  399.     printf("    that tcp_port number is used.  If it is not supplied \n");
  400.     printf("    then the Z39.50 port (210) is used.\n");
  401.     printf(" -d directory: means to use the directory as the source of databases.\n");
  402.     printf("    Defaults to the current directory.\n");
  403.     printf(" -e [file]: set log output to file, or /dev/null if not specified.\n");
  404.     printf(" -s means listen to standard I/O for queries.  This is the default\n");
  405.     printf(" -u user: if started as root, setuid to user after startup.\n");
  406.     printf(" -v prints the version.\n");
  407.     exit(1);
  408.   }
  409.   if(NULL == (next_argument = next_arg(&argc, &argv))){
  410.     printf("No arguments specified\n");
  411.     exit(0);
  412.   }
  413.   while((next_argument != NULL) &&
  414.     ('-' == next_argument[0])){
  415.     /* then we have an argument to process */
  416.     if (0 == strcmp("-p", next_argument)){
  417.       char *peek_argument = peek_arg(&argc, &argv);
  418.       use_stdio = FALSE;
  419.       if ((NULL != peek_argument) && /* if we are not out of args */
  420.       ('-' != peek_argument[0])){ { /* and the next isn't an option... */
  421.         /* get the port number */
  422.         tcp_port = atoi(next_arg(&argc, &argv));
  423.       }            /* end if (explicit tcp_port) */
  424.                     }
  425.     }                /* end if (-p) */
  426.     else if (0 == strcmp("-s", next_argument)){
  427.       use_stdio = TRUE;
  428.     }                /* end if (-s) */
  429.  
  430.     else if (0 == strcmp("-e", next_argument)) {
  431.       char *peek_argument = peek_arg(&argc, &argv);
  432.       log_file_name = "/dev/null"; /* default to /dev/null */
  433.       if ((peek_argument != NULL) &&
  434.       ('-' != peek_argument[0])) {
  435.     log_file_name = next_arg(&argc, &argv);
  436.       }                /* end if (explicit log file) */
  437.     }                /* end if (-e) */
  438.     else if (0 == strcmp("-d", next_argument)) {
  439.       index_dir = next_arg(&argc, &argv);
  440.     }
  441.     else if (0 == strcmp("-v", next_argument)) {
  442.       printf("%s: %s, %s\n", command_name, VERSION, SERVER_DATE);
  443.     }
  444.     else if (0 == strcmp("-u", next_argument)) {
  445.       uid_name = next_arg(&argc, &argv);
  446.       if((uid = finduid(uid_name)) < 0)
  447.     panic("Couldn't find user %s.", uid_name);
  448.     }
  449.     else{
  450.       panic("Don't recognize the %s option", next_argument);
  451.     }
  452.     next_argument = next_arg(&argc, &argv);
  453.   }                /* end while (more arguments) */
  454.  
  455.   if (use_stdio && log_file_name == NULL) 
  456.     log_file_name = "/dev/null";
  457.  
  458.   if (log_file_name == NULL) 
  459.     logfile = stderr;
  460.   else logfile = NULL;
  461.   
  462.   index_dir = index_dir ? index_dir : ".";  
  463.   info_dict = s_strdup(merge_pathnames(info_dict,index_dir));
  464.   
  465.   /* remember timestamp on INFO.dct if rebuilding needed 
  466.    * If it doesnt exist, it's assumed to be *very* old, to force
  467.    * re-indexing
  468.    */
  469.   info_change_time = (stat(info_dict,&statbuf) == -1) ? 0 : statbuf.st_mtime;
  470.   
  471.   /* compare with candidates */
  472.  
  473.   if ((n_files = scandir(index_dir, &list, srcfiles, alphasort)) < 0) {
  474.       waislog(WLOG_HIGH, WLOG_ERROR, 
  475.           "Error: reading directory %s, %s", 
  476.           index_dir, sys_errlist[errno]);
  477.       indexing_needed = FALSE;
  478.   }
  479.   
  480.   /* ok. we know if we need indexing, 
  481.    * and have all the filenames. 
  482.    */
  483.   
  484.   if (info_change_time == 0) indexing_needed = TRUE;
  485.   if (indexing_needed) {
  486.  
  487.     /* Time to re-index,
  488.      * aquire the lock 
  489.      */
  490.     waislog(WLOG_MEDIUM, WLOG_INDEX,
  491.         "re-indexing needed, info_change_time=%d",info_change_time); 
  492.  
  493.     if (( fd = open(LOCKFILE, O_WRONLY|O_CREAT|O_EXCL,0666)) == -1) {
  494.       
  495.       /* already locked by somebody else
  496.        * spin  till she finishes
  497.        */
  498.       while (!(stat(LOCKFILE,&statbuf) == -1)) {
  499.     sleep(NAPTIME);
  500.     naptime += NAPTIME;
  501.     waislog(WLOG_MEDIUM, WLOG_INFO,
  502.         "INFO locked, waiting since %d seconds", naptime);
  503.     if (naptime  > MAXNAPTIME)  {
  504.  
  505.       waislog(WLOG_HIGH, WLOG_ERROR,
  506.           "Warning - lockfile %s won't go away after %d seconds, not reindexing.", 
  507.           LOCKFILE, naptime);
  508.       break;
  509.     }
  510.       }
  511.       /* if lockfile went away, assume INFO.* build finished
  512.        * so just use it
  513.        */
  514.     } else {            /* we aquired the lock, so rebuild database  */
  515.       
  516.       if (!(child = fork())) {
  517.     database *db;
  518.     struct dirent **s = list;
  519.     char filename[MAX_FILENAME_LEN];
  520.           
  521.     waislog(WLOG_MEDIUM, WLOG_INDEX,
  522.         "Creating INFO database, pid=%d",getpid());
  523.     db = openDatabase(merge_pathnames("INFO",    index_dir),
  524.               true, /* maybe this should append XXX */
  525.               false);
  526.     db->the_word_memory_hashtable =
  527.       init_word_memory_hashtable(1L<<16, 100000L, db->the_word_memory_hashtable);
  528.           
  529.     while (*s) {        /* index it */
  530.       strncpy(filename, index_dir, MAX_FILENAME_LEN);
  531.       if(index_dir[strlen(index_dir) -1] != '/')
  532.         strncat(filename, "/", MAX_FILENAME_LEN);
  533.       strncat(filename, (*s)->d_name, MAX_FILENAME_LEN);
  534.       waislog(WLOG_MEDIUM, WLOG_INDEX,
  535.           "Indexing %s", filename);
  536.       index_text_file(filename, NULL, NULL, NULL, 
  537.               NULL, "WSRC", db, true, false);
  538.       s++;
  539.     }
  540.     freedir(list);        /* array of filenames */
  541.           
  542.     if(!probe_file(source_filename(filename, db)))
  543.       write_src_structure(source_filename(filename, db),
  544.                   "INFO", "WSRC", NULL, 0L, true, tcp_port);
  545.     finished_add_word(db);
  546.     closeDatabase(db);
  547.     if (unlink(LOCKFILE))
  548.       panic("Indexer: cant unlink lockfile!\n");
  549.     waislog(WLOG_MEDIUM, WLOG_INDEX,
  550.         "Indexer pid=%d done", getpid());
  551.           
  552.     exit(0);        /* indexing child */
  553.  
  554.       }  else if (child == -1) {
  555.     waislog(WLOG_HIGH, WLOG_ERROR,
  556.         "Unable to fork for indexer.");
  557.     exit(1);
  558.       }
  559.       /* wait for child process */
  560.       else while (wait(0) != child) ; /* do nothing */
  561.     }
  562.   }
  563.  
  564.  
  565.   if (use_stdio == TRUE) {
  566.     if(host_name[0] != 0)
  567.       waislog(WLOG_MEDIUM, WLOG_CONNECT,
  568.           "Accepted connection from: %s. %s", host_name, VERSION);
  569.     else
  570.       waislog(WLOG_MEDIUM, WLOG_CONNECT,
  571.           "Couldn't determine peer connection. %s", VERSION);
  572.   }
  573.   else waislog(WLOG_MEDIUM, WLOG_INFO, "Running server %s", VERSION);
  574.  
  575.   signal(SIGINT, breakKey);
  576.  
  577.   signal(SIGCHLD, childhandler);      /* XXX dont really need this any more */
  578.   signal(SIGALRM, alarmhandler);
  579.  
  580.   signal(SIGSEGV, seghandler);
  581.  
  582.   signal(SIGBUS, bushandler);
  583.  
  584.   if(use_stdio == FALSE)
  585.    { open_server(tcp_port,&socket,BUFSZ);
  586.  
  587. #ifdef SECURE_SERVER
  588.      /* if root, setuid to user specified id. */
  589.      if (uid > 0 && getuid() == 0)  {
  590.        waislog(WLOG_MEDIUM, WLOG_INFO,
  591.            "Setting uid to %s.", uid_name);
  592.        if ( 0 > setuid(uid)) {
  593.      waislog(WLOG_HIGH, WLOG_ERROR,
  594.          "Unable to setuid to %s!  Exiting.", uid_name);
  595.      exit(-1);
  596.        }
  597.      }
  598. #endif
  599.      while (TRUE) { /* be a server for several connections */
  600.        accept_client_connection(socket,&file);
  601.       
  602.        if ((child_proc = fork()) == 0) {
  603.           
  604.           /* grandson handles this connection
  605.            * double-fork takes care of zombies 
  606.            */
  607.           if ((child_proc = fork()) == 0) { 
  608.           serve_client(file, file, index_dir);
  609.           /* but leaves server up */
  610.           close_client_connection(file);
  611.           close_server(socket);
  612.           /* just exits this child */
  613.           waislog(WLOG_MEDIUM, WLOG_CLOSE,
  614.               "Done handling client");
  615.           exit(0);
  616.           } else {
  617.           /* son: orphans the grandchild, so init picks up 
  618.            * the exit status
  619.            */
  620.           exit(0);
  621.           }
  622.           } else {
  623.           waislog(WLOG_MEDIUM, WLOG_INFO,
  624.               "Child PID = %d", child_proc);
  625.           close_client_connection(file);     /* parent shouldn't keep the file */
  626.       }
  627.       }
  628.    }
  629.   else if(use_stdio == TRUE)
  630.    { /* connections on stdio don't use child processes yet */
  631.      serve_client(stdin, stdout, index_dir);
  632.      waislog(WLOG_MEDIUM, WLOG_CLOSE,
  633.          "Done handling client");
  634.       /* close the whole thing */
  635.      exit(0);
  636.    }
  637. }
  638.  
  639. /*---------------------------------------------------------------------------*/
  640.  
  641.