home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NETKIT-A.06 / NETKIT-A / NetKit-A-0.06 / tcp_wrapper-6.3 / clean_exit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-27  |  1.0 KB  |  43 lines

  1.  /*
  2.   * clean_exit() cleans up and terminates the program. It should be called
  3.   * instead of exit when for some reason the real network daemon will not or
  4.   * cannot be run. Reason: in the case of a datagram-oriented service we must
  5.   * discard the not-yet received data from the client. Otherwise, inetd will
  6.   * see the same datagram again and again, and go into a loop.
  7.   * 
  8.   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  9.   */
  10.  
  11. #ifndef lint
  12. static char sccsid[] = "@(#) clean_exit.c 1.3 93/09/11 20:45:43";
  13. #endif
  14.  
  15. #include <stdio.h>
  16.  
  17. extern void exit();
  18.  
  19. #include "log_tcp.h"
  20.  
  21. /* clean_exit - clean up and exit */
  22.  
  23. void    clean_exit(client)
  24. struct client_info *client;
  25. {
  26.  
  27.     /*
  28.      * In case of unconnected protocols we must eat up the not-yet received
  29.      * data or inetd will loop.
  30.      */
  31.  
  32.     if (client->sink)
  33.     client->sink(client->fd);
  34.  
  35.     /*
  36.      * Be kind to the inetd. We already reported the problem via the syslogd,
  37.      * and there is no need for additional garbage in the logfile.
  38.      */
  39.  
  40.     sleep(1);
  41.     exit(0);
  42. }
  43.