当前位置: 首页>>代码示例>>C++>>正文


C++ port_associate函数代码示例

本文整理汇总了C++中port_associate函数的典型用法代码示例。如果您正苦于以下问题:C++ port_associate函数的具体用法?C++ port_associate怎么用?C++ port_associate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了port_associate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fpm_event_port_add

/*
 * Add a FD to the fd set
 */
static int fpm_event_port_add(struct fpm_event_s *ev) /* {{{ */
{
	/* add the event to port */
	if (port_associate(pfd, PORT_SOURCE_FD, ev->fd, POLLIN, (void *)ev) < 0) {
		zlog(ZLOG_ERROR, "port: unable to add the event");
		return -1;
	}
	return 0;
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:12,代码来源:port.c

示例2: vws_add

static inline void
vws_add(struct vws *vws, int fd, void *data)
{
	/*
	 * POLLIN should be all we need here
	 *
	 */
	AZ(port_associate(vws->dport, PORT_SOURCE_FD, fd, POLLIN, data));
}
开发者ID:gsandie,项目名称:Varnish-Cache,代码行数:9,代码来源:cache_waiter_ports.c

示例3: event_queue_add_fd_write

int event_queue_add_fd_write(int eq, int fd) {

        if (port_associate(eq, PORT_SOURCE_FD, fd, POLLOUT, NULL)) {
                uwsgi_error("port_associate");
                return -1;
        }

        return fd;
}
开发者ID:dpetzold,项目名称:uwsgi,代码行数:9,代码来源:event.c

示例4: vca_add

static inline void
vca_add(int fd, void *data)
{
	/*
	 * POLLIN should be all we need here
	 *
	 */
	AZ(port_associate(solaris_dport, PORT_SOURCE_FD, fd, POLLIN, data));
}
开发者ID:QES,项目名称:Varnish-Cache,代码行数:9,代码来源:cache_waiter_ports.c

示例5: ph_nbio_emitter_apply_io_mask

ph_result_t ph_nbio_emitter_apply_io_mask(struct ph_nbio_emitter *emitter,
    ph_job_t *job, ph_iomask_t mask)
{
  int res;
  int want_mask = 0;

  if (job->fd == -1) {
    return PH_OK;
  }

  switch (mask & (PH_IOMASK_READ|PH_IOMASK_WRITE)) {
    case PH_IOMASK_READ:
      want_mask = POLLIN|DEFAULT_POLL_MASK;
      break;
    case PH_IOMASK_WRITE:
      want_mask = POLLOUT|DEFAULT_POLL_MASK;
      break;
    case PH_IOMASK_READ|PH_IOMASK_WRITE:
      want_mask = POLLIN|POLLOUT|DEFAULT_POLL_MASK;
      break;
    case 0:
    default:
      want_mask = 0;
  }

  if (want_mask == job->kmask) {
    return PH_OK;
  }

  switch (want_mask) {
    case 0:
      res = port_dissociate(emitter->io_fd, PORT_SOURCE_FD, job->fd);
      if (res != 0 && errno == ENOENT) {
        res = 0;
      }
      if (res != 0) {
        ph_panic("port_dissociate: setting mask to %02x on fd %d -> `Pe%d",
            mask, job->fd, errno);
      }
      job->kmask = 0;
      job->mask = 0;
      break;

    default:
      job->mask = mask;
      job->kmask = want_mask;
      res = port_associate(emitter->io_fd, PORT_SOURCE_FD, job->fd,
          want_mask, job);
      if (res != 0) {
        ph_panic("port_associate: setting mask to %02x on fd %d -> `Pe%d",
            mask, job->fd, errno);
        return PH_ERR;
      }
  }
  return PH_OK;
}
开发者ID:alemic,项目名称:libphenom,代码行数:56,代码来源:portfs.c

示例6: event_queue_fd_read_to_readwrite

int event_queue_fd_read_to_readwrite(int eq, int fd) {

    if (port_associate(eq, PORT_SOURCE_FD, fd, POLLIN|POLLOUT, NULL)) {
        uwsgi_error("port_associate");
        return -1;
    }

    return 0;

}
开发者ID:StephenPierce,项目名称:uwsgi,代码行数:10,代码来源:event.c

示例7: ngx_eventport_del_event

static ngx_int_t
ngx_eventport_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
    ngx_event_t       *e;
    ngx_connection_t  *c;
    /*
     * when the file descriptor is closed, the event port automatically
     * dissociates it from the port, so we do not need to dissociate explicitly
     * the event before the closing the file descriptor
     */
    if (flags & NGX_CLOSE_EVENT)
    {
        ev->active = 0;
        ev->oneshot = 0;
        return NGX_OK;
    }
    c = ev->data;
    if (event == NGX_READ_EVENT)
    {
        e = c->write;
        event = POLLOUT;
    }
    else
    {
        e = c->read;
        event = POLLIN;
    }
    if (e->oneshot)
    {
        ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
                       "eventport change event: fd:%d ev:%04Xi", c->fd, event);
        if (port_associate(ep, PORT_SOURCE_FD, c->fd, event,
                           (void *)((uintptr_t) ev | ev->instance))
                == -1)
        {
            ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
                          "port_associate() failed");
            return NGX_ERROR;
        }
    }
    else
    {
        ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0,
                       "eventport del event: fd:%d", c->fd);
        if (port_dissociate(ep, PORT_SOURCE_FD, c->fd) == -1)
        {
            ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
                          "port_dissociate() failed");
            return NGX_ERROR;
        }
    }
    ev->active = 0;
    ev->oneshot = 0;
    return NGX_OK;
}
开发者ID:icylord,项目名称:Nginx_1.9.3_VS2013,代码行数:55,代码来源:ngx_eventport_module.c

