From: Jeff Garzik <jeff@garzik.org>
To: Pete Zaitcev <zaitcev@redhat.com>
Cc: hail-devel@vger.kernel.org
Subject: Re: [PATCH 2/3] CLD: switch network proto from UDP to TCP
Date: Mon, 03 Jan 2011 13:00:30 -0500 [thread overview]
Message-ID: <4D220EBE.6030902@garzik.org> (raw)
In-Reply-To: <20110102163232.78eec2f3@lembas.zaitcev.lan>
On 01/02/2011 06:32 PM, Pete Zaitcev wrote:
> On Fri, 31 Dec 2010 05:57:28 -0500
> Jeff Garzik<jeff@garzik.org> wrote:
>
>> + struct cldc_tcp *tcp = private;
>> + ssize_t rc;
>> + struct ubbp_header ubbp;
>> +
>> + memcpy(ubbp.magic, "CLD1", 4);
>> + ubbp.op_size = (buflen<< 8) | 1;
>> +#ifdef WORDS_BIGENDIAN
>> + swab32(ubbp.op_size);
>> +#endif
>> +
>> + rc = write(tcp->fd,&ubbp, sizeof(ubbp));
>
> Why not this:
>
> unsigned int n;
>
> n = (buflen<< 8) | 1;
> ubbp.op_size = GUINT32_TO_LE(n);
Yep.
I used the #ifdef on the read(2) side, where I did not want to create an
additional var... then I copied that onto the write(2) side, where it
is less efficient as you point out.
Jeff
prev parent reply other threads:[~2011-01-03 18:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-31 10:56 [PATCH 1/3] CLD: convert back to libevent Jeff Garzik
2010-12-31 10:57 ` [PATCH 2/3] CLD: switch network proto from UDP to TCP Jeff Garzik
2010-12-31 10:58 ` [PATCH 3/3] CLD: enable replication on server and client Jeff Garzik
2011-01-02 23:32 ` [PATCH 2/3] CLD: switch network proto from UDP to TCP Pete Zaitcev
2011-01-03 10:43 ` Jim Meyering
2011-01-03 18:00 ` Jeff Garzik [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D220EBE.6030902@garzik.org \
--to=jeff@garzik.org \
--cc=hail-devel@vger.kernel.org \
--cc=zaitcev@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).