From b4c41e946104923df82212be453cf77b8eab63e5 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 27 Jun 2011 22:23:18 +0000 Subject: [PATCH] Make kgss test processes run in lock-step git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24994 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/gss-kernel-lib/t_kgss_common.c | 21 +++++++++++++++++++++ src/util/gss-kernel-lib/t_kgss_common.h | 2 ++ src/util/gss-kernel-lib/t_kgss_kernel.c | 9 +++++++++ src/util/gss-kernel-lib/t_kgss_user.c | 10 ++++++++++ 4 files changed, 42 insertions(+) diff --git a/src/util/gss-kernel-lib/t_kgss_common.c b/src/util/gss-kernel-lib/t_kgss_common.c index 1b31634c2..211cecc2b 100644 --- a/src/util/gss-kernel-lib/t_kgss_common.c +++ b/src/util/gss-kernel-lib/t_kgss_common.c @@ -82,3 +82,24 @@ read_data(int fd, void **data_out, size_t *len_out) *data_out = data; *len_out = len; } + +/* + * Acknowledgements are used to make the parent and child processes operate in + * lock-step. That way, if the child fails, the parent isn't several steps + * ahead before it finds out. + */ + +void +send_ack(int fd) +{ + rewrite(fd, "ack", 3); +} + +void +read_ack(int fd) +{ + char buf[3]; + + reread(fd, buf, 3); + assert(memcmp(buf, "ack", 3) == 0); +} diff --git a/src/util/gss-kernel-lib/t_kgss_common.h b/src/util/gss-kernel-lib/t_kgss_common.h index 8225bef28..edb38886a 100644 --- a/src/util/gss-kernel-lib/t_kgss_common.h +++ b/src/util/gss-kernel-lib/t_kgss_common.h @@ -28,3 +28,5 @@ void rewrite(int fd, const void *data, size_t len); void reread(int fd, void *buf, size_t len); void send_data(int fd, const void *data, size_t len); void read_data(int fd, void **data_out, size_t *len_out); +void send_ack(int fd); +void read_ack(int fd); diff --git a/src/util/gss-kernel-lib/t_kgss_kernel.c b/src/util/gss-kernel-lib/t_kgss_kernel.c index 0d70f1f38..f5914f421 100644 --- a/src/util/gss-kernel-lib/t_kgss_kernel.c +++ b/src/util/gss-kernel-lib/t_kgss_kernel.c @@ -273,12 +273,21 @@ main(int argc, char **argv) krb5_c_random_os_entropy(NULL, 0, &dummy); read_lucid_context(&acceptor); + send_ack(STDOUT_FILENO); read_wrap_token(acceptor); + send_ack(STDOUT_FILENO); read_mic_token(acceptor); + send_ack(STDOUT_FILENO); read_iov_token(acceptor); + send_ack(STDOUT_FILENO); + send_wrap_token(acceptor); + read_ack(STDIN_FILENO); send_mic_token(acceptor); + read_ack(STDIN_FILENO); send_iov_token(acceptor); + read_ack(STDIN_FILENO); + cleanup_context(acceptor); return 0; } diff --git a/src/util/gss-kernel-lib/t_kgss_user.c b/src/util/gss-kernel-lib/t_kgss_user.c index 15fca238a..6c4b63841 100644 --- a/src/util/gss-kernel-lib/t_kgss_user.c +++ b/src/util/gss-kernel-lib/t_kgss_user.c @@ -378,13 +378,23 @@ main(int argc, char **argv) establish_contexts(argv[1], &initiator, &acceptor); start_child(&to_child, &from_child, &child_pid); + send_lucid_context(acceptor, to_child); + read_ack(from_child); send_wrap_token(initiator, to_child); + read_ack(from_child); send_mic_token(initiator, to_child); + read_ack(from_child); send_iov_token(initiator, to_child); + read_ack(from_child); + read_wrap_token(initiator, from_child); + send_ack(to_child); read_mic_token(initiator, from_child); + send_ack(to_child); read_iov_token(initiator, from_child); + send_ack(to_child); + cleanup_context(initiator); close(to_child); close(from_child); -- 2.26.2