Logo Search packages:      
Sourcecode: obexd version File versions  Download package

void gw_obex_close ( GwObex ctx  ) 

Close GW OBEX connection and free all memory associated with it.

Parameters:
ctx Pointer returned by gw_obex_setup(). Cannot be used anymore after this calling this function.

Definition at line 285 of file gw-obex.c.

References gw_obex_xfer_close().

                                {
    GW_OBEX_LOCK(ctx);
    if (ctx->xfer) {
        GwObexXfer *xfer = ctx->xfer;
        GW_OBEX_UNLOCK(ctx);
        gw_obex_xfer_close(ctx->xfer, NULL);
        GW_OBEX_LOCK(ctx);
        /* In the async case the caller of put/get_async owns the xfer object */
        if (!xfer->async)
            _gw_obex_xfer_free(xfer);
        ctx->xfer = NULL;
    }
    if (ctx->conn_fd >= 0) {
        if (!gw_obex_disconnect(ctx))
            debug("OBEX Disconnect command failed\n");
        OBEX_TransportDisconnect(ctx->handle);
        close(ctx->conn_fd);
        ctx->conn_fd = -1;
    }
    if (ctx->handle) {
        OBEX_Cleanup(ctx->handle);
        ctx->handle = NULL;
    }
    if (ctx->gio) {
        g_io_channel_unref(ctx->gio);
        ctx->gio = NULL;
    }
    if (ctx->gio_source) {
        g_source_destroy(ctx->gio_source);
        ctx->gio_source = NULL;
    }
    GW_OBEX_UNLOCK(ctx);
#ifdef GW_OBEX_THREADS_ENABLED
    g_mutex_free(ctx->mutex);
    ctx->mutex = NULL;
#endif
    g_free(ctx);
}


Generated by  Doxygen 1.6.0   Back to index