示例#1
0
/**
 * Called to close and cleanup a client connection.
 * Must be called when the connection is not already
 * scheduled. e.g. After ev_io_stop() has been called.
 * Leaves the connection in the conns list so that it
 * can be re-used.
 * @arg conn The connection to close
 */
void close_client_connection(conn_info *conn) {
    // Stop the libev clients
    ev_io_stop(conn->thread_ev->loop, &conn->client);
    ev_io_stop(conn->thread_ev->loop, &conn->write_client);

    // Clear everything out
    circbuf_free(&conn->input);
    circbuf_free(&conn->output);

    // Close the fd
    syslog(LOG_DEBUG, "Closed connection. [%d]", conn->client.fd);
    close(conn->client.fd);
    free(conn);
}
示例#2
0
//------------------------------------------------------------------------------
tOplkError dllkcal_exit(void)
{
    tOplkError      ret = kErrorOk;

#ifdef CONFIG_INCLUDE_NMT_MN
    if (instance_l.pQueueCnRequestGen != NULL)
        circbuf_free(instance_l.pQueueCnRequestGen);

    if (instance_l.pQueueCnRequestNmt != NULL)
        circbuf_free(instance_l.pQueueCnRequestNmt);

    if (instance_l.pQueueIdentReq != NULL)
        circbuf_free(instance_l.pQueueIdentReq);

    if (instance_l.pQueueStatusReq != NULL)
        circbuf_free(instance_l.pQueueStatusReq);
#endif

    if (instance_l.pTxNmtFuncs != NULL)
        instance_l.pTxNmtFuncs->pfnDelInstance(instance_l.dllCalQueueTxNmt);

    if (instance_l.pTxGenFuncs != NULL)
        instance_l.pTxGenFuncs->pfnDelInstance(instance_l.dllCalQueueTxGen);

#if defined(CONFIG_INCLUDE_NMT_MN)
    if (instance_l.pTxSyncFuncs != NULL)
        instance_l.pTxSyncFuncs->pfnDelInstance(instance_l.dllCalQueueTxSync);
#endif
#if defined(CONFIG_INCLUDE_VETH)
    if (instance_l.pTxVethFuncs != NULL)
        instance_l.pTxVethFuncs->pfnDelInstance(instance_l.dllCalQueueTxVeth);
#endif

    // reset instance structure
    OPLK_MEMSET(&instance_l, 0, sizeof (instance_l));

    return ret;
}
//------------------------------------------------------------------------------
static tOplkError delInstance(tDllCalQueueInstance pDllCalQueue_p)
{
    tCircBufError               error;
    tDllCalCircBufInstance*     pDllCalCircBufInstance =
                                    (tDllCalCircBufInstance*)pDllCalQueue_p;

    error = circbuf_free(pDllCalCircBufInstance->pCircBufInstance);
    if (error != kCircBufOk)
    {
        return kErrorNoResource;
    }
    OPLK_FREE(pDllCalCircBufInstance);
    return kErrorOk;
}
//------------------------------------------------------------------------------
tOplkError sdotestcom_delInstance(void)
{
    tOplkError    ret = kErrorOk;
    tOplkError    Sequret;
    tCircBufError Cbret;

    // Free shared buffer
    Cbret = circbuf_free(sdoTestComInst.tCmdCon.pCbBufInst);

    // Release sequence layer resources
    Sequret = sdoseq_delInstance();

    if ((kCircBufOk != Cbret) ||
       (kErrorOk != Sequret))
    {
        ret = kErrorInvalidOperation;
    }
    else
    {
        ret = kErrorOk;
    }

    return ret;
}