gensio_close(3)

NAME
gensio_close, gensio_close_s, gensio_disable, gensio_free - Stop/free a gensio that is open

SYNOPSIS
#include <gensio/gensio.h>

typedef void (*gensio_done)(struct gensio *io, void *close_data);

int gensio_close(struct gensio *io, gensio_done close_done,
    void *close_data);

int gensio_close_s(struct gensio *io);

void gensio_disable(struct gensio *io);

void gensio_free(struct gensio *io);

gensio_close closes an open gensio. Note that the close operation is not complete until close_done() is called. This shuts down internal file descriptors and such, but does not free the gensio. If the gensio is a connecting one, you can generally re-open it. If you gensio_close before an open done is reported, the results (primarily whether the open done is called) are undefined. If the open done is called, it will be called before the close done. gensio_close_s is like gensio_close, but blocks until the operation is complete. BE VERY CAREFUL WITH THIS FUNCTION. Do not call it from a callback because it waits until all operations on the gensio are done, and they won't be done until the callback returns. You will deadlock if you do this. gensio_disable disables operation of the gensio so that closing will not result in any data being transmitted. THIS IS FOR EXTREMELY LIMITED USE. This will not close file descriptors nor disable I/O, necessarily, but will put the gensio stack into a state where freeing will not result in any transmission of data to the other end. You MUST be in a state where no callbacks are running or can run. This is primarily to allow a close of something like an SSL connection after a fork. If you didn't have this, the normal close in the one fork would shut down the SSL connection for the other fork, too. See gensio(5) for details on forking. gensio_free frees data associated with the gensio. If it is open, the gensio is closed. If you call gensio_free after gensio_close before the close_done callback is called, whether close_done is called is undefined.

RETURN VALUES
Zero is returned on success, or a gensio error on failure.

SEE ALSO
gensio_err(3), gensio(5)