*** http_main.c.preabsent	Mon Oct 18 10:17:38 1999
--- http_main.c	Mon Oct 18 10:29:10 1999
***************
*** 2805,2810 ****
--- 2805,2816 ----
  
  static void restart(int sig)
  {
+ #ifdef MOD_PUSHWEB
+   /* on a read failure, this is redundant.  it's not on a normal SIGHUP,
+      though. */
+   pushweb_shutdown(server_conf);
+ #endif
+ 
  #ifndef WIN32
      ap_start_restart(sig == SIGUSR1);
  #else
***************
*** 3404,3409 ****
--- 3410,3427 ----
  	    break;
  	lr = lr->next;
      }
+ 
+ #ifdef MOD_PUSHWEB
+     /* i'd really like to just create this listener outside
+        setup_listeners, but find_listener has a nasty habit of
+        zeroing it out. */
+     pushweb_init(server_conf, pconf);
+     /* the pushweb listener is now at the head of the list. */
+     FD_SET(ap_listeners->fd, &listenfds);
+     if (ap_listeners->fd > listenmaxfd)
+       listenmaxfd = ap_listeners->fd;
+ #endif /* MOD_PUSHWEB */
+ 
      /* turn the list into a ring */
      lr->next = ap_listeners;
      head_listener = ap_listeners;
***************
*** 3833,3838 ****
--- 3851,3880 ----
  	    usr1_just_die = 0;
  	    for (;;) {
  		clen = sizeof(sa_client);
+ 
+ #ifdef MOD_PUSHWEB
+ 		if(sd == pushweb_control_socket(server_conf)) {
+ 		    if(pushweb_cmsg_read(server_conf) < 0) {
+ 		      /* GAH.  we need to just sit here.  otherwise,
+ 			 idle server maintenance is convinced we're
+ 			 a problem child and just blithely tries to
+ 			 restart us when we exit.  so we sleep until
+ 			 the parent recognises the problem and kills
+ 			 us dead dead good.  time to stop using apache,
+ 			 i think. */
+ 		      restart(SIGUSR1);
+ 		      /* this is probably a mistake. */
+ 		      clean_child_exit(0);
+ 		      /* pause();*/
+ 		    }
+ 		    csd=sd;
+ 		    break;
+ 		}
+ 		/* shouldn't be necessary to add an else here; we
+ 		   either break out of the loop (skipping the code below)
+ 		   or exit altogether. */
+ #endif /* MOD_PUSHWEB */
+ 
  		csd = ap_accept(sd, &sa_client, &clen);
  		if (csd >= 0 || errno != EINTR)
  		    break;
***************
*** 3966,3971 ****
--- 4008,4036 ----
  
  	ap_note_cleanups_for_fd(ptrans, csd);
  
+ #ifdef MOD_PUSHWEB
+ 	/* i'm not sure if the foregoing entirely makes sense for absent.
+ 	   we might NOT want to stay alive, particularly if something
+ 	   has gone and hosed the control channel.  but owell, if
+ 	   this doesn't work, we'll probably figure it out and fail
+ 	   miserably pretty quickly. */
+ 	if(csd == sd) {
+  	  csd=pushweb_cmsg_process(server_conf, &sa_client);
+  	  if(csd < 0) {
+ 	    /* ut oh.  looks like something broke.  give up.
+ 	       we'd really like to be able to just tell apache to
+ 	       die, but there's no good way to do that without
+ 	       explicitly sending a signal. */
+ 	    ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
+ 			 "pushweb control channel processing failed.  exiting.");
+ 	    restart(SIGUSR1);
+ 	    clean_child_exit(0);
+ 	  }
+ 	}
+ 	/* otherwise nothing; everything's set and we proceed as though
+ 	   this were a normal client. */
+ #endif  /* MOD_PUSHWEB */
+ 
  	/* protect various fd_sets */
  #ifdef CHECK_FD_SETSIZE
  	if (csd >= FD_SETSIZE) {
***************
*** 4613,4618 ****
--- 4678,4694 ----
  		continue;
  	    }
  
+ #ifdef MOD_PUSHWEB
+ 	    /* it turns out this is the only viable place to do this,
+ 	       in spite of the expense. */
+ 	    if(pushweb_control_socket(server_conf) < 0) {
+ 	      restart(SIGHUP);
+ 	      /* clean_child_exit(0); */
+ 	    }
+ 	    /* idle server maintenance wants to make our life difficult */
+ 	    else
+ #endif /* MOD_PUSHWEB */
+ 
  	    perform_idle_server_maintenance();
  #ifdef TPF
          shutdown_pending = os_check_server(tpf_server_name);