示例8: uv__fs_event_rearm

static int uv__fs_event_rearm(uv_fs_event_t* handle) {
  if (handle->fd == -1) return 0;

  if (port_associate(handle->loop->fs_fd, PORT_SOURCE_FILE,
                     (uintptr_t) & handle->fo, FILE_ATTRIB | FILE_MODIFIED,
                     handle) == -1) {
    uv__set_sys_error(handle->loop, errno);
    return -1;
  }
  handle->fd = PORT_LOADED;
  return 0;
}
开发者ID:Andrepuel,项目名称:jxcore,代码行数:12,代码来源:sunos.c

示例9: ioctlsocket

bool SelEpolKqEvPrt::registerForEvent(SOCKET descriptor)
{
	curfds++;
	#ifdef OS_MINGW
		u_long iMode = 1;
		ioctlsocket(descriptor, FIONBIO, &iMode);
	#else
		fcntl(descriptor, F_SETFL, fcntl(descriptor, F_GETFD, 0) | O_NONBLOCK);
	#endif
	//fcntl(descriptor, F_SETFL, fcntl(descriptor, F_GETFD, 0) | O_NONBLOCK);
	#if defined(USE_MINGW_SELECT)
		FD_SET(descriptor, &master);
		if(descriptor > fdMax)
			fdMax = descriptor;
	#elif defined(USE_SELECT)
		FD_SET(descriptor%FD_SETSIZE, &master[descriptor/FD_SETSIZE]);
		if(descriptor > fdMax)
			fdMax = descriptor;
	#elif defined USE_EPOLL
		ev.events = EPOLLIN | EPOLLPRI;
		ev.data.fd = descriptor;
		if (epoll_ctl(epoll_handle, EPOLL_CTL_ADD, descriptor, &ev) < 0)
		{
			perror("epoll");
			logger << "Error adding to epoll cntl list" << endl;
			return false;
		}
	#elif defined USE_KQUEUE
		memset(&change, 0, sizeof(change));
		EV_SET(&change, descriptor, EVFILT_READ, EV_ADD, 0, 0, 0);
		kevent(kq, &change, 1, NULL, 0, NULL);
	#elif defined USE_DEVPOLL
		struct pollfd poll_fd;
		poll_fd.fd = descriptor;
		poll_fd.events = POLLIN;
		poll_fd.revents = 0;
		if (write(dev_poll_fd, &poll_fd, sizeof(poll_fd)) < 0) {
			perror("devpoll");
			return false;
		}
	#elif defined USE_EVPORT
		if (port_associate(port, PORT_SOURCE_FD, descriptor, POLLIN, NULL) < 0) {
			perror("port_associate");
		}
	#elif defined USE_POLL
		nfds++;
		polled_fds = (struct pollfd *)realloc(polled_fds, (nfds+1)*sizeof(struct pollfd));
		(polled_fds+nfds)->fd = descriptor;
		(polled_fds+nfds)->events = POLLIN | POLLPRI;
	#endif
	return true;
}
开发者ID:cddypang,项目名称:ffead-cpp,代码行数:52,代码来源:SelEpolKqEvPrt.cpp

示例10: impl_pollset_add

