diff options
Diffstat (limited to 'source3/lib/dbwrap/dbwrap_watch.c')
-rw-r--r-- | source3/lib/dbwrap/dbwrap_watch.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c index 4f3a2b3f059..a5f1ebd5bff 100644 --- a/source3/lib/dbwrap/dbwrap_watch.c +++ b/source3/lib/dbwrap/dbwrap_watch.c @@ -235,6 +235,8 @@ struct dbwrap_record_watch_state { TDB_DATA w_key; }; +static bool dbwrap_record_watch_filter(struct messaging_rec *rec, + void *private_data); static void dbwrap_record_watch_done(struct tevent_req *subreq); static int dbwrap_record_watch_state_destructor( struct dbwrap_record_watch_state *state); @@ -271,8 +273,8 @@ struct tevent_req *dbwrap_record_watch_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - subreq = messaging_read_send(state, ev, state->msg, - MSG_DBWRAP_MODIFIED); + subreq = messaging_filtered_read_send( + state, ev, state->msg, dbwrap_record_watch_filter, state); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -288,6 +290,21 @@ struct tevent_req *dbwrap_record_watch_send(TALLOC_CTX *mem_ctx, return req; } +static bool dbwrap_record_watch_filter(struct messaging_rec *rec, + void *private_data) +{ + struct dbwrap_record_watch_state *state = talloc_get_type_abort( + private_data, struct dbwrap_record_watch_state); + + if (rec->msg_type != MSG_DBWRAP_MODIFIED) { + return false; + } + if (rec->buf.length != state->w_key.dsize) { + return false; + } + return memcmp(rec->buf.data, state->w_key.dptr, rec->buf.length) == 0; +} + static int dbwrap_record_watch_state_destructor( struct dbwrap_record_watch_state *s) { @@ -351,33 +368,16 @@ static void dbwrap_record_watch_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data( subreq, struct tevent_req); - struct dbwrap_record_watch_state *state = tevent_req_data( - req, struct dbwrap_record_watch_state); struct messaging_rec *rec; int ret; - ret = messaging_read_recv(subreq, talloc_tos(), &rec); + ret = messaging_filtered_read_recv(subreq, talloc_tos(), &rec); TALLOC_FREE(subreq); if (ret != 0) { tevent_req_nterror(req, map_nt_error_from_unix(ret)); return; } - - if ((rec->buf.length == state->w_key.dsize) && - (memcmp(rec->buf.data, state->w_key.dptr, rec->buf.length) == 0)) { - tevent_req_done(req); - return; - } - - /* - * Not our record, wait for the next one - */ - subreq = messaging_read_send(state, state->ev, state->msg, - MSG_DBWRAP_MODIFIED); - if (tevent_req_nomem(subreq, req)) { - return; - } - tevent_req_set_callback(subreq, dbwrap_record_watch_done, req); + tevent_req_done(req); } NTSTATUS dbwrap_record_watch_recv(struct tevent_req *req, |