message: compatible with BASE mode.
diff: @@ -402,14 +402,15 @@ static void swWorker_stop()
  {
  swWorker *worker = SwooleWG.worker;
  swServer *serv = SwooleG.serv;
  - SwooleWG.wait_exit = 1;
  //remove read event
  - swConnection *socket = swReactor_get(SwooleG.main_reactor, worker->pipe_worker);
  - if (socket->events & SW_EVENT_WRITE)
  + if (worker->pipe_worker)
  + {
  + swConnection *pipe_socket = swReactor_get(SwooleG.main_reactor, worker->pipe_worker);
  + if (pipe_socket->events & SW_EVENT_WRITE)
  {
  - socket->events &= (~SW_EVENT_READ);
  - if (SwooleG.main_reactor->set(SwooleG.main_reactor, worker->pipe_worker, socket->fdtype | socket->events) < 0)
  + pipe_socket->events &= (~SW_EVENT_READ);
  + if (SwooleG.main_reactor->set(SwooleG.main_reactor, worker->pipe_worker, pipe_socket->fdtype | pipe_socket->events) < 0)
  {
  swSysError("reactor->set(%d, SW_EVENT_READ) failed.", worker->pipe_worker);
  }
  @@ -421,10 +422,7 @@ static void swWorker_stop()
  swSysError("reactor->del(%d) failed.", worker->pipe_worker);
  }
  }
  -
  - swWorkerStopMessage msg;
  - msg.pid = SwooleG.pid;
  - msg.worker_id = SwooleWG.id;
  + }
  if (serv->onWorkerStop)
  {
  @@ -432,6 +430,15 @@ static void swWorker_stop()
  serv->onWorkerStop = NULL;
  }
  + if (serv->factory_mode == SW_MODE_SINGLE)
  + {
  + goto try_to_exit;
  + }
  +
  + swWorkerStopMessage msg;
  + msg.pid = SwooleG.pid;
  + msg.worker_id = SwooleWG.id;
  +
  //send message to manager
  if (swChannel_push(SwooleG.serv->message_box, &msg, sizeof(msg)) < 0)
  {
  @@ -442,6 +449,7 @@ static void swWorker_stop()
  kill(SwooleGS->manager_pid, SIGIO);
  }
  + try_to_exit: SwooleWG.wait_exit = 1;
  if (SwooleG.timer.fd == 0)
  {
  swTimer_init(serv->max_wait_time * 1000);
  @@ -462,6 +470,12 @@ void swWorker_try_to_exit()
  {
  swServer *serv = SwooleG.serv;
  int expect_event_num = SwooleG.use_signalfd ? 1 : 0;
  +
  + if (serv->factory_mode == SW_MODE_SINGLE)
  + {
  + expect_event_num += serv->listen_port_num;
  + }
  +
  uint8_t call_worker_exit_func = 0;
  while (1)
  