Пример #1
0
static gearman_return_t _thread_packet_flush(gearman_server_con_st *con)
{
  gearman_return_t ret;

  /* Check to see if we've already tried to avoid excessive system calls. */
  if (con->con.events & POLLOUT)
    return GEARMAN_IO_WAIT;

  while (con->io_packet_list != NULL)
  {
    ret= gearman_connection_send(&(con->con), &(con->io_packet_list->packet),
                          con->io_packet_list->next == NULL ? true : false);
    if (ret != GEARMAN_SUCCESS)
      return ret;

    gearman_log_debug(con->thread->gearman, "%15s:%5s Sent      %s",
                      con->host == NULL ? "-" : con->host,
                      con->port == NULL ? "-" : con->port,
                      gearman_command_info_list[con->io_packet_list->packet.command].name);

    gearman_server_io_packet_remove(con);
  }

  /* Clear the POLLOUT flag. */
  return gearman_connection_set_events(&(con->con), POLLIN);
}
Пример #2
0
static gearmand_error_t _thread_packet_flush(gearman_server_con_st *con)
{
  /* Check to see if we've already tried to avoid excessive system calls. */
  if (con->con.events & POLLOUT)
  {
    return GEARMAN_IO_WAIT;
  }

  while (con->io_packet_list)
  {
    gearmand_error_t ret= gearman_io_send(con, &(con->io_packet_list->packet),
                                          con->io_packet_list->next == NULL ? true : false);
    if (gearmand_failed(ret))
    {
      return ret;
    }

    gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, 
                       "Sent %s to %s:%d",
                       gearman_command_info(con->io_packet_list->packet.command)->name,
                       con->_host == NULL ? "-" : con->_host,
                       con->_port == NULL ? "-" : con->_port);

    gearman_server_io_packet_remove(con);
  }

  /* Clear the POLLOUT flag. */
  return gearmand_io_set_events(con, POLLIN);
}