syslog: Added channel close callback.

This commit is contained in:
Fotis Panagiotopoulos 2021-06-17 17:45:01 +03:00 committed by Xiang Xiao
parent 83ac6cd399
commit b16de69e56
4 changed files with 13 additions and 5 deletions

View File

@ -94,10 +94,6 @@ FAR struct syslog_channel_s *syslog_dev_initialize(FAR const char *devpath,
* Input Parameters:
* channel - Handle to syslog channel to be used.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure.
*
* Assumptions:
* The caller has already switched the SYSLOG source to some safe channel
* (the default channel).

View File

@ -243,6 +243,15 @@ int syslog_channel_remove(FAR struct syslog_channel_s *channel)
g_syslog_channel[i] = NULL;
/* The channel is now removed from the list and its driver
* can be safely uninitialized.
*/
if (channel->sc_ops->sc_close)
{
channel->sc_ops->sc_close(channel);
}
return OK;
}
}

View File

@ -110,7 +110,8 @@ static const struct syslog_channel_ops_s g_syslog_dev_ops =
syslog_dev_putc,
syslog_dev_force,
syslog_dev_flush,
syslog_dev_write
syslog_dev_write,
syslog_dev_uninitialize
};
static const uint8_t g_syscrlf[2] =

View File

@ -93,6 +93,7 @@ typedef CODE ssize_t (*syslog_write_t)(FAR struct syslog_channel_s *channel,
typedef CODE int (*syslog_putc_t)(FAR struct syslog_channel_s *channel,
int ch);
typedef CODE int (*syslog_flush_t)(FAR struct syslog_channel_s *channel);
typedef CODE void (*syslog_close_t)(FAR struct syslog_channel_s *channel);
/* SYSLOG device operations */
@ -102,6 +103,7 @@ struct syslog_channel_ops_s
syslog_putc_t sc_force; /* Low-level output for interrupt handlers */
syslog_flush_t sc_flush; /* Flush buffered output (on crash) */
syslog_write_t sc_write; /* Write multiple bytes */
syslog_close_t sc_close; /* Channel close callback */
};
/* This structure provides the interface to a SYSLOG channel */