From d7c30f7c506ad8c537b74e232348633bfdff820a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Tue, 24 May 2005 18:32:16 +0000 Subject: [PATCH] (do_request): use sendmsg to send the reply git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15233 ec53bebd-3082-4978-b11e-865c3cabbd6b --- kcm/connect.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/kcm/connect.c b/kcm/connect.c index a2e2edb33..6fe2c8cc9 100644 --- a/kcm/connect.c +++ b/kcm/connect.c @@ -324,22 +324,36 @@ do_request(void *buf, size_t len, struct descr *d) ret = process_request(buf, len, &reply, &d->peercred); if (reply.length != 0) { unsigned char len[4]; + struct msghdr msghdr; + struct iovec iov[2]; - kcm_log(5, "sending %lu bytes to process %d", (unsigned long)reply.length, - d->peercred.pid); + kcm_log(5, "sending %lu bytes to process %d", + (unsigned long)reply.length, + (int)d->peercred.pid); + + memset (&msghdr, 0, sizeof(msghdr)); + msghdr.msg_name = d->sa; + msghdr.msg_namelen = d->sock_len; + msghdr.msg_iov = iov; + msghdr.msg_iovlen = sizeof(iov)/sizeof(*iov); +#if 0 + msghdr.msg_control = NULL; + msghdr.msg_controllen = 0; +#endif len[0] = (reply.length >> 24) & 0xff; len[1] = (reply.length >> 16) & 0xff; len[2] = (reply.length >> 8) & 0xff; len[3] = reply.length & 0xff; - if (sendto(d->s, len, sizeof(len), 0, NULL, 0) < 0) { - kcm_log (0, "sendto(%d): %d %s", d->peercred.pid, strerror(errno)); - krb5_data_free(&reply); - return; - } - if (sendto(d->s, reply.data, reply.length, 0, NULL, 0) < 0) { - kcm_log (0, "sendto(%d): %s", d->peercred.pid, strerror(errno)); + iov[0].iov_base = len; + iov[0].iov_len = 4; + iov[1].iov_base = reply.data; + iov[1].iov_len = reply.length; + + if (sendmsg (d->s, &msghdr, 0) < 0) { + kcm_log (0, "sendmsg(%d): %d %s", (int)d->peercred.pid, + strerror(errno)); krb5_data_free(&reply); return; }