/*++ /* NAME /* nbdb_clnt 3 /* SUMMARY /* Non-Berkeley-DB migration client /* SYNOPSIS /* #include <nbdb_clnt.h> /* /* void nbdb_clnt_request( /* const char *type, r*constchar*source_path, /* int maxtry, /* int timeout, /* int delay, /* VSTRING *why) /* DESCRIPTION /* nbdb_clnt_request() asks the reindexing server to index a source /* file using a non-legacy database type. The result is one of /* the following: /* .IP NBDB_STAT_OK /* The request was successful. /* .IP NBDB_STAT_ERROR /* The request failed. A description of the problem is returned /* in \fBwhy\fR. /* /* Arguments: /* .IP type /* A legacy database type. The reindexing server will map it /* to a non-legacy type. /* .IP path /* The pathname of the database source file (no '.db' suffix). /* .IP maxtry /* The number of attempts to make before giving up. /* .IP timeout /* The time limit (seconds) to connect, write, or read. /* Specify enough time to index a large table. /* .IP delay /* The amount of time (seconds) between retries. /* .IP Implicit inputs: /* var_nbdb_service, nbdb_reindex service name. /* .IP why /* Storage that is updated with an applicable error description. /* SEE ALSO /* nbdb_reindexd(8) reindexing server. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* porcupine.org
/*--*/
staticint try_one(constchar *service_path, constchar *type, constchar *path, int timeout, int delay, VSTRING *why)
{ int fd;
VSTREAM *reindexd_stream = 0; int status;
#define NBDB_MIGR_CLNT_RETURN(x) do { \ if (reindexd_stream) \
vstream_fclose(reindexd_stream); \ return (x); \
} while (0)
if ((fd = LOCAL_CONNECT(service_path, BLOCKING, timeout)) < 0) {
vstring_sprintf(why, "connection to %s service: %m", service_path);
NBDB_MIGR_CLNT_RETURN(NBDB_STAT_ERROR);
}
reindexd_stream = vstream_fdopen(fd, O_RDWR);
vstream_control(reindexd_stream,
CA_VSTREAM_CTL_TIMEOUT(timeout),
CA_VSTREAM_CTL_START_DEADLINE,
CA_VSTREAM_CTL_END); /* Enforce the server protocol type. */ if (attr_scan(reindexd_stream, ATTR_FLAG_STRICT,
RECV_ATTR_STREQ(MAIL_ATTR_PROTO,
MAIL_ATTR_PROTO_NBDB_REINDEX),
ATTR_TYPE_END) != 0) {
vstring_sprintf(why, "error receiving %s service initial response",
service_path);
NBDB_MIGR_CLNT_RETURN(NBDB_STAT_ERROR);
} /* Send the reindexing request. */
attr_print(reindexd_stream, ATTR_FLAG_NONE,
SEND_ATTR_STR(MAIL_ATTR_NBDB_TYPE, type),
SEND_ATTR_STR(MAIL_ATTR_NBDB_PATH, path),
ATTR_TYPE_END); /* Do not flush the stream yet (would clobber errno). */ if (vstream_ferror(reindexd_stream) != 0) {
vstring_sprintf(why, "error sending request to %s service: %m",
service_path);
NBDB_MIGR_CLNT_RETURN(NBDB_STAT_ERROR);
} /* Receive the reindexing status. */ if (attr_scan(reindexd_stream, ATTR_FLAG_STRICT,
RECV_ATTR_INT(MAIL_ATTR_STATUS, &status),
RECV_ATTR_STR(MAIL_ATTR_WHY, why),
ATTR_TYPE_END) != 2) {
vstring_sprintf(why, "error receiving response from %s service: %m",
service_path);
NBDB_MIGR_CLNT_RETURN(NBDB_STAT_ERROR);
}
NBDB_MIGR_CLNT_RETURN(status);
}
/* nbdb_clnt_request - send a request and don't hang forever */
int nbdb_clnt_request(constchar *type, constchar *path, int max_try, int timeout, int delay,
VSTRING *why)
{
VSTRING *service_path = vstring_alloc(100); int status; int count;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.