src/siri/admin/client.c
/*
 * Called when a connection to the 'other' siridb server is made.
 * An authentication request will be send by user/password since this will be
 * using the client connection. (a signal can be raised)
 */
Called when a connection to the 'other' siridb server is made.
An authentication request will be send by user/password since this will be
using the client connection. (a signal can be raised)
Called when a connection to the ' other ' siridb server is made . An authentication request will be send by user / password since this will be using the client connection . ( a signal can be raised )
static void CLIENT_on_connect(uv_connect_t * req, int status)
{
    sirinet_socket_t * ssocket = req->handle->data;
    siri_admin_client_t * adm_client = (siri_admin_client_t *) ssocket->origin;
    if (status == 0)
    {
        log_debug(
                "Connected to SiriDB server: '%s:%u', "
                "sending authentication request",
                adm_client->host, adm_client->port);
        uv_read_start(
                req->handle,
                sirinet_socket_alloc_buffer,
                sirinet_socket_on_data);
        sirinet_pkg_t * pkg;
        qp_packer_t * packer = sirinet_packer_new(512);
        if (packer == NULL)
        {
            CLIENT_err(adm_client, "memory allocation error");
        }
        else
        {
            if (qp_add_type(packer, QP_ARRAY3) ||
                qp_add_string(packer, adm_client->username) ||
                qp_add_string(packer, adm_client->password) ||
                qp_add_string(packer, adm_client->dbname))
            {
                qp_packer_free(packer);
            }
            else
            {
                pkg = sirinet_packer2pkg(packer, 0, CPROTO_REQ_AUTH);
                CLIENT_send_pkg(adm_client, pkg);
            }
        }
    }
    else
    {
        CLIENT_err(
                adm_client,
                "connecting to server '%s:%u' failed with error: %s",
                adm_client->host,
                adm_client->port,
                uv_strerror(status));
    }
    free(req);
}
static void CLIENT_on_connect ( uv_connect_t * req , int status ) { sirinet_socket_t * ssocket = req -> handle -> data ; siri_admin_client_t * adm_client = ( siri_admin_client_t * ) ssocket -> origin ; if ( status == 0 ) { log_debug ( " " " " , adm_client -> host , adm_client -> port ) ; uv_read_start ( req -> handle , sirinet_socket_alloc_buffer , sirinet_socket_on_data ) ; sirinet_pkg_t * pkg ; qp_packer_t * packer = sirinet_packer_new ( 512 ) ; if ( packer == NULL ) { CLIENT_err ( adm_client , " " ) ; } else { if ( qp_add_type ( packer , QP_ARRAY3 ) || qp_add_string ( packer , adm_client -> username ) || qp_add_string ( packer , adm_client -> password ) || qp_add_string ( packer , adm_client -> dbname ) ) { qp_packer_free ( packer ) ; } else { pkg = sirinet_packer2pkg ( packer , 0 , CPROTO_REQ_AUTH ) ; CLIENT_send_pkg ( adm_client , pkg ) ; } } } else { CLIENT_err ( adm_client , " " , adm_client -> host , adm_client -> port , uv_strerror ( status ) ) ; } free ( req ) ; }
Called when a connection to the 'other' siridb server is made.
Called when a connection to the ' other ' siridb server is made .