Fix mdb_reader_list() and its spec.

It and the MDB_msg_func can now return >= 0 for success.
Always return any MDB_msg_func() error result.
vmware
Hallvard Furuseth 11 years ago
parent a58fd16ae5
commit 7e453c9763
  1. 4
      libraries/liblmdb/lmdb.h
  2. 13
      libraries/liblmdb/mdb.c

@ -1409,7 +1409,7 @@ int mdb_dcmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b);
* *
* @param[in] msg The string to be printed. * @param[in] msg The string to be printed.
* @param[in] ctx An arbitrary context pointer for the callback. * @param[in] ctx An arbitrary context pointer for the callback.
* @return < 0 on failure, 0 on success. * @return < 0 on failure, >= 0 on success.
*/ */
typedef int (MDB_msg_func)(const char *msg, void *ctx); typedef int (MDB_msg_func)(const char *msg, void *ctx);
@ -1418,7 +1418,7 @@ typedef int (MDB_msg_func)(const char *msg, void *ctx);
* @param[in] env An environment handle returned by #mdb_env_create() * @param[in] env An environment handle returned by #mdb_env_create()
* @param[in] func A #MDB_msg_func function * @param[in] func A #MDB_msg_func function
* @param[in] ctx Anything the message function needs * @param[in] ctx Anything the message function needs
* @return < 0 on failure, 0 on success. * @return < 0 on failure, >= 0 on success.
*/ */
int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx); int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx);

@ -8299,7 +8299,7 @@ int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx)
unsigned int i, rdrs; unsigned int i, rdrs;
MDB_reader *mr; MDB_reader *mr;
char buf[64]; char buf[64];
int first = 1; int rc = 0, first = 1;
if (!env || !func) if (!env || !func)
return -1; return -1;
@ -8311,7 +8311,6 @@ int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx)
for (i=0; i<rdrs; i++) { for (i=0; i<rdrs; i++) {
if (mr[i].mr_pid) { if (mr[i].mr_pid) {
size_t tid; size_t tid;
int rc;
tid = mr[i].mr_tid; tid = mr[i].mr_tid;
if (mr[i].mr_txnid == (txnid_t)-1) { if (mr[i].mr_txnid == (txnid_t)-1) {
sprintf(buf, "%10d %"Z"x -\n", mr[i].mr_pid, tid); sprintf(buf, "%10d %"Z"x -\n", mr[i].mr_pid, tid);
@ -8320,17 +8319,19 @@ int mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx)
} }
if (first) { if (first) {
first = 0; first = 0;
func(" pid thread txnid\n", ctx); rc = func(" pid thread txnid\n", ctx);
if (rc < 0)
break;
} }
rc = func(buf, ctx); rc = func(buf, ctx);
if (rc < 0) if (rc < 0)
return rc; break;
} }
} }
if (first) { if (first) {
func("(no active readers)\n", ctx); rc = func("(no active readers)\n", ctx);
} }
return 0; return rc;
} }
/** Insert pid into list if not already present. /** Insert pid into list if not already present.

Loading…
Cancel
Save