gnunet-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-developers] threads & deadlocks


From: Jussi Eloranta
Subject: [GNUnet-developers] threads & deadlocks
Date: Thu, 23 Dec 2004 00:10:08 +0200

Hello,

I have been experiencing deadlocks with gnunet-gtk on macos x.
This happens during searches where one gets many replies.

After some heuristic debugging, I found that the following change in
util/semaphore.c resolved the problem (look at the comment line):

int semaphore_up_(Semaphore * s,
                  const char * filename,
                  const int linenumber) {
  int value_after_op;
  pthread_cond_t * cond;

  GNUNET_ASSERT_FL(s != NULL, filename, linenumber);
  cond = s->cond;
#if DEBUG_SEMUPDOWN
  LOG(LOG_DEBUG,
      "semaphore_up %p enter at %s:%d\n",
      s,
      filename,
      linenumber);
#endif
  MUTEX_LOCK(&(s->mutex));
  (s->v)++;
  value_after_op = s->v;
  /* The lines below were originally in opposite order */
  GNUNET_ASSERT(0 == pthread_cond_signal(cond));
  MUTEX_UNLOCK(&(s->mutex));

#if DEBUG_SEMUPDOWN
  LOG(LOG_DEBUG,
      "semaphore_up %p exit at %s:%d\n",
      s,
      filename,
      linenumber);
#endif
  return value_after_op;
}

After this change it works (look at the comment line in the code). I don't immediately see why this would change anything but in practice it does... Or may be it enforces that signal and wait calls will "match"?


Best regards,

Jussi Eloranta





reply via email to

[Prev in Thread] Current Thread [Next in Thread]