void HandlePollResponse(const std::string & upload_key, FSM & fsm, const mf::api::upload::poll_upload::Response & response) { if (!response.response_data) { auto timer = fsm.Timer(); timer->expires_from_now( std::chrono::seconds(poll_upload_retry_timeout_seconds)); timer->async_wait(boost::bind(&RetryPoll<FSM>, upload_key, fsm.AsFrontShared(), boost::asio::placeholders::error)); } else { const auto & response_data = *response.response_data; // if result is negative, it indicates a failure if (response_data.result < 0) { fsm.ProcessEvent( event::Error{std::error_code(response_data.result, poll_result_category()), "Poll upload bad response"}); } else if (response_data.fileerror != 0) { fsm.ProcessEvent(event::Error{ std::error_code(response_data.fileerror, poll_upload_file_error_category()), "Poll upload file error received"}); } else if (response_data.quickkey) { HandlePollCompleteResponse(fsm, response); } else { auto timer = fsm.Timer(); timer->expires_from_now( std::chrono::seconds(poll_upload_retry_timeout_seconds)); timer->async_wait(boost::bind(&RetryPoll<FSM>, upload_key, fsm.AsFrontShared(), boost::asio::placeholders::error)); } } }
void handler( const boost::system::error_code& error ) { if( error == boost::asio::error::operation_aborted ) { // Happens if we pause it } else if(error) { // DARC_WARNING("PeriodicTimer callback gave some error %u", error.value()); } else if( state_ == STOPPED ) { // Just ignore it } else { // Todo: system time can actually not be trusted. What about using boost::chrono? boost::posix_time::time_duration diff = boost::posix_time::microsec_clock::universal_time() - expected_deadline_; expires_from_now( period_ - diff ); //DARC_INFO("Diff: %s", boost::posix_time::to_simple_string(diff).c_str()); expected_deadline_ += period_; // std::cout << diff.total_milliseconds() << std::endl; async_wait( boost::bind( &periodic_timer::handler, this, boost::asio::placeholders::error ) ); if(state_ == RUNNING) { callback_(); } } }
static async_p async_create(int threads) { async_p async = malloc(sizeof(*async) + (threads * sizeof(pthread_t))); async->tasks = NULL; async->pool = NULL; async->pipe.in = 0; async->pipe.out = 0; if (pthread_mutex_init(&(async->lock), NULL)) { free(async); return NULL; }; if (pipe((int *) &(async->pipe))) { free(async); return NULL; }; fcntl(async->pipe.out, F_SETFL, O_NONBLOCK | O_WRONLY); async->run = 1; /* create threads */ for (async->count = 0; async->count < threads; async->count++) { if (create_thread( async->threads + async->count, worker_thread_cycle, async)) { /* signal */ async_signal(async); /* wait for threads and destroy object */ async_wait(async); /* return error */ return NULL; }; } return async; }
void PacketHandler::handleStatusPing(packets::Ping& packet) { packets::Pong(packet.payload).send(mSession); Server& server = mSession.getServer(); auto timer = std::make_shared<boost::asio::steady_timer>(server.getWorkIO(), asio::chrono::seconds(10)); timer->async_wait([timer, session = mSession.shared_from_this()] (const boost::system::error_code&) { session->disconnect(); }); }
bool Conn::Write(Packet &&pkt, callbacks_func_type &&cb) { auto timer = std::make_shared< boost::asio::deadline_timer >(io); timer->expires_from_now( boost::posix_time::milliseconds(read_timeout) ); timer->async_wait( boost::bind(&Conn::onTimeout, shared_from_this(), boost::asio::placeholders::error, pkt.hdr.sync, timer) ); if( LOG_DEBUG ) log_func("[iproto_conn] %s:%u: sending packet sync=%u", ep.address().to_string().c_str(), ep.port(), pkt.hdr.sync); callbacks_map[pkt.hdr.sync] = std::make_pair(std::move(timer), std::forward<callbacks_func_type>(cb)); return dropPacketWrite( std::forward<Packet>(pkt) ); }
void async_sleep(unsigned long usec) { int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); if(fd == -1) return; struct itimerspec it = { { 0, 0 }, { usec / 1000000, usec % 1000000 * 1000 } }; timerfd_settime(fd, 0, &it, NULL); async_wait(fd, ASYNC_READ); close(fd); }
std::shared_ptr<boost::asio::deadline_timer> RWHandler::setTimeoutTimer(int seconds) { auto timer = std::make_shared<boost::asio::deadline_timer>(m_io_service); timer->expires_from_now(boost::posix_time::seconds(seconds)); auto self(shared_from_this()); timer->async_wait([self](const boost::system::error_code& ec) { if (!ec) { self->onClosed(CLOSED_TYPE::TIMEOUT); } }); return timer; }
void NetworkInterfaceASIO::setAlarm(Date_t when, const stdx::function<void()>& action) { // "alarm" must stay alive until it expires, hence the shared_ptr. auto alarm = std::make_shared<asio::steady_timer>(_io_service, when - now()); alarm->async_wait([alarm, this, action](std::error_code ec) { if (!ec) { return action(); } else if (ec != asio::error::operation_aborted) { // When the network interface is shut down, it will cancel all pending // alarms, raising an "operation_aborted" error here, which we ignore. warning() << "setAlarm() received an error: " << ec.message(); } }); };
// 握手 void async_handshake(socket_ptr const& sp, endpoint const& addr) { async_handshaking_.set(); auto handler = BEX_IO_BIND(&this_type::on_async_handshake, this, BEX_IO_PH_ERROR, sp, addr); if (opts_->ssl_opts) { auto timed_handler = timer_handler<allocator>(handler, ios_); timed_handler.expires_from_now(boost::posix_time::milliseconds(opts_->ssl_opts->handshake_overtime)); timed_handler.async_wait(BEX_IO_BIND(&this_type::on_async_handshake, this, make_error_code(errc::handshake_overtime), sp, addr)); protocol_traits_type::async_handshake(sp, ssl::stream_base::client, timed_handler); } else protocol_traits_type::async_handshake(sp, ssl::stream_base::client, handler); }
void PeerStateList::addPeer(PeerState ps) { PeerStateContainer psc(ps); auto timer = std::make_unique<boost::asio::deadline_timer>(m_context.ios, boost::posix_time::time_duration(0, 20, 0)); timer->async_wait(boost::bind(&PeerStateList::timerCallback, this, boost::asio::placeholders::error, ps.getHash())); psc.timer = std::move(timer); auto itr = m_container.get<1>().find(ps.getHash()); if(itr == m_container.get<1>().end()) m_container.insert(std::move(psc)); else m_container.get<1>().replace(itr, std::move(psc)); }
void loop(async_s * as) { int nb, i; client_s * n; printf("[+] Loop ...\n\n"); while(1) { nb = async_wait(as); for(i=0; i < nb; ++i){ n = as->ev[i].data.ptr; if(n->func != NULL) n->func((void *)n); } } }
void OutboundMessageFragments::sendData(PeerState const &ps, uint32_t const msgId, ByteArray const &data) { auto timer = std::make_unique<boost::asio::deadline_timer>(m_context.ios, boost::posix_time::time_duration(0, 0, 2)); timer->async_wait(boost::bind(&OutboundMessageFragments::timerCallback, this, boost::asio::placeholders::error, ps, msgId)); OutboundMessageState oms(msgId, data); oms.setTimer(std::move(timer)); std::lock_guard<std::mutex> lock(m_mutex); uint32_t tmp = msgId; m_states.emplace(std::make_pair(std::move(tmp), std::move(oms))); m_context.ios.post(boost::bind(&OutboundMessageFragments::sendDataCallback, this, ps, msgId)); }
void sleep(std::size_t ms,CO co,boost::system::error_code& e) { BOOST_ASSERT(co != NULL); if (ms == 0) { return; } timer_handler<CO> handler(co,e); expires_from_now(boost::posix_time::milliseconds(ms)); async_wait(handler); ////////////////////////// co -> yield(); ///////////////////////// if(e) { ORCHID_DEBUG("timer sleep error: %s",e.message().c_str()); } return; }
void stackless_loop(struct uwsgi_server *uwsgi) { int i; PyTaskletObject *int_tasklet; // tasklets main loop for(;;) { //uwsgi->async_running = -1 ; //if (PyStackless_GetRunCount() > 0) { uwsgi->async_running = 0 ; //} uwsgi->async_nevents = async_wait(uwsgi->async_queue, uwsgi->async_events, uwsgi->async, uwsgi->async_running, 0); if (uwsgi->async_nevents < 0) { continue; } for(i=0; i<uwsgi->async_nevents;i++) { if (uwsgi->async_events[i].ASYNC_FD == uwsgi->serverfd) { //pass the connection to the first available tasklet fprintf(stderr,"sending new connection...\n"); PyChannel_Send(uwsgi->workers_channel, Py_True); } } /* if (PyStackless_GetRunCount() > 0) { PyStackless_Schedule(Py_None, 0); } */ PyStackless_RunWatchdogEx( 10, PY_WATCHDOG_TOTALTIMEOUT); //int_tasklet = (PyTaskletObject *) PyStackless_RunWatchdog( 1000 ); /* fprintf(stderr,"done watchdog %p\n", int_tasklet); if (!PyTasklet_IsCurrent(int_tasklet)) { fprintf(stderr,"re-insert: %d\n", 1);// PyTasklet_Insert(int_tasklet)); } fprintf(stderr,"recycle\n"); */ } }
int main_cpp11(){ boost::asio::io_service io; const auto count_ptr = std::make_shared<int>(0); const auto timer_ptr = std::make_shared<boost::asio::deadline_timer>( io, boost::posix_time::seconds(1)); timer_ptr->async_wait( [&timer_ptr, &count_ptr] (const boost::system::error_code& ec){ return print( ec, timer_ptr, count_ptr); }); io.run(); std::cout << "Final count is " << *count_ptr << std::endl; return 0; }
int main(int argc, char *argv[]) { int i,j,k, dd; struct aio_rq *p[NR_REQS]; for (i=0;i<NR_REQS;i++) p[i] = (struct aio_rq *)malloc (sizeof (struct aio_rq)); for (i=0;i<DEVICE_SECTOR_SIZE;i++){ buf1[i]='x'; } if ((dd=dev_open(DISKIMG)) < 0) exit(1); for (i=0;i<NR_REQS;i++){ p[i]->dd = dd; p[i]->offset = i; /* ith sector */ p[i]->buffer = buf1; p[i]->tid = pthread_self(); if (async_write(p[i]) < 0) { printf("Error in async_write"); exit(1); } } printf("******Overlap some compution with I/O******\n"); k=0; for (j=0;j<10*1000*1000;j++) k++; printf("Waiting for the I/O to finish\n"); /* Blocking waiting for the I/O to finish */ for (i=0;i<NR_REQS;i++) if (async_wait(p[i]) < 0) { printf("Error in async_write"); exit(1); } printf("Done\n"); if (dev_rls(dd) < 0) exit(1); return 0; } /****** End main() ******/
// 带超时的异步连接 bool async_connect_timed(endpoint const& addr, boost::posix_time::time_duration time) { if (is_running() || !async_connecting_.set()) return false; socket_ptr sp = protocol_type::alloc_socket(ios_, *opts_, ec_); if (ec_) return false; /// 连接超时计时器, 异步等待 auto timed_handler = timer_handler<allocator>(BEX_IO_BIND(&this_type::on_async_connect_timed, this, BEX_IO_PH_ERROR, sp, addr, time), ios_); timed_handler.expires_from_now(time); timed_handler.async_wait(BEX_IO_BIND(&this_type::on_overtime, this, BEX_IO_PH_ERROR, sp, errc::connect_overtime)); sp->lowest_layer().async_connect(addr, timed_handler); // 启动工作线程 mstrand_service_.startup(opts_->workthread_count); return true; }
void async_wait(int fd, int dir) { if(epfd == -1) epfd = epoll_create1(EPOLL_CLOEXEC); if(epfd == -1) return; ucontext_t ctx; struct epoll_event event = { dir ? EPOLLOUT : EPOLLIN, { &ctx } }; if(epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event) != 0) { if(errno == EEXIST) { int fd2 = dup(fd); async_wait(fd2, dir); close(fd2); } return; } if(ucp_next) { ucontext_t *ucp = ucp_next; ucp_next = ucp->uc_link; swapcontext(&ctx, ucp); } else { struct epoll_event event; while(epoll_wait(epfd, &event, 1, -1) != 1); if(&ctx != event.data.ptr) swapcontext(&ctx, event.data.ptr); } clear(&trash); epoll_ctl(epfd, EPOLL_CTL_DEL, fd, NULL); }
socket1.native_non_blocking(false, ec); ip::udp::endpoint endpoint1 = socket1.local_endpoint(); ip::udp::endpoint endpoint2 = socket1.local_endpoint(ec); ip::udp::endpoint endpoint3 = socket1.remote_endpoint(); ip::udp::endpoint endpoint4 = socket1.remote_endpoint(ec); socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); socket1.wait(socket_base::wait_read); socket1.wait(socket_base::wait_write, ec); socket1.async_wait(socket_base::wait_read, wait_handler()); int i3 = socket1.async_wait(socket_base::wait_write, lazy); (void)i3; // basic_datagram_socket functions. socket1.send(buffer(mutable_char_buffer)); socket1.send(buffer(const_char_buffer)); socket1.send(null_buffers()); socket1.send(buffer(mutable_char_buffer), in_flags); socket1.send(buffer(const_char_buffer), in_flags); socket1.send(null_buffers(), in_flags); socket1.send(buffer(mutable_char_buffer), in_flags, ec); socket1.send(buffer(const_char_buffer), in_flags, ec); socket1.send(null_buffers(), in_flags, ec); socket1.async_send(buffer(mutable_char_buffer), send_handler());
int main(int argc, char *argv[]) { int i,j,k, dd; struct aio_rq *p; p = (struct aio_rq *)malloc (sizeof (struct aio_rq)); for (i=0;i<DEVICE_SECTOR_SIZE;i++){ buf1[i]='c'; buf2[i]=0; } if ((dd=dev_open(DISKIMG)) < 0) exit(1); p->dd = dd; p->offset = 0; p->buffer = buf1; p->tid = pthread_self(); if (async_write(p) < 0) { printf("Error in async_write"); exit(1); } i=0; while (1) { printf("*** Computation overlapping I/O iteration=%d\n", i++); for (j=0;j<1000*1000;j++) k++; printf("*** Checking if I/O terminated\n"); if (async_status(p) > 0) { printf("\tI/O operation finished.\n"); break; } else printf("\tI/O operation NOT finished yet.\n"); } p->dd = dd; p->offset = 0; p->buffer = buf2; p->tid = pthread_self(); if (async_read(p) < 0) { printf("Error in async_read"); exit(1); } /* Blocking waiting for the I/O to finish */ if (async_wait(p) < 0) { printf("Error in async_write"); exit(1); } if (memcmp(buf1, buf2,DEVICE_SECTOR_SIZE)) printf("Read value different from writen value\n"); if (dev_rls(dd) < 0) exit(1); return 0; } /****** End main() ******/
void async_wait_at(const time_type& expiry_time) { async_wait(expiry_time - now()); }
void uwsgi_proxy(int proxyfd) { int efd ; #ifdef __linux__ struct epoll_event *eevents; struct epoll_event ev; #elif defined(__sun__) struct pollfd *eevents; struct pollfd ev; #else struct kevent *eevents; struct kevent ev; #endif int max_events = 64; int nevents, i; const int nonblocking = 1; const int blocking = 0; char buffer[4096]; ssize_t rlen; ssize_t wlen; int max_connections = sysconf(_SC_OPEN_MAX); int soopt; socklen_t solen = sizeof(int); int rc; struct uwsgi_proxy_connection *upcs; struct sockaddr_in upc_addr; socklen_t upc_len = sizeof(struct sockaddr_in); int next_node = -1; fprintf(stderr, "spawned uWSGI proxy (pid: %d)\n", getpid()); fprintf(stderr, "allocating space for %d concurrent proxy connections\n", max_connections); // allocate memory for connections upcs = malloc(sizeof(struct uwsgi_proxy_connection) * max_connections); if (!upcs) { uwsgi_error("malloc()"); exit(1); } memset(upcs, 0, sizeof(struct uwsgi_proxy_connection) * max_connections); efd = async_queue_init(proxyfd); if (efd < 0) { exit(1); } #ifdef __linux__ eevents = malloc(sizeof(struct epoll_event) * max_events); memset(&ev, 0, sizeof(struct epoll_event)); #elif defined(__sun) eevents = malloc(sizeof(struct pollfd) * max_events); memset(&ev, 0, sizeof(struct pollfd)); #else eevents = malloc(sizeof(struct kevent) * max_events); memset(&ev, 0, sizeof(struct kevent)); #endif if (!eevents) { uwsgi_error("malloc()"); exit(1); } signal(SIGINT, (void *) &end_proxy); signal(SIGTERM, (void *) &reload_proxy); signal(SIGHUP, (void *) &reload_proxy); // and welcome to the loop... for (;;) { nevents = async_wait(efd, eevents, max_events, -1, 0); if (nevents < 0) { uwsgi_error("epoll_wait()"); continue; } for (i = 0; i < nevents; i++) { if (eevents[i].ASYNC_FD == proxyfd) { if (eevents[i].ASYNC_IS_IN) { // new connection, accept it ev.ASYNC_FD = accept(proxyfd, (struct sockaddr *) &upc_addr, &upc_len); if (ev.ASYNC_FD < 0) { uwsgi_error("accept()"); continue; } upcs[ev.ASYNC_FD].node = -1; // now connect to the first worker available upcs[ev.ASYNC_FD].dest_fd = socket(AF_INET, SOCK_STREAM, 0); if (upcs[ev.ASYNC_FD].dest_fd < 0) { uwsgi_error("socket()"); uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } upcs[upcs[ev.ASYNC_FD].dest_fd].node = -1; // set nonblocking if (ioctl(upcs[ev.ASYNC_FD].dest_fd, FIONBIO, &nonblocking)) { uwsgi_error("ioctl()"); uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } upcs[ev.ASYNC_FD].status = 0; upcs[ev.ASYNC_FD].retry = 0; next_node = uwsgi_proxy_find_next_node(next_node); if (next_node == -1) { fprintf(stderr, "unable to find an available worker in the cluster !\n"); uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } upcs[upcs[ev.ASYNC_FD].dest_fd].node = next_node; rc = connect(upcs[ev.ASYNC_FD].dest_fd, (struct sockaddr *) &uwsgi.shared->nodes[next_node].ucn_addr, sizeof(struct sockaddr_in)); uwsgi.shared->nodes[next_node].connections++; if (!rc) { // connected to worker, put it in the epoll_list if (async_add(efd, ev.ASYNC_FD, ASYNC_IN)) { uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } upcs[upcs[ev.ASYNC_FD].dest_fd].dest_fd = ev.ASYNC_FD; upcs[upcs[ev.ASYNC_FD].dest_fd].status = 0; upcs[upcs[ev.ASYNC_FD].dest_fd].retry = 0; ev.ASYNC_FD = upcs[ev.ASYNC_FD].dest_fd; if (async_add(efd, ev.ASYNC_FD, ASYNC_IN)) { uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } // re-set blocking if (ioctl(upcs[upcs[ev.ASYNC_FD].dest_fd].dest_fd, FIONBIO, &blocking)) { uwsgi_error("ioctl()"); uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } } else if (errno == EINPROGRESS) { // the socket is waiting, set status to CONNECTING upcs[ev.ASYNC_FD].status = UWSGI_PROXY_WAITING; upcs[upcs[ev.ASYNC_FD].dest_fd].dest_fd = ev.ASYNC_FD; upcs[upcs[ev.ASYNC_FD].dest_fd].status = UWSGI_PROXY_CONNECTING; upcs[upcs[ev.ASYNC_FD].dest_fd].retry = 0; ev.ASYNC_FD = upcs[ev.ASYNC_FD].dest_fd; if (async_add(efd, ev.ASYNC_FD, ASYNC_OUT)) { uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } } else { // connection failed, retry with the next node ? uwsgi_error("connect()"); // close only when all node are tried uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } } else { fprintf(stderr, "!!! something horrible happened to the uWSGI proxy, reloading it !!!\n"); exit(1); } } else { // this is for clients/workers if (eevents[i].ASYNC_IS_IN) { // is this a connected client/worker ? //fprintf(stderr,"ready %d\n", upcs[eevents[i].data.fd].status); if (!upcs[eevents[i].ASYNC_FD].status) { if (upcs[eevents[i].ASYNC_FD].dest_fd >= 0) { rlen = read(eevents[i].ASYNC_FD, buffer, 4096); if (rlen < 0) { uwsgi_error("read()"); uwsgi_proxy_close(upcs, eevents[i].ASYNC_FD); continue; } else if (rlen == 0) { uwsgi_proxy_close(upcs, eevents[i].ASYNC_FD); continue; } else { wlen = write(upcs[eevents[i].ASYNC_FD].dest_fd, buffer, rlen); if (wlen != rlen) { uwsgi_error("write()"); uwsgi_proxy_close(upcs, eevents[i].ASYNC_FD); continue; } } } else { uwsgi_proxy_close(upcs, eevents[i].ASYNC_FD); continue; } } else if (upcs[eevents[i].ASYNC_FD].status == UWSGI_PROXY_WAITING) { // disconnected node continue; } else { fprintf(stderr, "UNKNOWN STATUS %d\n", upcs[eevents[i].ASYNC_FD].status); continue; } } else if (eevents[i].ASYNC_IS_OUT) { if (upcs[eevents[i].ASYNC_FD].status == UWSGI_PROXY_CONNECTING) { #ifdef UWSGI_PROXY_USE_KQUEUE if (getsockopt(eevents[i].ASYNC_FD, SOL_SOCKET, SO_ERROR, (void *) (&soopt), &solen) < 0) { uwsgi_error("getsockopt()"); uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } /* is something bad ? */ if (soopt) { fprintf(stderr, "connect() %s\n", strerror(soopt)); // increase errors on node fprintf(stderr, "*** marking cluster node %d/%s as failed ***\n", upcs[eevents[i].ASYNC_FD].node, uwsgi.shared->nodes[upcs[eevents[i].ASYNC_FD].node].name); uwsgi.shared->nodes[upcs[eevents[i].ASYNC_FD].node].errors++; uwsgi.shared->nodes[upcs[eevents[i].ASYNC_FD].node].status = UWSGI_NODE_FAILED; uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } // increase errors on node #endif ev.ASYNC_FD = upcs[eevents[i].ASYNC_FD].dest_fd; upcs[ev.ASYNC_FD].status = 0; if (async_add(efd, ev.ASYNC_FD, ASYNC_IN)) { uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } ev.ASYNC_FD = upcs[ev.ASYNC_FD].dest_fd; upcs[ev.ASYNC_FD].status = 0; if (async_mod(efd, ev.ASYNC_FD, ASYNC_IN)) { uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } // re-set blocking if (ioctl(ev.ASYNC_FD, FIONBIO, &blocking)) { uwsgi_error("ioctl()"); uwsgi_proxy_close(upcs, ev.ASYNC_FD); continue; } } else { fprintf(stderr, "strange event for %d\n", (int) eevents[i].ASYNC_FD); } } else { if (upcs[eevents[i].ASYNC_FD].status == UWSGI_PROXY_CONNECTING) { if (getsockopt(eevents[i].ASYNC_FD, SOL_SOCKET, SO_ERROR, (void *) (&soopt), &solen) < 0) { uwsgi_error("getsockopt()"); } /* is something bad ? */ if (soopt) { fprintf(stderr, "connect() %s\n", strerror(soopt)); } // increase errors on node fprintf(stderr, "*** marking cluster node %d/%s as failed ***\n", upcs[eevents[i].ASYNC_FD].node, uwsgi.shared->nodes[upcs[eevents[i].ASYNC_FD].node].name); uwsgi.shared->nodes[upcs[eevents[i].ASYNC_FD].node].errors++; uwsgi.shared->nodes[upcs[eevents[i].ASYNC_FD].node].status = UWSGI_NODE_FAILED; } else { fprintf(stderr, "STRANGE EVENT !!! %d %d %d\n", (int) eevents[i].ASYNC_FD, (int) eevents[i].ASYNC_EV, upcs[eevents[i].ASYNC_FD].status); } uwsgi_proxy_close(upcs, eevents[i].ASYNC_FD); continue; } } } } }
void on_start() { expected_deadline_ = boost::posix_time::microsec_clock::universal_time() + period_; expires_from_now( period_ ); async_wait( boost::bind( &periodic_timer::handler, this, boost::asio::placeholders::error ) ); }
/** * Both signals for an Async object to finish up and waits for it to finish. * This is akin to calling both `signal` and `wait` in succession: * - Async.signal(async); * - Async.wait(async); * * @return 0 on success and -1 of error. */ static void async_finish(async_p async) { async_signal(async); async_wait(async); }