src/statserv.c
static int add_listener(char *where, int listen_id)
{
    COMSTACK l;
    void *ap;
    IOCHAN lst = NULL;
    const char *mode;

    if (control_block.dynamic)
        mode = "dynamic";
    else if (control_block.threads)
        mode = "threaded";
    else
        mode = "static";

    yaz_log(log_server, "Adding %s listener on %s id=%d PID=%ld", mode, where,
            listen_id, (long) getpid());

    l = cs_create_host(where, 2, &ap);
    if (!l)
    {
        yaz_log(YLOG_FATAL, "Failed to listen on %s", where);
        return -1;
    }
    if (*control_block.cert_fname)
        cs_set_ssl_certificate_file(l, control_block.cert_fname);

    if (cs_bind(l, ap, CS_SERVER) < 0)
    {
        if (cs_errno(l) == CSYSERR)
            yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to bind to %s", where);
        else
            yaz_log(YLOG_FATAL, "Failed to bind to %s: %s", where,
                    cs_strerror(l));
        cs_close(l);
        return -1;
    }
    if (!(lst = iochan_create(cs_fileno(l), listener, EVENT_INPUT |
                              EVENT_EXCEPT, listen_id)))
    {
        yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create IOCHAN-type");
        cs_close(l);
        return -1;
    }
    iochan_setdata(lst, l); /* user-defined data for listener is COMSTACK */
    l->user = lst;  /* user-defined data for COMSTACK is listener chan */

    /* Add listener to chain */
    lst->next = pListener;
    pListener = lst;
    return 0; /* OK */
}
/*
 * Set up a listening endpoint, and give it to the event-handler.
 */
Set up a listening endpoint, and give it to the event-handler.
Set up a listening endpoint and give it to the event - handler .
static int add_listener(char *where, int listen_id)
{
    COMSTACK l;
    void *ap;
    IOCHAN lst = NULL;
    const char *mode;
    if (control_block.dynamic)
        mode = "dynamic";
    else if (control_block.threads)
        mode = "threaded";
    else
        mode = "static";
    yaz_log(log_server, "Adding %s listener on %s id=%d PID=%ld", mode, where,
            listen_id, (long) getpid());
    l = cs_create_host(where, 2, &ap);
    if (!l)
    {
        yaz_log(YLOG_FATAL, "Failed to listen on %s", where);
        return -1;
    }
    if (*control_block.cert_fname)
        cs_set_ssl_certificate_file(l, control_block.cert_fname);
    if (cs_bind(l, ap, CS_SERVER) < 0)
    {
        if (cs_errno(l) == CSYSERR)
            yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to bind to %s", where);
        else
            yaz_log(YLOG_FATAL, "Failed to bind to %s: %s", where,
                    cs_strerror(l));
        cs_close(l);
        return -1;
    }
    if (!(lst = iochan_create(cs_fileno(l), listener, EVENT_INPUT |
                              EVENT_EXCEPT, listen_id)))
    {
        yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create IOCHAN-type");
        cs_close(l);
        return -1;
    }
    iochan_setdata(lst, l); 
    l->user = lst;  
    lst->next = pListener;
    pListener = lst;
    return 0; 
}
static int add_listener ( char * where , int listen_id ) { COMSTACK l ; void * ap ; IOCHAN lst = NULL ; const char * mode ; if ( control_block . dynamic ) mode = " " ; else if ( control_block . threads ) mode = " " ; else mode = " " ; yaz_log ( log_server , " " , mode , where , listen_id , ( long ) getpid ( ) ) ; l = cs_create_host ( where , 2 , & ap ) ; if ( ! l ) { yaz_log ( YLOG_FATAL , " " , where ) ; return -1 ; } if ( * control_block . cert_fname ) cs_set_ssl_certificate_file ( l , control_block . cert_fname ) ; if ( cs_bind ( l , ap , CS_SERVER ) < 0 ) { if ( cs_errno ( l ) == CSYSERR ) yaz_log ( YLOG_FATAL | YLOG_ERRNO , " " , where ) ; else yaz_log ( YLOG_FATAL , " " , where , cs_strerror ( l ) ) ; cs_close ( l ) ; return -1 ; } if ( ! ( lst = iochan_create ( cs_fileno ( l ) , listener , EVENT_INPUT | EVENT_EXCEPT , listen_id ) ) ) { yaz_log ( YLOG_FATAL | YLOG_ERRNO , " " ) ; cs_close ( l ) ; return -1 ; } iochan_setdata ( lst , l ) ; l -> user = lst ; lst -> next = pListener ; pListener = lst ; return 0 ; }
Set up a listening endpoint, and give it to the event-handler.
Set up a listening endpoint and give it to the event - handler .
/* user-defined data for listener is COMSTACK */ /* user-defined data for COMSTACK is listener chan */ /* Add listener to chain */ /* OK */