Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-103

Window plugins hangs when connecting to a couchbase cluster with 2 or more nodes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.0beta
    • Fix Version/s: None
    • Component/s: library
    • Security Level: Public
    • Labels:
      None
    • Environment:
      Windows

      Description

      When running the event loop from a window build it was observed that lcb_io_run_event_loop would never complete when performing a get or set operation. lcb_wait was called after calling lcb_store or lcb_get and would never complete.

      This issue was seen after adding a second server to the couchbase cluster.

      I tracked down the issue to link_event and unlink_event in plugin-win32.c

      Link event was not inserting new events into the linked link properly after the first 2 it would trash the second entry with any addition adds.

      In unlink_event the loop would did not properly remove events from the linked list and would connect the head to the next pointer of the event being deleted skipping over any other events in the list.

      Here is the fixed code: (link_timer and unlink_timer had the same logic so I updated those also)

      static void link_event(struct winsock_io_cookie *instance,
      struct winsock_event *event)

      { event->next = instance->events; instance->events = event; }

      static void unlink_event(struct winsock_io_cookie *instance,
      struct winsock_event *event)
      {
      if (instance->events == NULL)
      return;

      if (instance->events == event)

      { instance->events = event->next; }

      else {
      struct winsock_event *prev = instance->events;
      struct winsock_event *next = prev->next;
      while (next != NULL) {
      if (event == next)

      { prev->next = next->next; return; }
      prev = next;
      next = prev->next;
      }
      }
      }

      static void link_timer(struct winsock_io_cookie *instance,
      struct winsock_timer *timer) { timer->next = instance->timers; instance->timers = timer; }

      static void unlink_timer(struct winsock_io_cookie *instance,
      struct winsock_timer *timer)
      {
      if (instance->timers == NULL)
      return;

      if (instance->timers == timer) { instance->timers = timer->next; } else {
      struct winsock_timer *prev = instance->timers;
      struct winsock_timer *next = prev->next;
      while (next != NULL) {
      if (timer == next) { prev->next = next->next; return; }

      prev = next;
      next = prev->next;
      }
      }
      }

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        avsej Sergey Avseyev added a comment - - edited

        patch from trondn on IRC: http://pastebin.com/sDtFnsiM <- That link is dead...

        Show
        avsej Sergey Avseyev added a comment - - edited patch from trondn on IRC: http://pastebin.com/sDtFnsiM <- That link is dead...
        Show
        trond Trond Norbye added a comment - http://review.couchbase.org/#/c/21078/

          People

          • Assignee:
            trond Trond Norbye
            Reporter:
            brettharrison Brett Harrison
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes