Changeset 1583


Ignore:
Timestamp:
Oct 13, 2004, 5:08:24 AM (21 years ago)
Author:
bird
Message:

Fixed freopen deadlock. Changed _closestream to require STREAMV_LOCK to be taken before call.

Location:
trunk/src/emx/src/lib/io
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/io/_fopen.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1582 r1583  
    3535    default:
    3636      errno = EINVAL;
     37      STREAMV_LOCK;
    3738      _closestream (dst);
     39      STREAMV_UNLOCK;
    3840      return NULL;
    3941    }
     
    8183  if (_fmutex_create (&dst->__u.__fsem, 0) != 0)
    8284    {
     85      STREAMV_LOCK;
    8386      _closestream (dst);
     87      STREAMV_UNLOCK;
    8488      return NULL;
    8589    }
     
    8791  if (dst->_handle < 0)
    8892    {
     93      STREAMV_LOCK;
    8994      _closestream (dst);
     95      STREAMV_UNLOCK;
    9096      return NULL;
    9197    }
  • trunk/src/emx/src/lib/io/_mfopen.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1582 r1583  
    7474        {
    7575          errno = ENOMEM;
     76          STREAMV_LOCK;
    7677          _closestream (stream);
     78          STREAMV_UNLOCK;
    7779          return NULL;
    7880        }
     
    109111
    110112  buf = stream->_buffer;
     113  STREAMV_LOCK;
    111114  _closestream (stream);
     115  STREAMV_UNLOCK;
    112116  return buf;
    113117}
  • trunk/src/emx/src/lib/io/_newstre.c

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1582 r1583  
    109109
    110110    if (stream->__pSV)
    111     {
    112         STREAMV_LOCK;
    113111        ((struct streamvec *)stream->__pSV)->cFree++;
    114         STREAMV_UNLOCK;
    115     }
    116112}
  • trunk/src/emx/src/lib/io/fclose.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1582 r1583  
    66#include <string.h>
    77#include <io.h>
     8#include <386/builtin.h>
     9#include <sys/fmutex.h>
    810#include <emx/io.h>
    911
     
    3032        free (stream->_buffer);
    3133    }
     34  STREAMV_LOCK;
    3235  _closestream (stream);
     36  STREAMV_UNLOCK;
    3337  return result;
    3438}
  • trunk/src/emx/src/lib/io/fdopen.c

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1582 r1583  
    3232  if (_fmutex_create (&dst->__u.__fsem, 0) != 0)
    3333    {
     34      STREAMV_LOCK;
    3435      _closestream (dst);
     36      STREAMV_UNLOCK;
    3537      return NULL;
    3638    }
     
    4749      break;
    4850    default:
     51      STREAMV_LOCK;
    4952      _closestream (dst);
     53      STREAMV_UNLOCK;
    5054      return NULL;
    5155    }
  • trunk/src/emx/src/lib/io/freopen.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1582 r1583  
    1414  STREAMV_LOCK;
    1515  if (stream->_flags & _IOOPEN)
    16     fclose (stream);
     16    { /* duplication of fclose(), but no _closestream lock. */
     17      int result;
     18      char buf[L_tmpnam];
     19
     20      result = EOF;
     21      if ((stream->_flags & _IOOPEN) && !(stream->_flags & _IOSPECIAL))
     22        {
     23          result = 0;
     24          result = fflush (stream);
     25          if (close (stream->_handle) < 0)
     26            result = EOF;
     27          if (result == 0 && (stream->_flags & _IOTMP))
     28            {
     29              _itoa (stream->_tmpidx, buf, 10);
     30              strcat (buf, ".tmp");
     31              if (remove (buf) != 0)
     32                result = EOF;
     33            }
     34          if ((stream->_flags & _IOBUFMASK) == _IOBUFLIB)
     35            free (stream->_buffer);
     36        }
     37      _closestream (stream);
     38    }
    1739  result = _openstream (stream, fname, mode, SH_DENYNO, 0);
    1840  STREAMV_UNLOCK;
Note: See TracChangeset for help on using the changeset viewer.