Changeset 174 for trunk/src


Ignore:
Timestamp:
Aug 27, 2008, 5:40:28 PM (16 years ago)
Author:
katerina
Message:

Fix for tickets #112, #113 (dnmalloc deadlock on fork, hostname portability in test script).

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/dnmalloc.c

    r173 r174  
    15081508    pthread_mutex_unlock(&mALLOC_MUTEx);
    15091509}
    1510 void dnmalloc_fork_child(void) {
     1510void dnmalloc_fork_child(void) {
     1511  int rc;
    15111512#ifdef __GLIBC__
    15121513  if (dnmalloc_use_mutex)
    1513     pthread_mutex_init(&mALLOC_MUTEx, NULL);
     1514    {
     1515      pthread_mutex_unlock (&mALLOC_MUTEx);
     1516      pthread_mutex_destroy(&mALLOC_MUTEx);
     1517      rc = pthread_mutex_init(&mALLOC_MUTEx, NULL);
     1518    }
    15141519#else
    15151520  if (dnmalloc_use_mutex)
    1516     pthread_mutex_unlock(&mALLOC_MUTEx);
    1517 #endif
     1521    rc = pthread_mutex_unlock(&mALLOC_MUTEx);
     1522#endif
     1523  if (rc != 0)
     1524    {
     1525      fputs("fork_child failed", stderr);
     1526      _exit(EXIT_FAILURE);
     1527    }
    15181528}
    15191529static int dnmalloc_mutex_lock(pthread_mutex_t *mutex)
  • trunk/src/samhain.c

    r172 r174  
    12341234  /* --- Close all but first three file descriptors. ---
    12351235   */
    1236   sh_unix_closeall(3, -1); /* at program start */
     1236  sh_unix_closeall(3, -1, SL_FALSE); /* at program start */
    12371237
    12381238
  • trunk/src/sh_entropy.c

    r171 r174  
    581581      /* don't leak file descriptors
    582582       */
    583       sh_unix_closeall (3, -1); /* in child process */
     583      sh_unix_closeall (3, -1, SL_TRUE); /* in child process */
    584584
    585585      /* zero priv info
  • trunk/src/sh_extern.c

    r170 r174  
    294294           */
    295295#if !defined(PDGBFILE)
    296           sh_unix_closeall (3, task->com_fd); /* in child process */
     296          sh_unix_closeall (3, task->com_fd, SL_TRUE); /* in child process */
    297297#endif
    298298
  • trunk/src/sh_gpg.c

    r170 r174  
    487487      /* don't leak file descriptors
    488488       */
    489       sh_unix_closeall (3, -1); /* in child process */
     489      sh_unix_closeall (3, -1, SL_TRUE); /* in child process */
    490490
    491491      if (NULL == freopen(_("/dev/null"), "r+", stderr))
  • trunk/src/sh_unix.c

    r172 r174  
    12461246#endif
    12471247
    1248 void sh_unix_closeall (int fd, int except)
     1248void sh_unix_closeall (int fd, int except, int inchild)
    12491249{
    12501250  int fdx = fd;
     
    12811281    }
    12821282
    1283   sl_dropall (fdx, except);
     1283  if (!inchild)
     1284    sl_dropall (fdx, except);
     1285  else
     1286    sl_dropall_dirty (fdx, except);
    12841287
    12851288  SL_RET0(_("sh_unix_closeall"));
  • trunk/src/slib.c

    r170 r174  
    20932093            (void) free(ofiles[fd]->path);
    20942094          (void) free(ofiles[fd]);
     2095          ofiles[fd] = NULL;
     2096        }
     2097      ++fd;
     2098    }
     2099  return 0;
     2100}
     2101
     2102int sl_dropall_dirty(int fd, int except)
     2103{
     2104  while (fd < MAXFD)
     2105    {
     2106      if (ofiles[fd] != NULL && fd != except)
     2107        {
    20952108          ofiles[fd] = NULL;
    20962109        }
Note: See TracChangeset for help on using the changeset viewer.