-.\" $OpenBSD: smtpd-tables.7,v 1.2 2024/05/22 08:39:50 op Exp $
+.\" $OpenBSD: smtpd-tables.7,v 1.3 2024/05/23 17:10:00 op Exp $
.\"
.\" Copyright (c) 2008 Janne Johansson <jj@openbsd.org>
.\" Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net>
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\"
-.Dd $Mdocdate: May 22 2024 $
+.Dd $Mdocdate: May 23 2024 $
.Dt SMTPD-TABLES 7
.Os
.Sh NAME
.Sq ok
on success or
.Sq error
-upon a failure to do so.
+and a message upon a failure to do so.
.It Cm check Ar service id query
Check whether
.Ar query
.Sq not-found
if not, or
.Sq error
-upon an error.
+and a message upon an error.
.It Cm lookup Ar service id query
Look up a value in the table for given the
.Ar query .
.Sq not-found
if not found, or
.Sq error
-upon an error.
+and a message upon an error.
.It Cm fetch Ar service id
Fetch the next item from the table, eventually wrapping around.
It is only supported for the
.Sq not-found
if the table is empty, or
.Sq error
-upon an error.
+and a message upon an error.
.El
.Pp
Each service has a specific format for the result.
.Sh EXAMPLES
Assuming the table is called
.Dq devs ,
-here's an example of a successful
+here's an example of a failed
.Cm update
transaction:
.Bd -literal -offset indent
table|0.1|1713795097.394049|devs|update|478ff0d2
-update-result|478ff0d2|ok
+update-result|478ff0d2|error|failed to connect to the database
.Ed
.Pp
A
-/* $OpenBSD: table_proc.c,v 1.21 2024/05/23 17:05:45 op Exp $ */
+/* $OpenBSD: table_proc.c,v 1.22 2024/05/23 17:10:00 op Exp $ */
/*
* Copyright (c) 2024 Omar Polo <op@openbsd.org>
r = table_proc_recv(table, "update-result");
if (!strcmp(r, "ok"))
return (1);
- if (!strcmp(r, "error"))
+
+ if (!strncmp(r, "error", 5)) {
+ if (r[5] == '|') {
+ r += 6;
+ log_warnx("warn: table-proc: %s update failed: %s",
+ table->t_name, r);
+ }
return (0);
+ }
log_warnx("warn: table-proc: failed parse reply");
fatalx("table-proc: exiting");
table_proc_send(table, req, s, k);
r = table_proc_recv(table, res);
- /* common replies */
if (!strcmp(r, "not-found"))
return (0);
- if (!strcmp(r, "error"))
+
+ if (!strncmp(r, "error", 5)) {
+ if (r[5] == '|') {
+ r += 6;
+ log_warnx("warn: table-proc: %s %s failed: %s",
+ table->t_name, req, r);
+ }
return (-1);
+ }
if (dst == NULL) {
/* check op */
if (!strcmp(r, "not-found"))
return (0);
- if (!strcmp(r, "error"))
+
+ if (!strncmp(r, "error", 5)) {
+ if (r[5] == '|') {
+ r += 6;
+ log_warnx("warn: table-proc: %s fetch failed: %s",
+ table->t_name, r);
+ }
return (-1);
+ }
if (strncmp(r, "found|", 6) != 0) {
log_warnx("warn: table-proc: failed to parse reply");