|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 3073 (0xc01) Types: TextFile Names: »main.c«
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦cfd40dc56⟧ »EurOpenD3/news/nntp/nntp.1.5.8.tar.Z« └─⟦2ec98eca6⟧ └─⟦this⟧ »server/main.c« └─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit └─⟦5cced586a⟧ »EurOpenD3/news/nntp/nntp.1.5.7.tar.Z« └─⟦7340f105e⟧ └─⟦this⟧ »./server/main.c«
#ifndef lint static char *sccsid = "@(#)main.c 1.12 (Berkeley) 8/27/89"; #endif /* * Network News Transfer Protocol server * * Phil Lapsley * University of California, Berkeley * (Internet: phil@berkeley.edu; UUCP: ...!ucbvax!phil) * Stan Barber * Baylor College of Medicine * (Internet: sob@tmc.edu; UUCP: ...!bcm!sob) */ #include "common.h" #include <sys/socket.h> #include <netinet/in.h> #ifndef EXCELAN #include <netdb.h> #else struct sockaddr_in current_peer = { AF_INET, IPPORT_NNTP }; #endif #include <signal.h> main() { #ifdef ALONE /* If no inetd */ int sockt, client, length; struct sockaddr_in from; extern int reaper(); disassoc(); /* fd 0-2 should be open and point to / now. */ /* Let's close all the other FD's just to be sure */ for(sockt = 3; sockt < 40; sockt++) (void) close(sockt); #ifdef SYSLOG #ifdef BSD_42 openlog("nntpd", LOG_PID); /* fd 3 */ #else openlog("nntpd", LOG_PID, SYSLOG); /* fd 3 */ #endif #endif #ifdef FASTFORK num_groups = read_groups(); /* Read active file now (fd 4) */ /* and then do it every */ set_timer(); /* so often later */ #endif #ifndef EXCELAN sockt = get_socket(); /* should be fd 4 or 5 */ #ifdef USG (void) signal(SIGCLD, SIG_IGN); #else (void) signal(SIGCHLD, reaper); #endif if (listen(sockt, SOMAXCONN) < 0) { #ifdef SYSLOG syslog(LOG_ERR, "main: listen: %m"); #endif exit(1); } #endif for (;;) { #ifdef LOAD register int load; char oline[NNTP_STRLEN]; #endif LOAD #ifdef EXCELAN int status; sockt = 3; sockt = get_socket(); if (sockt < 0) continue; #ifdef USG (void) signal(SIGCLD, SIG_IGN); memset((char *)&from,'\0',sizeof(from)); #else bzero((char *)&from,sizeof(from)); #endif client = accept(sockt, &from); #else length = sizeof (from); client = accept(sockt, &from, &length); #endif EXCELAN if (client < 0) { #ifdef SYSLOG #ifdef EXCELAN if (errno != EINTR && errno != 60 ) #else if (errno != EINTR) #endif syslog(LOG_ERR, "accept: %m\n"); #endif #ifdef EXCELAN close(sockt); sleep(1); #endif continue; } #ifdef LOAD if (( load = getla()) > LOAD ) { sprintf( oline, "%d loadav at %d, try later\n", ERR_GOODBYE, load ); write( client, oline, strlen( oline )); #ifdef SYSLOG syslog( LOG_INFO, "loadav at %d, sleeping", load ); #endif SYSLOG close( client ); sleep( 5 ); continue; } #endif LOAD switch (fork()) { case -1: #ifdef SYSLOG syslog(LOG_ERR, "fork: %m\n"); #endif #ifdef EXCELAN (void) close(sockt); #endif (void) close(client); break; case 0: #ifdef EXCELAN if (fork()) exit(0); #ifdef USG (void * )memcpy(¤t_peer,&from, sizeof(from)); #else bcopy(&from,¤t_peer,sizeof(from)); #endif make_stdio(sockt); #else (void) close(sockt); make_stdio(client); #endif #ifdef USG (void) signal(SIGCLD,SIG_DFL); #endif serve(); break; default: #ifdef EXCELAN (void) close(sockt); #else (void) close(client); #endif break; } } #else /* We have inetd */ serve(); #endif }