Exemplo n.º 1
0
tbx_ns_t *tbx_ns_new()
{
    tbx_ns_t *ns = (tbx_ns_t *)malloc(sizeof(tbx_ns_t));

    if (ns == NULL) {
        log_printf(0, "new_netstream: Failed malloc!!\n");
        abort();
    }

    assert_result(apr_pool_create(&(ns->mpool), NULL), APR_SUCCESS);
    apr_thread_mutex_create(&(ns->read_lock), APR_THREAD_MUTEX_DEFAULT,ns->mpool);
    apr_thread_mutex_create(&(ns->write_lock), APR_THREAD_MUTEX_DEFAULT,ns->mpool);

    _ns_init(ns, 0);
    ns->id = ns->cuid = -1;

    return(ns);
}
Exemplo n.º 2
0
void ns_config_sock(NetStream_t *ns, int tcpsize)
{
    log_printf(10, "ns_config_sock: ns=%d, \n", ns->id);

    _ns_init(ns, 0);

    ns->sock_type = NS_TYPE_SOCK;
    network_sock_t *sock = (network_sock_t *)malloc(sizeof(network_sock_t));
    assert(sock != NULL);
    memset(sock, 0, sizeof(network_sock_t));
    ns->sock = (net_sock_t *)sock;
//  assert_result_not(apr_pool_create(&(sock->mpool), NULL), APR_SUCCESS);
    int err = apr_pool_create(&(sock->mpool), NULL);
    if (err != APR_SUCCESS) {
        log_printf(0, "ns_config_sock:  apr_pool_crete error = %d\n", err);
        flush_log();
        assert(err == APR_SUCCESS);
    }

//**QWERT
    apr_thread_mutex_create(&(sock->lock), APR_THREAD_MUTEX_DEFAULT,sock->mpool);
//**QWERTY

    sock->tcpsize = tcpsize;
    ns->native_fd = sock_native_fd;
    ns->connect = sock_connect;
    ns->sock_status = sock_status;
    ns->set_peer = sock_set_peer;
    ns->close = sock_close;
//  ns->read = sock_read;
//  ns->write = sock_write;
    ns->read = sock_apr_read;
    ns->write = sock_apr_write;
    ns->accept = sock_accept;
    ns->bind = sock_bind;
    ns->listen = sock_listen;
    ns->connection_request = sock_connection_request;
}
Exemplo n.º 3
0
void ns_config_sock(NetStream_t *ns, int fd, int tcpsize)
{
  log_printf(10, "ns_config_sock: ns=%d, fd=%d\n", ns->id, fd);

  _ns_init(ns, 0);

  ns->sock_type = NS_TYPE_SOCK;
  network_sock_t *sock = (network_sock_t *)malloc(sizeof(network_sock_t));
  assert(sock != NULL);
  ns->sock = (net_sock_t *)sock;
  sock->fd = fd;
  sock->tcpsize = tcpsize;
  ns->connect = sock_connect;
  ns->sock_status = sock_status;
  ns->set_peer = sock_set_peer;
  ns->close = sock_close;
  ns->read = sock_read;
  ns->write = sock_write;
  ns->accept = sock_accept;
  ns->bind = sock_bind;
  ns->listen = sock_listen;
  ns->connection_request = sock_connection_request;
}
Exemplo n.º 4
0
void ns_config_phoebus(NetStream_t *ns, phoebus_t *path, int tcpsize)
{
  network_phoebus_t *sock = (network_phoebus_t *)malloc(sizeof(network_phoebus_t));

  _ns_init(ns, 0);
  
  ns->sock_type = NS_TYPE_PHOEBUS;
  ns->sock = (net_sock_t *)sock;

  sock->p_path = path;
  if (path == NULL) sock->p_path = global_phoebus;

  sock->fd = -1;
  sock->family = -1;
  sock->tcpsize = tcpsize;

  ns->connect = phoebus_connect;
  ns->sock_status = sock_status;
  ns->set_peer = phoebus_set_peer;
  ns->close = phoebus_close;
  ns->read = phoebus_read;
  ns->write = phoebus_write;
}
Exemplo n.º 5
0
void ns_init(tbx_ns_t *ns)
{
    _ns_init(ns, 1);
}
Exemplo n.º 6
0
void ns_init(NetStream_t *ns)
{
    _ns_init(ns, 1);
}