* programs; these can be found in the section marked "Synchronous API".
*/
+/**
+ * ctdb_log_fn_t - logging function for ctdbd
+ * @log_priv: private (typesafe) arg via ctdb_connect
+ * @severity: syslog-style severity
+ * @format: printf-style format string.
+ * @ap: arguments for formatting.
+ *
+ * The severity passed to log() are as per syslog(3). In particular,
+ * LOG_DEBUG is used for tracing, LOG_WARNING is used for unusual
+ * conditions which don't necessarily return an error through the API,
+ * LOG_ERR is used for errors such as lost communication with ctdbd or
+ * out-of-memory, LOG_ALERT is used for library usage bugs, LOG_CRIT is
+ * used for libctdb internal consistency checks.
+ *
+ * The log() function can be typesafe: the @log_priv arg to
+ * ctdb_donnect and signature of log() should match.
+ */
typedef void (*ctdb_log_fn_t)(void *log_priv,
int severity, const char *format, va_list ap);
* Returns a ctdb context if successful or NULL. Use ctdb_free() to
* release the returned ctdb_connection when finished.
*
- * The log() function can be typesafe: the log_priv arg and signature
- * of log() should match. The priority passed to log() os as per
- * syslog(3).
- *
* See Also:
- * ctdb_log_file()
+ * ctdb_log_fn_t, ctdb_log_file()
*/
struct ctdb_connection *ctdb_connect(const char *addr,
ctdb_log_fn_t log_fn, void *log_priv);
/* Library user error if this isn't a reply to a call. */
if (req->hdr.hdr->operation != CTDB_REQ_CALL) {
errno = EINVAL;
- DEBUG(ctdb, LOG_ERR,
+ DEBUG(ctdb, LOG_ALERT,
"This was not a ctdbd call request: operation %u",
req->hdr.hdr->operation);
return NULL;
if (req->hdr.call->callid != callid) {
errno = EINVAL;
- DEBUG(ctdb, LOG_ERR,
+ DEBUG(ctdb, LOG_ALERT,
"This was not a ctdbd %u call request: %u",
callid, req->hdr.call->callid);
return NULL;
/* Library user error if this isn't a reply to a call. */
if (len < sizeof(*inhdr)) {
errno = EINVAL;
- DEBUG(ctdb, LOG_CRIT,
+ DEBUG(ctdb, LOG_ALERT,
"Short ctdbd control reply: %zu bytes", len);
return NULL;
}
if (req->hdr.hdr->operation != CTDB_REQ_CONTROL) {
errno = EINVAL;
- DEBUG(ctdb, LOG_ERR,
+ DEBUG(ctdb, LOG_ALERT,
"This was not a ctdbd control request: operation %u",
req->hdr.hdr->operation);
return NULL;
/* ... or if it was a different control from what we expected. */
if (req->hdr.control->opcode != control) {
errno = EINVAL;
- DEBUG(ctdb, LOG_ERR,
+ DEBUG(ctdb, LOG_ALERT,
"This was not an opcode %u ctdbd control request: %u",
control, req->hdr.control->opcode);
return NULL;
}
if (holding_lock(ctdb)) {
- DEBUG(ctdb, LOG_WARNING, "Do not block while holding lock!");
+ DEBUG(ctdb, LOG_ALERT, "Do not block while holding lock!");
}
if (revents & POLLOUT) {
static void free_lock(struct ctdb_lock *lock)
{
if (lock->held_magic) {
- DEBUG(lock->ctdb_db->ctdb, LOG_CRIT,
+ DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"free_lock invalid lock %p", lock);
}
free(lock->hdr);
void ctdb_release_lock(struct ctdb_lock *lock)
{
if (lock->held_magic != lock_magic(lock)) {
- DEBUG(lock->ctdb_db->ctdb, LOG_CRIT,
+ DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"ctdb_release_lock invalid lock %p", lock);
} else {
tdb_chainunlock(lock->ctdb_db->tdb, lock->key);
TDB_DATA data;
if (holding_lock(ctdb_db->ctdb)) {
- DEBUG(ctdb_db->ctdb, LOG_ERR,
+ DEBUG(ctdb_db->ctdb, LOG_ALERT,
"ctdb_readrecordlock_async: already holding lock");
return false;
}
{
if (lock->held_magic != lock_magic(lock)) {
errno = EBADF;
- DEBUG(lock->ctdb_db->ctdb, LOG_ERR,
+ DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"ctdb_writerecord: Can not write. Lock has been released.");
return -1;
}
if (lock->ctdb_db->persistent) {
errno = EINVAL;
- DEBUG(lock->ctdb_db->ctdb, LOG_ERR,
+ DEBUG(lock->ctdb_db->ctdb, LOG_ALERT,
"ctdb_writerecord: cannot write to persistent db");
return -1;
}