[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make run in parallel mode with output redirected to a regular file c
From: |
Eli Zaretskii |
Subject: |
Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines |
Date: |
Fri, 31 May 2013 18:27:04 +0300 |
> Date: Fri, 31 May 2013 16:58:21 +0200
> Cc: address@hidden, address@hidden, address@hidden
> From: Frank Heckenbach <address@hidden>
>
> > > void write (int fd, void *data, size_t size)
> > > {
> > > if (getflags (fd) & O_APPEND)
> > > {
> > > lock_mutex (get_mutex (fd));
> > > off_t pos = get_size (fd);
> > > do_write (fd, pos, data, size);
> > > set_pos (fd, pos + size);
> > > unlock_mutex (get_mutex (fd));
> > > }
> > > else
> > > {
> > > // no mutex here!
> > > off_t pos = get_pos (fd);
> > > do_write (fd, pos, data, size);
> > > set_pos (fd, pos + size);
> > > }
> > > }
> >
> > If the 'else' clause uses a single file pointer system-wise, there's
> > no overwriting because the pointer is not moved between writes.
>
> I still can't follow you. Just imagine this function is run by two
> different processes simultaneously with the same FD without
> O_APPEND. Both fetch the current position (get_pos) and get the same
> value. Then both write (do_write) at this same position, overwriting
> each other. Finally, both update the file pointer (set_pos), but
> again, only the 2nd one becomes effective.
There's no reason for them to call get_pos. do_write moves the
pointer as a side effect.
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, (continued)
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Eli Zaretskii, 2013/05/27
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Paul Smith, 2013/05/27
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Eli Zaretskii, 2013/05/27
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Frank Heckenbach, 2013/05/29
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Eli Zaretskii, 2013/05/29
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Frank Heckenbach, 2013/05/29
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Eli Zaretskii, 2013/05/30
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Frank Heckenbach, 2013/05/30
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Eli Zaretskii, 2013/05/31
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Frank Heckenbach, 2013/05/31
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines,
Eli Zaretskii <=
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Frank Heckenbach, 2013/05/31
- RE: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Martin Dorey, 2013/05/29
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Frank Heckenbach, 2013/05/29
- Re: Make run in parallel mode with output redirected to a regular file can randomly drop output lines, Frank Heckenbach, 2013/05/30