site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=wnO3+VLL/84OWqtPDop+UtL4q+J4DTzrhP4Gkycr/SA=; b=EMXCINCZ9HYd/RkrubsomJWEykI1eYbmNyDPbWwnOKXJtcyx2pqZ/3L+hEQsVO8TJB4hX98py9FEPJwYa7e2YUKd0gXvRCsDKfLYKoHvcfEMpnUqSlEU8enbPEEDDXsrg1sxFUot6UmHcdvEVvgDGImCKIKzN7VS9Xzb2fSQBlY= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=on4BonV4ieZ+817h6VraNZOSKijwZY2rRwwfWHbV+aSXoaTz6Z2LabbAYoBJ0M+YrpTTvkqCT8Te2YkdCoDe+Y0j1PCTIIlKpKb0IGfaZ0rxcGJg8Wk+U48eHrCGmweg0dUNlyAQ5P/zcBSnA9XNtrZncrXRdB7Dy1vUaX3qygo= darwin-dev, I'm experiencing strange behaviour with DBM on a Mac OS X 10.5.1 (both on G5 and Intel) and it would be great to get some feedback from the list on what the problem might be. The program below is storing 200 byte records into a hash with an incrementing numeric string key using dbm_store(). However, at insert (and key) number 232783, dbm_store() returns -1, which indicates failure. However, errno is 0 and dbm_error() also returns 0, so the error itself seems unspecified. I believe the DBM implementation on Mac OS X is Berkeley DB (http://www.opensource.apple.com/darwinsource/10.5/BerkeleyDB-15/). I've heard that some people have had problems with databases becoming corrupt after millions of store and fetch operations under heavy loads with the implementations available at around year 2000. These people also recommend against using Berkeley DB in general. Feedback on the problem with the below program and the overall suitability of the Berkeley DB implementation in Leopard is mostly appreciated. Thanks. Christian #include <stdio.h> #include <string.h> #include <ndbm.h> #include <errno.h> #include <assert.h> #define NUM_RECORDS 250000 #define MAX_KEY_SIZE 10 #define MAX_VALUE_SIZE 200 int main (int argc, const char * argv[]) { DBM *db; int i; db = dbm_open("/tmp/testdb", O_RDWR | O_CREAT, 0660); assert(db != NULL); for (i = 0; i < NUM_RECORDS; i++) { char key[MAX_KEY_SIZE]; char value[MAX_VALUE_SIZE]; datum k; datum v; int status; memset(key, '\0', MAX_KEY_SIZE); snprintf(key, MAX_KEY_SIZE, "%d", i); k.dptr = key; k.dsize = strlen(key); memset(value, 'A', MAX_VALUE_SIZE); v.dptr = value; v.dsize = MAX_VALUE_SIZE; status = dbm_store(db, k, v, DBM_REPLACE); if (status != 0) { fprintf(stderr, "key: %s, status: %d, errno=%d, strerrno=%s, dbm_error=%d\n", k.dptr, status, errno, strerror(errno), dbm_error(db)); return 1; } } dbm_close(db); return 0; } _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com