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); }
gearman_server_con_st *gearman_server_con_add(gearman_server_thread_st *thread, gearmand_con_st *dcon, gearmand_error_t *ret) { gearman_server_con_st *con= _server_con_create(thread, dcon, ret); if (con == NULL) { return NULL; } if ((*ret= gearman_io_set_fd(&(con->con), dcon->fd)) != GEARMAN_SUCCESS) { gearman_server_con_free(con); return NULL; } *ret= gearmand_io_set_events(con, POLLIN); if (*ret != GEARMAN_SUCCESS) { gearmand_gerror("gearmand_io_set_events", *ret); gearman_server_con_free(con); return NULL; } return con; }