Merge branch 'collectd-5.8'
authorFlorian Forster <octo@collectd.org>
Tue, 5 Dec 2017 06:33:18 +0000 (07:33 +0100)
committerFlorian Forster <octo@collectd.org>
Tue, 5 Dec 2017 06:33:18 +0000 (07:33 +0100)
1  2 
src/exec.c
src/powerdns.c
src/rrdtool.c
src/table.c
src/utils_ovs.c

diff --combined src/exec.c
@@@ -265,6 -265,7 +265,6 @@@ __attribute__((noreturn)) static void e
                                                   int gid, int egid) /* {{{ */
  {
    int status;
 -  char errbuf[1024];
  
  #if HAVE_SETGROUPS
    if (getuid() == 0) {
  
    status = setgid(gid);
    if (status != 0) {
 -    ERROR("exec plugin: setgid (%i) failed: %s", gid,
 -          sstrerror(errno, errbuf, sizeof(errbuf)));
 +    ERROR("exec plugin: setgid (%i) failed: %s", gid, STRERRNO);
      exit(-1);
    }
  
    if (egid != -1) {
      status = setegid(egid);
      if (status != 0) {
 -      ERROR("exec plugin: setegid (%i) failed: %s", egid,
 -            sstrerror(errno, errbuf, sizeof(errbuf)));
 +      ERROR("exec plugin: setegid (%i) failed: %s", egid, STRERRNO);
        exit(-1);
      }
    }
  
    status = setuid(uid);
    if (status != 0) {
 -    ERROR("exec plugin: setuid (%i) failed: %s", uid,
 -          sstrerror(errno, errbuf, sizeof(errbuf)));
 +    ERROR("exec plugin: setuid (%i) failed: %s", uid, STRERRNO);
      exit(-1);
    }
  
    execvp(pl->exec, pl->argv);
  
 -  ERROR("exec plugin: Failed to execute ``%s'': %s", pl->exec,
 -        sstrerror(errno, errbuf, sizeof(errbuf)));
 +  ERROR("exec plugin: Failed to execute ``%s'': %s", pl->exec, STRERRNO);
    exit(-1);
  } /* void exec_child }}} */
  
@@@ -319,11 -324,13 +319,11 @@@ static void reset_signal_mask(void) /* 
  
  static int create_pipe(int fd_pipe[2]) /* {{{ */
  {
 -  char errbuf[1024];
    int status;
  
    status = pipe(fd_pipe);
    if (status != 0) {
 -    ERROR("exec plugin: pipe failed: %s",
 -          sstrerror(errno, errbuf, sizeof(errbuf)));
 +    ERROR("exec plugin: pipe failed: %s", STRERRNO);
      return -1;
    }
  
@@@ -351,6 -358,7 +351,6 @@@ static int fork_child(program_list_t *p
    int fd_pipe_in[2] = {-1, -1};
    int fd_pipe_out[2] = {-1, -1};
    int fd_pipe_err[2] = {-1, -1};
 -  char errbuf[1024];
    int status;
    int pid;
  
    status = getpwnam_r(pl->user, &sp, nambuf, sizeof(nambuf), &sp_ptr);
    if (status != 0) {
      ERROR("exec plugin: Failed to get user information for user ``%s'': %s",
 -          pl->user, sstrerror(status, errbuf, sizeof(errbuf)));
 +          pl->user, STRERROR(status));
      goto failed;
    }
  
        if (status != 0) {
          ERROR("exec plugin: Failed to get group information "
                "for group ``%s'': %s",
 -              pl->group, sstrerror(status, errbuf, sizeof(errbuf)));
 +              pl->group, STRERROR(status));
          goto failed;
        }
        if (gr_ptr == NULL) {
  
    pid = fork();
    if (pid < 0) {
 -    ERROR("exec plugin: fork failed: %s",
 -          sstrerror(errno, errbuf, sizeof(errbuf)));
 +    ERROR("exec plugin: fork failed: %s", STRERRNO);
      goto failed;
    } else if (pid == 0) {
      int fd_num;
@@@ -679,7 -688,9 +679,7 @@@ static void *exec_notification_one(voi
  
    fh = fdopen(fd, "w");
    if (fh == NULL) {
 -    char errbuf[1024];
 -    ERROR("exec plugin: fdopen (%i) failed: %s", fd,
 -          sstrerror(errno, errbuf, sizeof(errbuf)));
 +    ERROR("exec plugin: fdopen (%i) failed: %s", fd, STRERRNO);
      kill(pid, SIGTERM);
      close(fd);
      sfree(arg);
@@@ -788,7 -799,11 +788,11 @@@ static int exec_read(void) /* {{{ *
  
      pthread_attr_init(&attr);
      pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-     plugin_thread_create(&t, &attr, exec_read_one, (void *)pl, "exec read");
+     int status =
+         plugin_thread_create(&t, &attr, exec_read_one, (void *)pl, "exec read");
+     if (status != 0) {
+       ERROR("exec plugin: plugin_thread_create failed.");
+     }
      pthread_attr_destroy(&attr);
    } /* for (pl) */
  
@@@ -827,8 -842,11 +831,11 @@@ static int exec_notification(const noti
  
      pthread_attr_init(&attr);
      pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-     plugin_thread_create(&t, &attr, exec_notification_one, (void *)pln,
-                          "exec notify");
+     int status = plugin_thread_create(&t, &attr, exec_notification_one,
+                                       (void *)pln, "exec notify");
+     if (status != 0) {
+       ERROR("exec plugin: plugin_thread_create failed.");
+     }
      pthread_attr_destroy(&attr);
    } /* for (pl) */
  
diff --combined src/powerdns.c
  #endif
  #define FUNC_ERROR(func)                                                       \
    do {                                                                         \
 -    char errbuf[1024];                                                         \
 -    ERROR("powerdns plugin: %s failed: %s", func,                              \
 -          sstrerror(errno, errbuf, sizeof(errbuf)));                           \
 +    ERROR("powerdns plugin: %s failed: %s", func, STRERRNO);                   \
    } while (0)
  #define SOCK_ERROR(func, sockpath)                                             \
    do {                                                                         \
 -    char errbuf[1024];                                                         \
      ERROR("powerdns plugin: Socket `%s` %s failed: %s", sockpath, func,        \
 -          sstrerror(errno, errbuf, sizeof(errbuf)));                           \
 +          STRERRNO);                                                           \
    } while (0)
  
  #define SERVER_SOCKET LOCALSTATEDIR "/run/pdns.controlsocket"
@@@ -376,8 -379,8 +376,8 @@@ static void submit(const char *plugin_i
    plugin_dispatch_values(&vl);
  } /* }}} static void submit */
  
- static int powerdns_get_data_dgram(list_item_t *item, /* {{{ */
-                                    char **ret_buffer, size_t *ret_buffer_size) {
+ static int powerdns_get_data_dgram(list_item_t *item, char **ret_buffer) {
+   /* {{{ */
    int sd;
    int status;
  
    buffer[buffer_size - 1] = 0;
  
    *ret_buffer = buffer;
-   *ret_buffer_size = buffer_size;
    return 0;
  } /* }}} int powerdns_get_data_dgram */
  
- static int powerdns_get_data_stream(list_item_t *item, /* {{{ */
-                                     char **ret_buffer,
-                                     size_t *ret_buffer_size) {
+ static int powerdns_get_data_stream(list_item_t *item, char **ret_buffer) {
+   /* {{{ */
    int sd;
    int status;
  
      if (status < 0) {
        SOCK_ERROR("recv", item->sockaddr.sun_path);
        break;
-     } else if (status == 0)
+     } else if (status == 0) {
        break;
+     }
  
      buffer_new = realloc(buffer, buffer_size + status + 1);
      if (buffer_new == NULL) {
        FUNC_ERROR("realloc");
-       status = -1;
+       status = ENOMEM;
        break;
      }
      buffer = buffer_new;
    } /* while (42) */
    close(sd);
  
-   if (status < 0) {
+   if (status != 0) {
      sfree(buffer);
-   } else {
-     assert(status == 0);
-     *ret_buffer = buffer;
-     *ret_buffer_size = buffer_size;
+     return status;
    }
  
-   return status;
+   *ret_buffer = buffer;
+   return 0;
  } /* }}} int powerdns_get_data_stream */
  
- static int powerdns_get_data(list_item_t *item, char **ret_buffer,
-                              size_t *ret_buffer_size) {
+ static int powerdns_get_data(list_item_t *item, char **ret_buffer) {
    if (item->socktype == SOCK_DGRAM)
-     return powerdns_get_data_dgram(item, ret_buffer, ret_buffer_size);
+     return powerdns_get_data_dgram(item, ret_buffer);
    else if (item->socktype == SOCK_STREAM)
-     return powerdns_get_data_stream(item, ret_buffer, ret_buffer_size);
+     return powerdns_get_data_stream(item, ret_buffer);
    else {
      ERROR("powerdns plugin: Unknown socket type: %i", (int)item->socktype);
      return -1;
  
  static int powerdns_read_server(list_item_t *item) /* {{{ */
  {
-   char *buffer = NULL;
-   size_t buffer_size = 0;
-   int status;
-   char *dummy;
-   char *saveptr;
-   char *key;
-   char *value;
-   const char *const *fields;
-   int fields_num;
    if (item->command == NULL)
      item->command = strdup(SERVER_COMMAND);
    if (item->command == NULL) {
      return -1;
    }
  
-   status = powerdns_get_data(item, &buffer, &buffer_size);
-   if (status != 0)
-     return -1;
+   char *buffer = NULL;
+   int status = powerdns_get_data(item, &buffer);
+   if (status != 0) {
+     ERROR("powerdns plugin: powerdns_get_data failed.");
+     return status;
+   }
+   if (buffer == NULL) {
+     return EINVAL;
+   }
  
+   const char *const *fields = default_server_fields;
+   int fields_num = default_server_fields_num;
    if (item->fields_num != 0) {
      fields = (const char *const *)item->fields;
      fields_num = item->fields_num;
-   } else {
-     fields = default_server_fields;
-     fields_num = default_server_fields_num;
    }
  
    assert(fields != NULL);
  
    /* corrupt-packets=0,deferred-cache-inserts=0,deferred-cache-lookup=0,latency=0,packetcache-hit=0,packetcache-miss=0,packetcache-size=0,qsize-q=0,query-cache-hit=0,query-cache-miss=0,recursing-answers=0,recursing-questions=0,servfail-packets=0,tcp-answers=0,tcp-queries=0,timedout-packets=0,udp-answers=0,udp-queries=0,udp4-answers=0,udp4-queries=0,udp6-answers=0,udp6-queries=0,
     */
-   dummy = buffer;
-   saveptr = NULL;
+   char *dummy = buffer;
+   char *saveptr = NULL;
+   char *key;
    while ((key = strtok_r(dummy, ",", &saveptr)) != NULL) {
      dummy = NULL;
  
-     value = strchr(key, '=');
+     char *value = strchr(key, '=');
      if (value == NULL)
        break;
  
@@@ -688,7 -679,6 +676,6 @@@ static int powerdns_update_recursor_com
  static int powerdns_read_recursor(list_item_t *item) /* {{{ */
  {
    char *buffer = NULL;
-   size_t buffer_size = 0;
    int status;
  
    char *dummy;
    }
    assert(item->command != NULL);
  
-   status = powerdns_get_data(item, &buffer, &buffer_size);
+   status = powerdns_get_data(item, &buffer);
    if (status != 0) {
      ERROR("powerdns plugin: powerdns_get_data failed.");
      return -1;
diff --combined src/rrdtool.c
@@@ -520,7 -520,10 +520,7 @@@ static void rrd_cache_flush(cdtime_t ti
      {
        char **tmp = realloc(keys, (keys_num + 1) * sizeof(char *));
        if (tmp == NULL) {
 -        char errbuf[1024];
 -        ERROR("rrdtool plugin: "
 -              "realloc failed: %s",
 -              sstrerror(errno, errbuf, sizeof(errbuf)));
 +        ERROR("rrdtool plugin: realloc failed: %s", STRERRNO);
          c_avl_iterator_destroy(iter);
          sfree(keys);
          return;
@@@ -620,9 -623,8 +620,8 @@@ static int rrd_cache_insert(const char 
      return -1;
    }
  
-   c_avl_get(cache, filename, (void *)&rc);
-   if (rc == NULL) {
+   int status = c_avl_get(cache, filename, (void *)&rc);
+   if ((status != 0) || (rc == NULL)) {
      rc = malloc(sizeof(*rc));
      if (rc == NULL) {
        pthread_mutex_unlock(&cache_lock);
    values_new =
        realloc((void *)rc->values, (rc->values_num + 1) * sizeof(char *));
    if (values_new == NULL) {
 -    char errbuf[1024];
      void *cache_key = NULL;
  
 -    sstrerror(errno, errbuf, sizeof(errbuf));
 -
      c_avl_remove(cache, filename, &cache_key, NULL);
      pthread_mutex_unlock(&cache_lock);
  
 -    ERROR("rrdtool plugin: realloc failed: %s", errbuf);
 +    ERROR("rrdtool plugin: realloc failed: %s", STRERRNO);
  
      sfree(cache_key);
      sfree(rc->values);
      void *cache_key = strdup(filename);
  
      if (cache_key == NULL) {
 -      char errbuf[1024];
 -      sstrerror(errno, errbuf, sizeof(errbuf));
 -
        pthread_mutex_unlock(&cache_lock);
  
 -      ERROR("rrdtool plugin: strdup failed: %s", errbuf);
 +      ERROR("rrdtool plugin: strdup failed: %s", STRERRNO);
  
        sfree(rc->values[0]);
        sfree(rc->values);
@@@ -807,7 -815,9 +806,7 @@@ static int rrd_write(const data_set_t *
          return 0;
        }
      } else {
 -      char errbuf[1024];
 -      ERROR("rrdtool plugin: stat(%s) failed: %s", filename,
 -            sstrerror(errno, errbuf, sizeof(errbuf)));
 +      ERROR("rrdtool plugin: stat(%s) failed: %s", filename, STRERRNO);
        return -1;
      }
    } else if (!S_ISREG(statbuf.st_mode)) {
@@@ -1036,8 -1046,7 +1035,7 @@@ static int rrd_init(void) 
      cache_flush_timeout = 0;
    } else if (cache_flush_timeout < cache_timeout) {
      INFO("rrdtool plugin: \"CacheFlush %.3f\" is less than \"CacheTimeout "
-          "%.3f\". "
-          "Ajusting \"CacheFlush\" to %.3f seconds.",
+          "%.3f\". Adjusting \"CacheFlush\" to %.3f seconds.",
           CDTIME_T_TO_DOUBLE(cache_flush_timeout),
           CDTIME_T_TO_DOUBLE(cache_timeout),
           CDTIME_T_TO_DOUBLE(cache_timeout * 10));
diff --combined src/table.c
@@@ -78,6 -78,10 +78,10 @@@ static void tbl_result_setup(tbl_result
  } /* tbl_result_setup */
  
  static void tbl_result_clear(tbl_result_t *res) {
+   if (res == NULL) {
+     return;
+   }
    sfree(res->type);
  
    sfree(res->instance_prefix);
@@@ -103,11 -107,17 +107,17 @@@ static void tbl_setup(tbl_t *tbl, char 
  } /* tbl_setup */
  
  static void tbl_clear(tbl_t *tbl) {
+   if (tbl == NULL) {
+     return;
+   }
    sfree(tbl->file);
    sfree(tbl->sep);
    sfree(tbl->plugin_name);
    sfree(tbl->instance);
  
+   /* (tbl->results == NULL) -> (tbl->results_num == 0) */
+   assert((tbl->results != NULL) || (tbl->results_num == 0));
    for (size_t i = 0; i < tbl->results_num; ++i)
      tbl_result_clear(tbl->results + i);
    sfree(tbl->results);
@@@ -154,7 -164,8 +164,7 @@@ static int tbl_config_append_array_i(ch
  
    tmp = realloc(*var, ((*len) + num) * sizeof(**var));
    if (NULL == tmp) {
 -    char errbuf[1024];
 -    log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
 +    log_err("realloc failed: %s.", STRERRNO);
      return -1;
    }
    *var = tmp;
@@@ -176,7 -187,8 +186,7 @@@ static int tbl_config_result(tbl_t *tbl
    tbl_result_t *res =
        realloc(tbl->results, (tbl->results_num + 1) * sizeof(*tbl->results));
    if (res == NULL) {
 -    char errbuf[1024];
 -    log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
 +    log_err("realloc failed: %s.", STRERRNO);
      return -1;
    }
  
@@@ -233,7 -245,8 +243,7 @@@ static int tbl_config_table(oconfig_ite
  
    tbl_t *tbl = realloc(tables, (tables_num + 1) * sizeof(*tables));
    if (NULL == tbl) {
 -    char errbuf[1024];
 -    log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
 +    log_err("realloc failed: %s.", STRERRNO);
      return -1;
    }
  
@@@ -440,7 -453,9 +450,7 @@@ static int tbl_read_table(tbl_t *tbl) 
  
    fh = fopen(tbl->file, "r");
    if (NULL == fh) {
 -    char errbuf[1024];
 -    log_err("Failed to open file \"%s\": %s.", tbl->file,
 -            sstrerror(errno, errbuf, sizeof(errbuf)));
 +    log_err("Failed to open file \"%s\": %s.", tbl->file, STRERRNO);
      return -1;
    }
  
    }
  
    if (0 != ferror(fh)) {
 -    char errbuf[1024];
 -    log_err("Failed to read from file \"%s\": %s.", tbl->file,
 -            sstrerror(errno, errbuf, sizeof(errbuf)));
 +    log_err("Failed to read from file \"%s\": %s.", tbl->file, STRERRNO);
      fclose(fh);
      return -1;
    }
diff --combined src/utils_ovs.c
  #define OVS_DB_POLL_READ_BLOCK_SIZE 512 /* read block size (bytes) */
  #define OVS_DB_DEFAULT_DB_NAME "Open_vSwitch"
  
+ #define OVS_DB_EVENT_NONE 0
  #define OVS_DB_EVENT_TIMEOUT 5 /* event thread timeout (sec) */
  #define OVS_DB_EVENT_TERMINATE 1
  #define OVS_DB_EVENT_CONN_ESTABLISHED 2
@@@ -750,18 -751,21 +751,18 @@@ static void ovs_db_reconnect(ovs_db_t *
    }
    /* try to connect to the server */
    for (struct addrinfo *rp = result; rp != NULL; rp = rp->ai_next) {
 -    char errbuff[OVS_ERROR_BUFF_SIZE];
      int sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
      if (sock < 0) {
 -      sstrerror(errno, errbuff, sizeof(errbuff));
 -      OVS_DEBUG("socket(): %s", errbuff);
 +      OVS_DEBUG("socket(): %s", STRERRNO);
        continue;
      }
      if (connect(sock, rp->ai_addr, rp->ai_addrlen) < 0) {
        close(sock);
 -      sstrerror(errno, errbuff, sizeof(errbuff));
 -      OVS_DEBUG("connect(): %s [family=%d]", errbuff, rp->ai_family);
 +      OVS_DEBUG("connect(): %s [family=%d]", STRERRNO, rp->ai_family);
      } else {
        /* send notification to event thread */
-       ovs_db_event_post(pdb, OVS_DB_EVENT_CONN_ESTABLISHED);
        pdb->sock = sock;
+       ovs_db_event_post(pdb, OVS_DB_EVENT_CONN_ESTABLISHED);
        break;
      }
    }
@@@ -792,10 -796,12 +793,10 @@@ static void *ovs_poll_worker(void *arg
  
    /* poll data */
    while (ovs_db_poll_is_running(pdb)) {
 -    char errbuff[OVS_ERROR_BUFF_SIZE];
      poll_fd.fd = pdb->sock;
      int poll_ret = poll(&poll_fd, 1, /* ms */ OVS_DB_POLL_TIMEOUT * 1000);
      if (poll_ret < 0) {
 -      sstrerror(errno, errbuff, sizeof(errbuff));
 -      OVS_ERROR("poll(): %s", errbuff);
 +      OVS_ERROR("poll(): %s", STRERRNO);
        break;
      } else if (poll_ret == 0) {
        OVS_DEBUG("poll(): timeout");
        char buff[OVS_DB_POLL_READ_BLOCK_SIZE];
        ssize_t nbytes = recv(poll_fd.fd, buff, sizeof(buff), 0);
        if (nbytes < 0) {
 -        sstrerror(errno, errbuff, sizeof(errbuff));
 -        OVS_ERROR("recv(): %s", errbuff);
 +        OVS_ERROR("recv(): %s", STRERRNO);
          /* read error? Try to reconnect */
          close(poll_fd.fd);
          continue;
@@@ -862,26 -869,30 +863,30 @@@ static void *ovs_event_worker(void *arg
      ts.tv_sec += (OVS_DB_EVENT_TIMEOUT);
      int ret = pthread_cond_timedwait(&pdb->event_thread.cond,
                                       &pdb->event_thread.mutex, &ts);
-     if (!ret) {
+     if (!ret || ret == ETIMEDOUT) {
        /* handle the event */
        OVS_DEBUG("handle event %d", pdb->event_thread.value);
        switch (pdb->event_thread.value) {
        case OVS_DB_EVENT_CONN_ESTABLISHED:
          if (pdb->cb.post_conn_init)
            pdb->cb.post_conn_init(pdb);
+         /* reset event */
+         pdb->event_thread.value = OVS_DB_EVENT_NONE;
          break;
        case OVS_DB_EVENT_CONN_TERMINATED:
          if (pdb->cb.post_conn_terminate)
            pdb->cb.post_conn_terminate();
+         /* reset event */
+         pdb->event_thread.value = OVS_DB_EVENT_NONE;
+         break;
+       case OVS_DB_EVENT_NONE:
+         /* wait timeout */
+         OVS_DEBUG("no event received (timeout)");
          break;
        default:
          OVS_DEBUG("unknown event received");
          break;
        }
-     } else if (ret == ETIMEDOUT) {
-       /* wait timeout */
-       OVS_DEBUG("no event received (timeout)");
-       continue;
      } else {
        /* unexpected error */
        OVS_ERROR("pthread_cond_timedwait() failed");
@@@ -927,11 -938,10 +932,10 @@@ static int ovs_db_event_thread_init(ovs
    return 0;
  }
  
- /* Destroy EVENT thread */
- /* XXX: Must hold pdb->mutex when calling! */
- static int ovs_db_event_thread_destroy(ovs_db_t *pdb) {
+ /* Terminate EVENT thread */
+ static int ovs_db_event_thread_terminate(ovs_db_t *pdb) {
    if (pthread_equal(pdb->event_thread.tid, (pthread_t){0})) {
-     /* already destroyed */
+     /* already terminated */
      return 0;
    }
    ovs_db_event_post(pdb, OVS_DB_EVENT_TERMINATE);
     * performs some task (handles event) and releases it when
     * while sleeping. Thus, if event thread exits, the mutex
     * remains locked */
+   pdb->event_thread.tid = (pthread_t){0};
    pthread_mutex_unlock(&pdb->event_thread.mutex);
+   return 0;
+ }
+ /* Destroy EVENT thread private data */
+ static void ovs_db_event_thread_data_destroy(ovs_db_t *pdb) {
+   /* destroy mutex */
    pthread_mutex_destroy(&pdb->event_thread.mutex);
    pthread_cond_destroy(&pdb->event_thread.cond);
-   pdb->event_thread.tid = (pthread_t){0};
-   return 0;
  }
  
  /* Initialize POLL thread */
@@@ -1247,23 -1262,26 +1256,26 @@@ int ovs_db_destroy(ovs_db_t *pdb) 
    if (pdb == NULL)
      return -1;
  
+   /* stop event thread */
+   if (ovs_db_event_thread_terminate(pdb) < 0) {
+     OVS_ERROR("stop event thread failed");
+     ovs_db_ret = -1;
+   }
    /* try to lock the structure before releasing */
    if ((ret = pthread_mutex_lock(&pdb->mutex))) {
      OVS_ERROR("pthread_mutex_lock() DB mutex lock failed (%d)", ret);
      return -1;
    }
  
-   /* stop poll thread */
-   if (ovs_db_event_thread_destroy(pdb) < 0) {
+   /* stop poll thread and destroy thread's private data */
+   if (ovs_db_poll_thread_destroy(pdb) < 0) {
      OVS_ERROR("destroy poll thread failed");
      ovs_db_ret = -1;
    }
  
-   /* stop event thread */
-   if (ovs_db_poll_thread_destroy(pdb) < 0) {
-     OVS_ERROR("stop event thread failed");
-     ovs_db_ret = -1;
-   }
+   /* destroy event thread private data */
+   ovs_db_event_thread_data_destroy(pdb);
  
    pthread_mutex_unlock(&pdb->mutex);