[Groonga-commit] groonga/groonga at 9038a99 [master] ii cursor: add missing decode success check

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 30 14:34:48 JST 2017


Kouhei Sutou	2017-01-30 14:34:48 +0900 (Mon, 30 Jan 2017)

  New Revision: 9038a99feda1bf2b973c3e3e22de6a4fd1208082
  https://github.com/groonga/groonga/commit/9038a99feda1bf2b973c3e3e22de6a4fd1208082

  Message:
    ii cursor: add missing decode success check

  Modified files:
    lib/ii.c

  Modified: lib/ii.c (+27 -2)
===================================================================
--- lib/ii.c    2017-01-30 14:25:09 +0900 (b50ef11)
+++ lib/ii.c    2017-01-30 14:34:48 +0900 (4bba262)
@@ -5135,7 +5135,20 @@ grn_ii_cursor_next_internal(grn_ctx *ctx, grn_ii_cursor *c,
             if (c->curr_chunk <= c->nchunks) {
               if (c->curr_chunk == c->nchunks) {
                 if (c->cp < c->cpe) {
-                  grn_p_decv(ctx, c->cp, c->cpe - c->cp, c->rdv, c->ii->n_elements);
+                  int decoded_size;
+                  decoded_size =
+                    grn_p_decv(ctx, c->cp, c->cpe - c->cp,
+                               c->rdv, c->ii->n_elements);
+                  if (decoded_size == 0) {
+                    GRN_LOG(ctx, GRN_LOG_WARNING,
+                            "[ii][cursor][next][chunk][last] "
+                            "chunk(%d) is changed by another thread "
+                            "while decoding: %p",
+                            c->cinfo[c->curr_chunk].segno,
+                            c);
+                    c->pc.rid = 0;
+                    break;
+                  }
                   if (buffer_is_reused(ctx, c->ii, c)) {
                     GRN_LOG(ctx, GRN_LOG_WARNING,
                             "[ii][cursor][next][chunk][last] "
@@ -5166,8 +5179,20 @@ grn_ii_cursor_next_internal(grn_ctx *ctx, grn_ii_cursor *c,
                 if (size && (cp = WIN_MAP(c->ii->chunk, ctx, &iw,
                                           c->cinfo[c->curr_chunk].segno, 0,
                                           size, grn_io_rdonly))) {
-                  grn_p_decv(ctx, cp, size, c->rdv, c->ii->n_elements);
+                  int decoded_size;
+                  decoded_size =
+                    grn_p_decv(ctx, cp, size, c->rdv, c->ii->n_elements);
                   grn_io_win_unmap(&iw);
+                  if (decoded_size == 0) {
+                    GRN_LOG(ctx, GRN_LOG_WARNING,
+                            "[ii][cursor][next][chunk] "
+                            "chunk(%d) is changed by another thread "
+                            "while decoding: %p",
+                            c->cinfo[c->curr_chunk].segno,
+                            c);
+                    c->pc.rid = 0;
+                    break;
+                  }
                   if (chunk_is_reused(ctx, c->ii, c,
                                       c->cinfo[c->curr_chunk].segno, size)) {
                     GRN_LOG(ctx, GRN_LOG_WARNING,
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index