Ignore:
Timestamp:
Mar 27, 2018, 4:05:17 PM (7 years ago)
Author:
bird
Message:

kmk/win: Windows kmk now defaults to --output-sync=target. Fixed output sync on windows in nested make processes that got busted by winchildren and it's no inheritance policy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/w32/compat/posixfcn.c

    r3140 r3194  
    154154record_sync_mutex (const char *str)
    155155{
     156#ifdef CONFIG_NEW_WIN_CHILDREN
     157  HANDLE hmtx = OpenMutexA(SYNCHRONIZE, FALSE /*fInheritable*/, str);
     158  if (hmtx)
     159    mutex_handle = (intptr_t)hmtx;
     160  else
     161    {
     162      mutex_handle = -1;
     163      errno = ENOENT;
     164    }
     165#else
    156166  char *endp;
    157167  intptr_t hmutex = strtol (str, &endp, 16);
     
    164174      errno = EINVAL;
    165175    }
     176#endif
    166177}
    167178
    168179/* Create a new mutex or reuse one created by our parent.  */
    169180intptr_t
     181#ifdef CONFIG_NEW_WIN_CHILDREN
     182create_mutex (char *mtxname, size_t size)
     183#else
    170184create_mutex (void)
    171 {
     185#endif
     186{
     187#ifndef CONFIG_NEW_WIN_CHILDREN
    172188  SECURITY_ATTRIBUTES secattr;
     189#endif
    173190  intptr_t hmutex = -1;
    174191
     
    176193     that.  */
    177194  if (mutex_handle > 0)
    178     return mutex_handle;
    179 
     195    {
     196#ifdef CONFIG_NEW_WIN_CHILDREN
     197      mtxname[0] = '\0';
     198#endif
     199      return mutex_handle;
     200    }
     201
     202#ifdef CONFIG_NEW_WIN_CHILDREN
     203  /* We're the top-level Make. Child Make processes will open our mutex, since
     204     children does not inherit any handles other than the three standard ones. */
     205  snprintf(mtxname, size, "Make-output-%u-%u-%u", GetCurrentProcessId(),
     206           GetCurrentThreadId(), GetTickCount());
     207  hmutex = (intptr_t)CreateMutexA (NULL, FALSE /*Locked*/, mtxname);
     208#else
    180209  /* We are the top-level Make, and we want the handle to be inherited
    181210     by our child processes.  */
     
    185214
    186215  hmutex = (intptr_t)CreateMutex (&secattr, FALSE, NULL);
     216#endif
    187217  if (!hmutex)
    188218    {
Note: See TracChangeset for help on using the changeset viewer.