Pete Zaitcev | 3 Jan 2011 00:32
Picon
Favicon

Re: [PATCH 2/3] CLD: switch network proto from UDP to TCP

On Fri, 31 Dec 2010 05:57:28 -0500
Jeff Garzik <jeff <at> 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);

-- P
Pete Zaitcev | 3 Jan 2011 02:20
Picon

Crash with db5

Looks like Rawhide throws this if libdb-devel is in use:

make  check-TESTS
make[3]: Entering directory `/q/zaitcev/hail/hail-tip/test/cld'
PASS: prep-db
DB_ENV->lsn_reset: method not permitted before handle's open method
DB_ENV->dbremove: method not permitted before handle's open method
cld[11548]: SIGSEGV
PASS: start-daemon
port file not found.
FAIL: pid-exists

libdb-5.1.19-2.fc15.x86_64

-- Pete
Jeff Garzik | 3 Jan 2011 02:44
Favicon

Re: Crash with db5

On 01/02/2011 08:20 PM, Pete Zaitcev wrote:
> Looks like Rawhide throws this if libdb-devel is in use:
>
> make  check-TESTS
> make[3]: Entering directory `/q/zaitcev/hail/hail-tip/test/cld'
> PASS: prep-db
> DB_ENV->lsn_reset: method not permitted before handle's open method
> DB_ENV->dbremove: method not permitted before handle's open method
> cld[11548]: SIGSEGV
> PASS: start-daemon
> port file not found.
> FAIL: pid-exists
>
> libdb-5.1.19-2.fc15.x86_64

Are you compiling with db4 headers, but linking with db5?
Or vice versa?

This is a problem I ran into, with F14.  hail's configure script 
searches for the first libdb, which will always be libdb5 on >= F14, 
because libdb5 is always installed due to dependencies.  But... you can 
either have db4-devel or libdb-devel installed for the devel pkg.

If you have db4-devel + libdb5... boom.

	Jeff

Pete Zaitcev | 3 Jan 2011 03:19
Picon

Re: Crash with db5

On Sun, 02 Jan 2011 20:44:02 -0500
Jeff Garzik <jeff <at> garzik.org> wrote:

> > PASS: prep-db
> > DB_ENV->lsn_reset: method not permitted before handle's open method
> > DB_ENV->dbremove: method not permitted before handle's open method
> > cld[11548]: SIGSEGV

> Are you compiling with db4 headers, but linking with db5?
> Or vice versa?
> If you have db4-devel + libdb5... boom.

Looks like you're right, although it's the "vice versa" case:

[zaitcev <at> niphredil hail-tip]$ rpm -q libdb-devel db4-devel db4 libdb
libdb-devel-5.1.19-2.fc15.x86_64
package db4-devel is not installed
db4-4.8.30-2.fc14.x86_64
db4-4.8.30-2.fc14.i686
libdb-5.1.19-2.fc15.x86_64
[zaitcev <at> niphredil hail-tip]$ ldd ./cld/.libs/cld | grep db
        libdb-4.8.so => /lib64/libdb-4.8.so (0x00007f7f619f9000)
        libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x00007f7f5db85000)
[zaitcev <at> niphredil hail-tip]$ rpm -qf /lib64/libdb-4.8.so
db4-4.8.30-2.fc14.x86_64
[zaitcev <at> niphredil hail-tip]$ 

How to fix this? I cannot blow away db4.

-- Pete
(Continue reading)

Pete Zaitcev | 3 Jan 2011 04:36
Picon

Re: Crash with db5

On Sun, 02 Jan 2011 20:44:02 -0500
Jeff Garzik <jeff <at> garzik.org> wrote:

> > DB_ENV->dbremove: method not permitted before handle's open method
> > cld[11548]: SIGSEGV

> Are you compiling with db4 headers, but linking with db5?
> Or vice versa?

It turned out that Rawhide revved up the db5, so this band-aids it:

commit 42d083416656e195baa79a924df0f11a3f0681c2
Author: Pete Zaitcev <zaitcev <at> yahoo.com>
Date:   Sun Jan 2 20:28:39 2011 -0700

    Accept db-5.1.

diff --git a/configure.ac b/configure.ac
index 9cfad23..abc9330 100644
--- a/configure.ac
+++ b/configure.ac
 <at>  <at>  -75,7 +75,8  <at>  <at>  dnl AC_TYPE_PID_T
 dnl -----------------------------
 dnl Checks for required libraries
 dnl -----------------------------
-AC_CHECK_LIB(db-5.0, db_create, DB4_LIBS=-ldb-5.0,
+AC_CHECK_LIB(db-5.1, db_create, DB4_LIBS=-ldb-5.1,
+	AC_CHECK_LIB(db-5.0, db_create, DB4_LIBS=-ldb-5.0,
 	AC_CHECK_LIB(db-4.9, db_create, DB4_LIBS=-ldb-4.9,
 	AC_CHECK_LIB(db-4.8, db_create, DB4_LIBS=-ldb-4.8,
(Continue reading)

Jim Meyering | 3 Jan 2011 11:43
Gravatar

Re: [PATCH 2/3] CLD: switch network proto from UDP to TCP

Pete Zaitcev wrote:
> On Fri, 31 Dec 2010 05:57:28 -0500
> Jeff Garzik <jeff <at> 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);

Nice.
Avoiding those pesky in-function #ifdefs makes the code more readable.

IMHO, this is kinder still on the eyes of reviewers, since the
types of "n" and "rc" stay even closer to each definition/first-use:

  	unsigned int n = (buflen << 8) | 1;
(Continue reading)

Jeff Garzik | 3 Jan 2011 19:00
Favicon

Re: [PATCH 2/3] CLD: switch network proto from UDP to TCP

On 01/02/2011 06:32 PM, Pete Zaitcev wrote:
> On Fri, 31 Dec 2010 05:57:28 -0500
> Jeff Garzik<jeff <at> 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
(Continue reading)


Gmane