static apr_status_t impl_pollset_add(apr_pollset_t *pollset,
                                     const apr_pollfd_t *descriptor)
{
    apr_os_sock_t fd;
    pfd_elem_t *elem;
    int res;
    apr_status_t rv = APR_SUCCESS;

    pollset_lock_rings();

    if (!APR_RING_EMPTY(&(pollset->p->free_ring), pfd_elem_t, link)) {
        elem = APR_RING_FIRST(&(pollset->p->free_ring));
        APR_RING_REMOVE(elem, link);
    }
    else {
        elem = (pfd_elem_t *) apr_palloc(pollset->pool, sizeof(pfd_elem_t));
        APR_RING_ELEM_INIT(elem, link);
        elem->on_query_ring = 0;
    }
    elem->pfd = *descriptor;

    if (descriptor->desc_type == APR_POLL_SOCKET) {
        fd = descriptor->desc.s->socketdes;
    }
    else {
        fd = descriptor->desc.f->filedes;
    }

    /* If another thread is polling, notify the kernel immediately; otherwise,
     * wait until the next call to apr_pollset_poll().
     */
    if (apr_atomic_read32(&pollset->p->waiting)) {
        res = port_associate(pollset->p->port_fd, PORT_SOURCE_FD, fd, 
                             get_event(descriptor->reqevents), (void *)elem);

        if (res < 0) {
            rv = apr_get_netos_error();
            APR_RING_INSERT_TAIL(&(pollset->p->free_ring), elem, pfd_elem_t, link);
        }
        else {
            elem->on_query_ring = 1;
            APR_RING_INSERT_TAIL(&(pollset->p->query_ring), elem, pfd_elem_t, link);
        }
    } 
    else {
        APR_RING_INSERT_TAIL(&(pollset->p->add_ring), elem, pfd_elem_t, link);
    }

    pollset_unlock_rings();

    return rv;
}
开发者ID:Ga-vin,项目名称:apache,代码行数:52,代码来源:port.c

示例11: alter_fd_associate

static void alter_fd_associate(eventer_t e, int mask, struct ports_spec *spec) {
  int events = 0, s_errno = 0, ret;
  if(mask & EVENTER_READ) events |= POLLIN;
  if(mask & EVENTER_WRITE) events |= POLLOUT;
  if(mask & EVENTER_EXCEPTION) events |= POLLERR;
  errno = 0;
  ret = port_associate(spec->port_fd, PORT_SOURCE_FD, e->fd, events, (void *)(intptr_t)e->fd);
  s_errno = errno;
  if (ret == -1) {
    mtevFatal(mtev_error,
          "eventer port_associate failed(%d-%d): %d/%s\n", e->fd, spec->port_fd, s_errno, strerror(s_errno));
  }
}
开发者ID:esproul,项目名称:libmtev,代码行数:13,代码来源:eventer_ports_impl.c

示例12: port_associate

bool FdEventQueue::associate(fd_t fd, FdEvent::Type fd_event_types) {
  if (fd_event_types > 0) {
    return port_associate(
             port,
             PORT_SOURCE_FD,
             fd,
             fd_event_types,
             NULL
           ) != -1;
  } else {
    return dissociate(fd);
  }
}
开发者ID:respu,项目名称:yield,代码行数:13,代码来源:fd_event_queue.cpp

示例13: pe_update_events

void
pe_update_events(fde_t * F, short filter, PF * handler)
{
	PF *cur_handler = NULL;

	if (filter == POLLRDNORM)
		cur_handler = F->read_handler;
	else if (filter == POLLWRNORM)
		cur_handler = F->write_handler;

	if (!cur_handler && handler)
		port_associate(pe, PORT_SOURCE_FD, F->fd, filter, F);
	else if (cur_handler && !handler)
		port_dissociate(pe, PORT_SOURCE_FD, F->fd);
}
开发者ID:BackupTheBerlios,项目名称:phoenixfn-svn,代码行数:15,代码来源:ports.c

示例14: ngx_eventport_add_event

static ngx_int_t
ngx_eventport_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
    ngx_int_t          events, prev;
    ngx_event_t       *e;
    ngx_connection_t  *c;

    c = ev->data;

    events = event;

    if (event == NGX_READ_EVENT) {
        e = c->write;
        prev = POLLOUT;
#if (NGX_READ_EVENT != POLLIN)
        events = POLLIN;
#endif

    } else {
        e = c->read;
        prev = POLLIN;
#if (NGX_WRITE_EVENT != POLLOUT)
        events = POLLOUT;
#endif
    }

    if (e->oneshot) {
        events |= prev;
    }

    ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
                   "eventport add event: fd:%d ev:%04Xi", c->fd, events);

    if (port_associate(ep, PORT_SOURCE_FD, c->fd, events,
                       (void *) ((uintptr_t) ev | ev->instance))
        == -1)
    {
        ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
                      "port_associate() failed");
        return NGX_ERROR;
    }

    ev->active = 1;
    ev->oneshot = 1;

    return NGX_OK;
}
开发者ID:sudorails,项目名称:e_verification,代码行数:47,代码来源:ngx_eventport_module.c

示例15: port_associate

bool PortsEngine::AddFd(EventHandler* eh, int event_mask)
{
	int fd = eh->GetFd();
	if ((fd < 0) || (fd > GetMaxFds() - 1))
		return false;

	if (ref[fd])
		return false;

	ref[fd] = eh;
	SocketEngine::SetEventMask(eh, event_mask);
	port_associate(EngineHandle, PORT_SOURCE_FD, fd, mask_to_events(event_mask), eh);

	ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "New file descriptor: %d", fd);
	CurrentSetSize++;
	return true;
}
开发者ID:Paciik,项目名称:inspircd,代码行数:17,代码来源:socketengine_ports.cpp


注:本文中的port_associate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。